openstack pike安裝

wang_0720發表於2018-01-30
節點規劃
準備4臺虛機,分別做Controller,Network,Compute,Middleware。
Controller安裝keystone,glance,nova-api,nova-conductor,nova-scheduler,nova-placement
Network安裝neutron相關元件
Compute安裝nova-compute
Middleware安裝mariadb,rabbitmq,memcache。
網路規劃
controller
  eth0: 192.168.100.111 external
  eth1: 10.1.1.1 admim
network 
  eth0: 192.168.100.114 external
  eth1: 10.1.1.4 admin
  eth2: 10.2.2.4 tunnel
compute
  eth0: 192.168.100.112 external
  eth1: 10.1.1.2 admin
  eth2: 10.2.2.2 tunnel
middleware (mysql,mq,memcache)
  eth1: 10.1.1.3 admin
基礎配置
每個節點都按如下操作
hosts檔案
echo "
10.1.1.1 controller
10.1.1.2 compute
10.1.1.3 middleware
10.1.1.4 network
" >>/etc/hosts
配置yum源
yum install -y  wget
wget -O /etc/yum.repos.d/CentOS-Base.repo
yum install centos-release-openstack-pike -y
yum clean all && yum makecache
時間同步
echo "*/3 * * * * /usr/sbin/ntpdate ntp6.aliyun.com  &> /dev/null" > /tmp/crontab
crontab /tmp/crontab
Middleware節點
安裝資料庫
yum install -y mariadb-server 
systemctl restart mariadb.service
systemctl enable mariadb.service
安裝rabbitmq
yum install -y erlang rabbitmq-server
systemctl restart rabbitmq-server 
systemctl enable rabbitmq-server
建立openstack使用者,並設定密碼
rabbitmqctl add_user openstack 123456
給openstack使用者賦予許可權
rabbitmqctl set_permissions openstack ".*" ".*" ".*"
rabbitmqctl set_user_tags openstack administrator
rabbitmqctl list_users
開啟RabbitMQ相關外掛
/usr/lib/rabbitmq/bin/rabbitmq-plugins enable rabbitmq_management mochiweb webmachine rabbitmq_web_dispatch amqp_client rabbitmq_management_agent
檢視RabbitMQ外掛
/usr/lib/rabbitmq/bin/rabbitmq-plugins list
安裝memcached
yum install -y memcached python-memcached
配置memcache監聽埠
sed -i  's/OPTIONS*.*/OPTIONS="-l 127.0.0.1,10.1.1.3"/' /etc/sysconfig/memcached
重啟memcache並設定開機啟動
systemctl restart memcached.service
systemctl enable memcached.service
systemctl status memcached.service


Controller節點
安裝keystone
yum  -y install openstack-keystone httpd mod_wsgi python-openstackclient openstack-utils  
建立keystone庫,並給keystone使用者授權
create database keystone;
grant all privileges on keystone.* to 'keystone'@'localhost' identified by '123456';
grant all privileges on keystone.* to 'keystone'@'%' identified by '123456';
配置/etc/keystone/keystone.conf 
 cp /etc/keystone/keystone.conf /etc/keystone/keystone.conf.bak
 > /etc/keystone/keystone.conf

 openstack-config --set /etc/keystone/keystone.conf DEFAULT transport_url rabbit://openstack:123456@middleware
 openstack-config --set /etc/keystone/keystone.conf database connection mysql://keystone:123456@middleware/keystone
 openstack-config --set /etc/keystone/keystone.conf cache backend oslo_cache.memcache_pool
 openstack-config --set /etc/keystone/keystone.conf cache enabled true
 openstack-config --set /etc/keystone/keystone.conf cache memcache_servers middleware:11211
 openstack-config --set /etc/keystone/keystone.conf memcache servers middleware:11211
 openstack-config --set /etc/keystone/keystone.conf token expiration 3600
 openstack-config --set /etc/keystone/keystone.conf token provider fernet
配置httpd.conf檔案
 sed  -i  "s/ServerName controller/" /etc/httpd/conf/httpd.conf
配置keystone與httpd結合
 ln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/
建立identity表結構
su -s /bin/sh -c "keystone-manage db_sync" keystone
初始化fernet
keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
keystone-manage credential_setup --keystone-user keystone --keystone-group keystone
啟動httpd,並設定httpd開機啟動
 systemctl enable httpd.service
 systemctl restart httpd.service
 systemctl status httpd.service
建立admin使用者角色

keystone-manage bootstrap --bootstrap-password 123456 --bootstrap-admin-url --bootstrap-internal-url --bootstrap-public-url --bootstrap-region-id RegionOne --bootstrap-username admin --bootstrap-project-name admin --bootstrap-role-name admin --bootstrap-service-name keystone

驗證

openstack project list --os-username admin --os-project-name admin --os-user-domain-id default --os-project-domain-id default --os-identity-api-version 3 --os-auth-url --os-password 123456

建立admin使用者環境變數,建立/root/admin-openrc 檔案
cat >> /root/admin-openrc <<eof
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_DOMAIN_ID=default
export OS_USERNAME=admin
export OS_PROJECT_NAME=admin
export OS_PASSWORD=123456
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
export OS_AUTH_URL=
EOF
建立service專案
 source /root/admin-openrc
 openstack project create --domain default   --description "Service Project" service
建立demo專案
 openstack project create --domain default   --description "Demo Project" demo
建立demo使用者,並設定密碼
 openstack user create --domain default  demo  --password 123456
建立user角色並將demo使用者賦予user角色
 openstack role create user
 openstack role add --project demo --user demo user
驗證keystone

unset OS_TOKEN  OS_URL
openstack --os-auth-url   --os-project-domain-name default --os-user-domain-name default   --os-project-name admin --os-username admin token issue --os-password 123456
openstack --os-auth-url    --os-project-domain-name default --os-user-domain-name default   --os-project-name demo --os-username demo token issue --os-password 123456

安裝glance
建立glance資料庫
CREATE DATABASE glance;
建立資料庫使用者並賦予許可權
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY '123456';
建立glance使用者及賦予admin許可權
 source /root/admin-openrc
 openstack user create  --domain default glance  --password 123456
 openstack role add --project service --user glance admin
建立image服務
 openstack service create --name glance --description "OpenStack Image service" image
建立glance的endpoint
 openstack endpoint create --region RegionOne  image public
 openstack endpoint create --region RegionOne  image internal
 openstack endpoint create --region RegionOne  image admin
安裝glance相關的軟體包
yum install -y openstack-glance python-glance 
配置/etc/glance/glance-api.conf
cp /etc/glance/glance-api.conf /etc/glance/glance-api.conf.bak
 \>/etc/glance/glance-api.conf

 openstack-config --set  /etc/glance/glance-api.conf DEFAULT transport_url rabbit://openstack:123456@middleware
 openstack-config --set  /etc/glance/glance-api.conf database connection  mysql+pymysql://glance:123456@middleware/glance
 openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken auth_uri 
 openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken auth_url 
 openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken memcached_servers  middleware:11211
 openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken auth_type  password
 openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken project_domain_name  default
 openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken user_domain_name   default  
 openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken project_name  service
 openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken username  glance
 openstack-config --set  /etc/glance/glance-api.conf keystone_authtoken password  123456
 openstack-config --set  /etc/glance/glance-api.conf paste_deploy flavor  keystone
 openstack-config --set  /etc/glance/glance-api.conf glance_store stores  file,http
 openstack-config --set  /etc/glance/glance-api.conf glance_store default_store  file
 openstack-config --set  /etc/glance/glance-api.conf glance_store filesystem_store_datadir  /var/lib/glance/images/

配置/etc/glance/glance-registry.conf
cp /etc/glance/glance-registry.conf /etc/glance/glance-registry.conf.bak
>/etc/glance/glance-registry.conf

 openstack-config --set  /etc/glance/glance-registry.conf DEFAULT transport_url rabbit://openstack:devops@middleware
 openstack-config --set  /etc/glance/glance-registry.conf database connection  mysql+pymysql://glance:123456@middleware/glance
 openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken auth_uri 
 openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken auth_url 
 openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken memcached_servers  middleware:11211  
 openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken auth_type  password
 openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken project_domain_name  default
 openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken user_domain_name  default
 openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken project_name  service
 openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken username  glance
 openstack-config --set  /etc/glance/glance-registry.conf keystone_authtoken password 123456
 openstack-config --set  /etc/glance/glance-registry.conf paste_deploy flavor  keystone

同步glance資料庫,初始化glance表結構
/bin/sh -c "glance-manage db_sync" glance
建立映象儲存目錄並賦予glance使用者和組許可權
mkdir /var/lib/glance/images
chown glance.glance /var/lib/glance/images
chown glance.glance /var/log/glance/api.log
啟動glance服務及設定開機啟動
 systemctl enable openstack-glance-api.service openstack-glance-registry.service
 systemctl restart openstack-glance-api.service openstack-glance-registry.service
 systemctl status openstack-glance-api.service openstack-glance-registry.service
下載測試映象檔案
 wget 
上傳映象到glance
source /root/admin-openrc

glance image-create --name "cirros-0.3.4-x86_64" --file cirros-0.3.4-x86_64-disk.img  --disk-format qcow2 --container-format bare --visibility public --progress

檢視映象列表:
glance image-list
安裝nova (controller部分)
建立資料庫
create database nova;
create database nova_api;
create database nova_cell0;
資料庫授權
grant all privileges on nova.* to nova@'localhost' identified by '123456';
grant all privileges on nova.* to nova@'%' identified by '123456';
grant all privileges on nova_api.* to nova@'localhost' identified by '123456';
grant all privileges on nova_api.* to nova@'%' identified by '123456';
grant all privileges on nova_cell0.* to nova@'%' identified by '123456';
grant all privileges on nova_cell0.* to nova@'localhost' identified by '123456';
source admin-openrc
建立使用者,分配角色
openstack user create --domain default nova --password 123456
openstack role add --project service --user nova admin
建立compute服務
openstack service create --name nova --description "OpenStack Compute" compute
建立endpoint
openstack endpoint create --region RegionOne compute public %\(tenant_id\)s
openstack endpoint create --region RegionOne compute internal %\(tenant_id\)s
openstack endpoint create --region RegionOne compute admin %\(tenant_id\)s
建立placement 使用者和服務
openstack user create --domain default placement --password 123456
openstack role add --project service --user placement admin
openstack service create --name placement --description "Placement API" placement
建立placement endpoint
openstack endpoint create --region RegionOne placement admin
openstack endpoint create --region RegionOne placement public
openstack endpoint create --region RegionOne placement internal
安裝nova相關軟體
yum install -y openstack-nova-api openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler openstack-nova-placement-api  
配置/etc/nova/nova.conf
cp /etc/nova/nova.conf /etc/nova/nova.conf.bak
 >/etc/nova/nova.conf

openstack-config --set /etc/nova/nova.conf DEFAULT enabled_apis  osapi_compute,metadata
openstack-config --set /etc/nova/nova.conf DEFAULT my_ip 10.1.1.1
openstack-config --set /etc/nova/nova.conf DEFAULT use_neutron True
openstack-config --set /etc/nova/nova.conf DEFAULT firewall_driver nova.firewall.NoopFirewallDriver
openstack-config --set /etc/nova/nova.conf DEFAULT transport_url rabbit://openstack:123456@middleware
openstack-config --set /etc/nova/nova.conf database connection mysql+pymysql://nova:123456@middleware/nova
openstack-config --set /etc/nova/nova.conf api_database connection mysql+pymysql://nova:123456@middleware/nova_api
openstack-config --set /etc/nova/nova.conf scheduler discover_hosts_in_cells_interval -1
openstack-config --set /etc/nova/nova.conf api auth_strategy keystone
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_uri
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_url
openstack-config --set /etc/nova/nova.conf keystone_authtoken memcached_servers middleware:11211
openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_type password openstack-config --set /etc/nova/nova.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/nova/nova.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/nova/nova.conf keystone_authtoken project_name service
openstack-config --set /etc/nova/nova.conf keystone_authtoken username nova
openstack-config --set /etc/nova/nova.conf keystone_authtoken password 123456
openstack-config --set /etc/nova/nova.conf keystone_authtoken service_token_roles_required True
openstack-config --set /etc/nova/nova.conf placement auth_url
openstack-config --set /etc/nova/nova.conf placement memcached_servers middleware:11211
openstack-config --set /etc/nova/nova.conf placement auth_type password
openstack-config --set /etc/nova/nova.conf placement project_domain_name default
openstack-config --set /etc/nova/nova.conf placement user_domain_name default
openstack-config --set /etc/nova/nova.conf placement project_name service
openstack-config --set /etc/nova/nova.conf placement username placement
openstack-config --set /etc/nova/nova.conf placement password 123456
openstack-config --set /etc/nova/nova.conf placement os_region_name RegionOne
openstack-config --set /etc/nova/nova.conf vnc vncserver_listen 192.168.100.111
openstack-config --set /etc/nova/nova.conf vnc vncserver_proxyclient_address 192.168.100.111
openstack-config --set /etc/nova/nova.conf glance api_servers
openstack-config --set /etc/nova/nova.conf oslo_concurrency lock_path /var/lib/nova/tmp

配置/etc/httpd/conf.d/00-nova-placement-api.conf
新增:

  = 2.4>
    Require all granted
  
  <ifversion
    Order allow,deny
    Allow from all
  

像下面這樣


  WSGIProcessGroup nova-placement-api
  WSGIApplicationGroup %{GLOBAL}
  WSGIPassAuthorization On
  WSGIDaemonProcess nova-placement-api processes=3 threads=1 user=nova group=nova
  WSGIScriptAlias / /usr/bin/nova-placement-api
  = 2.4>
    ErrorLogFormat "%M"
 
  ErrorLog /var/log/nova/nova-placement-api.log
 
    = 2.4>
      Require all granted
   
    <ifversion
      Order allow,deny
      Allow from all
   
 
  SSLEngine On
  SSLCertificateFile ...
  SSLCertificateKeyFile ...


重啟httpd 服務:
systemctl restart httpd.service
同步nova_api資料庫
su -s /bin/sh -c "nova-manage api_db sync" nova
同步nova_cell0資料庫
su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
建立cell1
su -s /bin/sh -c "nova-manage cell_v2   create_cell --name=cell1 --verbose" nova
nova資料庫
su -s /bin/sh -c "nova-manage db sync" nova
確認ova cell0 和 cell1註冊和建立成功
nova-manage cell_v2 list_cells
檢查部署是否正常
nova-status upgrade check
nova-manage cell_v2 discover_hosts
設定開機啟動
systemctl enable openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
重啟服務
systemctl restart openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
安裝Dashboard
安裝dashboard相關軟體包
yum install -y openstack-dashboard
修改配置檔案/etc/openstack-dashboard/local_settings
vim /etc/openstack-dashboard/local_settings
需要該的部分
ALLOWED_HOSTS = ['*',]


CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
        'LOCATION': 'middleware:11211',
    },
}


OPENSTACK_HOST = "controller"
OPENSTACK_KEYSTONE_URL = "http://%s:5000/v2.0" % OPENSTACK_HOST
OPENSTACK_KEYSTONE_URL = "http://%s:5000/v3" % OPENSTACK_HOST
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "user"


啟動dashboard服務並設定開機啟動
systemctl restart httpd.service memcached.service
systemctl status httpd.service memcached.service
Network節點
建立neutron資料庫
create database neutron;
資料庫授權
grant all privileges on neutron.* to neutron@'localhost' identified by '123456';
grant all privileges on neutron.* to neutron@'%' identified by '123456';
建立使用者
openstack user create --domain default neutron --password 123456
給使用者分配角色
openstack role add --project service --user neutron admin
建立服務
openstack service create --name neutron --description "OpenStack Networking" network
建立端點
openstack endpoint create --region RegionOne network public
openstack endpoint create --region RegionOne network internal
openstack endpoint create --region RegionOne network admin
安裝相關軟體
yum install -y openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables 
配置neutron.conf
 cp /etc/neutron/neutron.conf /etc/neutron/neutron.conf.bak
 >/etc/neutron/neutron.conf
 openstack-config --set /etc/neutron/neutron.conf DEFAULT core_plugin ml2
 openstack-config --set /etc/neutron/neutron.conf DEFAULT service_plugins router
 openstack-config --set /etc/neutron/neutron.conf DEFAULT allow_overlapping_ips True
 openstack-config --set /etc/neutron/neutron.conf DEFAULT auth_strategy keystone
 openstack-config --set /etc/neutron/neutron.conf DEFAULT transport_url rabbit://openstack:123456@middleware
 openstack-config --set /etc/neutron/neutron.conf DEFAULT notify_nova_on_port_status_changes True
 openstack-config --set /etc/neutron/neutron.conf DEFAULT notify_nova_on_port_data_changes True
 openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_uri
 openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_url
 openstack-config --set /etc/neutron/neutron.conf keystone_authtoken memcached_servers middleware:11211
 openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_type password
 openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_domain_name default
 openstack-config --set /etc/neutron/neutron.conf keystone_authtoken user_domain_name default
 openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_name service
 openstack-config --set /etc/neutron/neutron.conf keystone_authtoken username neutron
 openstack-config --set /etc/neutron/neutron.conf keystone_authtoken password 123456
 openstack-config --set /etc/neutron/neutron.conf database connection mysql+pymysql://neutron:123456@middleware/neutron
 openstack-config --set /etc/neutron/neutron.conf nova auth_url
 openstack-config --set /etc/neutron/neutron.conf nova auth_type password
 openstack-config --set /etc/neutron/neutron.conf nova project_domain_name default
 openstack-config --set /etc/neutron/neutron.conf nova user_domain_name default
 openstack-config --set /etc/neutron/neutron.conf nova region_name RegionOne
 openstack-config --set /etc/neutron/neutron.conf nova project_name service
 openstack-config --set /etc/neutron/neutron.conf nova username nova
 openstack-config --set /etc/neutron/neutron.conf nova password 123456
 openstack-config --set /etc/neutron/neutron.conf oslo_concurrency lock_path /var/lib/neutron/tmp
```
配置ml2_config.ini
cp /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugins/ml2/ml2_conf.ini.bak
 >/etc/neutron/plugins/ml2/ml2_conf.ini

 openstack-config --set   /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers flat,vlan,vxlan
 openstack-config --set   /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers linuxbridge,l2population
 openstack-config --set   /etc/neutron/plugins/ml2/ml2_conf.ini ml2 extension_drivers port_security
 openstack-config --set   /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types vxlan
 openstack-config --set   /etc/neutron/plugins/ml2/ml2_conf.ini ml2 path_mtu 1500
 openstack-config --set   /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_flat flat_networks  provider
 openstack-config --set   /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_vxlan vni_ranges  1:1000
 openstack-config --set   /etc/neutron/plugins/ml2/ml2_conf.ini securitygroup enable_ipset  True

cp /etc/neutron/plugins/ml2/linuxbridge_agent.ini /etc/neutron/plugins/ml2/linuxbridge_agent.ini.bak
>/etc/neutron/plugins/ml2/linuxbridge_agent.ini

openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini DEFAULT debug false
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings provider:eth0
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan enable_vxlan True
openstack-config --set  /etc/neutron/plugins/ml2/linuxbridge_agent.ini  vxlan  local_ip  10.2.2.4
openstack-config --set  /etc/neutron/plugins/ml2/linuxbridge_agent.ini  vxlan l2_population  True
openstack-config --set  /etc/neutron/plugins/ml2/linuxbridge_agent.ini  agent  prevent_arp_spoofing  True
openstack-config --set  /etc/neutron/plugins/ml2/linuxbridge_agent.ini  securitygroup  enable_security_group  True
openstack-config --set   /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup  firewall_driver  neutron.agent.linux.iptables_firewall.IptablesFirewallDriver

注意provider:eth0,中eth0是外網網路卡,一般這裡寫的網路卡名都是能訪問外網的,如果不是外網網路卡,那麼VM就會與外界網路隔離。
local_ip 定義的是隧道網路


配置 /etc/neutron/l3_agent.ini
 cp /etc/neutron/l3_agent.ini /etc/neutron/l3_agent.ini.bak
 >/etc/neutron/l3_agent.ini

 openstack-config --set  /etc/neutron/l3_agent.ini  DEFAULT  interface_driver  neutron.agent.linux.interface.BridgeInterfaceDriver
 openstack-config --set  /etc/neutron/l3_agent.ini  DEFAULT  external_network_bridge
 openstack-config --set  /etc/neutron/l3_agent.ini  DEFAULT  debug false

配置/etc/neutron/dhcp_agent.ini
cp /etc/neutron/dhcp_agent.ini /etc/neutron/dhcp_agent.ini.bak
>/etc/neutron/dhcp_agent.ini

 openstack-config --set  /etc/neutron/dhcp_agent.ini  DEFAULT  interface_driver  neutron.agent.linux.interface.BridgeInterfaceDriver
 openstack-config --set  /etc/neutron/dhcp_agent.ini  DEFAULT dhcp_driver  neutron.agent.linux.dhcp.Dnsmasq
 openstack-config --set  /etc/neutron/dhcp_agent.ini  DEFAULT enable_isolated_metadata True
 openstack-config --set  /etc/neutron/dhcp_agent.ini  DEFAULT verbose True
 openstack-config --set  /etc/neutron/dhcp_agent.ini  DEFAULT debug false

配置controller節點的/etc/nova/nova.conf,讓compute節點能使用上neutron網路

 openstack-config --set  /etc/nova/nova.conf  neutron url 
 openstack-config --set  /etc/nova/nova.conf  neutron auth_url 
 openstack-config --set  /etc/nova/nova.conf  neutron auth_type  password
 openstack-config --set  /etc/nova/nova.conf  neutron project_domain_name  default
 openstack-config --set  /etc/nova/nova.conf  neutron user_domain_name  default
 openstack-config --set  /etc/nova/nova.conf  neutron region_name  RegionOne
 openstack-config --set  /etc/nova/nova.conf  neutron project_name service
 openstack-config --set  /etc/nova/nova.conf  neutron username  neutron
 openstack-config --set  /etc/nova/nova.conf  neutron password  123456
 openstack-config --set  /etc/nova/nova.conf  neutron service_metadata_proxy  True
 openstack-config --set  /etc/nova/nova.conf  neutron metadata_proxy_shared_secret  123456

將dhcp-option-force=26,1450寫入/etc/neutron/dnsmasq-neutron.conf
 echo "dhcp-option-force=26,1450" >/etc/neutron/dnsmasq-neutron.conf
配置/etc/neutron/metadata_agent.ini
cp /etc/neutron/metadata_agent.ini /etc/neutron/metadata_agent.ini.bak
>/etc/neutron/metadata_agent.ini
 
openstack-config --set  /etc/neutron/metadata_agent.ini  DEFAULT nova_metadata_ip controller
openstack-config --set  /etc/neutron/metadata_agent.ini  DEFAULT metadata_proxy_shared_secret 123456
openstack-config --set  /etc/neutron/metadata_agent.ini  DEFAULT metadata_workers 4
openstack-config --set  /etc/neutron/metadata_agent.ini  DEFAULT verbose  True
openstack-config --set  /etc/neutron/metadata_agent.ini  DEFAULT debug false
openstack-config --set  /etc/neutron/metadata_agent.ini  DEFAULT nova_metadata_protocol http

建立硬連結
 ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
同步資料庫,初始化neutron表結構
su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf   --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron
在controller上重啟nova服務
 systemctl restart openstack-nova-api.service
 systemctl status openstack-nova-api.service
重啟neutron服務並設定開機啟動
 systemctl enable neutron-server.service  neutron-linuxbridge-agent.service neutron-dhcp-agent.service  neutron-metadata-agent.service neutron-l3-agent.service
 systemctl restart neutron-server.service  neutron-linuxbridge-agent.service  neutron-dhcp-agent.service  neutron-metadata-agent.service neutron-l3-agent.service
 systemctl status neutron-server.service  neutron-linuxbridge-agent.service  neutron-dhcp-agent.service  neutron-metadata-agent.service neutron-l3-agent.service


openstack network agent list
建立網路
執行環境變數
 source /root/admin-openrc
建立flat模式的public網路,public是外出網路,必須是flat模式的
 neutron net-create --shared provider --router:external True --provider:network_type flat --provider:physical_network provider
本實驗環境192.168.100.0/24網段可以出外網,就以該網段作為public網段
建立子網
neutron subnet-create provider 192.168.100.0/24 --name provider-sub  --allocation-pool start=192.168.100.180,end=192.168.100.190 --dns-nameserver 8.8.8.8 --gateway 192.168.100.180
建立名為private的私有網路, 網路模式為vxlan
 neutron net-create private --provider:network_type vxlan --router:external False --shared
建立名為private-subnet的私有網路子網,網段為172.17.1.0, 這個網段就是虛擬機器獲取的私有的IP地址
neutron subnet-create private --name private-subnet --gateway 172.17.1.1  172.17.1.0/24
也可以建立多個不同的私有子網路
如果虛機要能夠訪問外部網路還需要新增路由
新增路由
neutron router-create router01
將私有網路的子網加入路由  
neutron router-interface-add router01 private-sub  
設定public網路為路由的閘道器
neutron router-gateway-set router01 provider


#Compute節點
安裝相關依賴包
yum install -y openstack-selinux python-openstackclient yum-plugin-priorities openstack-nova-compute openstack-utils 
配置nova.conf
 cp /etc/nova/nova.conf /etc/nova/nova.conf.bak
 >/etc/nova/nova.conf

 openstack-config --set /etc/nova/nova.conf DEFAULT auth_strategy  keystone
 openstack-config --set /etc/nova/nova.conf DEFAULT my_ip  10.1.1.2
 openstack-config --set /etc/nova/nova.conf DEFAULT use_neutron  True
 openstack-config --set /etc/nova/nova.conf DEFAULT firewall_driver  nova.virt.firewall.NoopFirewallDriver
 openstack-config --set /etc/nova/nova.conf DEFAULT transport_url rabbit://openstack:123456@middleware
 openstack-config --set /etc/nova/nova.conf keystone_authtoken  auth_uri 
 openstack-config --set /etc/nova/nova.conf keystone_authtoken  auth_url 
 openstack-config --set /etc/nova/nova.conf keystone_authtoken  memcached_servers  middleware:11211
 openstack-config --set /etc/nova/nova.conf keystone_authtoken  auth_type  password
 openstack-config --set /etc/nova/nova.conf keystone_authtoken  project_domain_name  default
 openstack-config --set /etc/nova/nova.conf keystone_authtoken  user_domain_name  default
 openstack-config --set /etc/nova/nova.conf keystone_authtoken  project_name  service
 openstack-config --set /etc/nova/nova.conf keystone_authtoken  username  nova
 openstack-config --set /etc/nova/nova.conf keystone_authtoken  password 123456
 openstack-config --set /etc/nova/nova.conf placement auth_uri
 openstack-config --set /etc/nova/nova.conf placement auth_url
 openstack-config --set /etc/nova/nova.conf placement memcached_servers middleware:11211
 openstack-config --set /etc/nova/nova.conf placement auth_type password
 openstack-config --set /etc/nova/nova.conf placement project_domain_name default
 openstack-config --set /etc/nova/nova.conf placement user_domain_name default
 openstack-config --set /etc/nova/nova.conf placement project_name service
 openstack-config --set /etc/nova/nova.conf placement username placement
 openstack-config --set /etc/nova/nova.conf placement password 123456
 openstack-config --set /etc/nova/nova.conf placement os_region_name RegionOne
 openstack-config --set /etc/nova/nova.conf vnc enabled True
 openstack-config --set /etc/nova/nova.conf vnc keymap en-us
 openstack-config --set /etc/nova/nova.conf vnc vncserver_listen  0.0.0.0
 openstack-config --set /etc/nova/nova.conf vnc vncserver_proxyclient_address  10.1.1.2
 openstack-config --set /etc/nova/nova.conf vnc novncproxy_base_url  http://192.168.100.112:6080/vnc_auto.html
 openstack-config --set /etc/nova/nova.conf glance  api_servers 
 openstack-config --set /etc/nova/nova.conf oslo_concurrency  lock_path  /var/lib/nova/tmp
 openstack-config --set /etc/nova/nova.conf libvirt virt_type  qemu
 openstack-config --set /etc/nova/nova.conf libvirt cpu_mode none

設定libvirtd.service 和openstack-nova-compute.service開機啟動
 systemctl enable libvirtd.service openstack-nova-compute.service
 systemctl restart libvirtd.service openstack-nova-compute.service
 systemctl status libvirtd.service openstack-nova-compute.service
到controller上執行驗證
 source /root/admin-openrc
 openstack compute service list
安裝Neutron
安裝相關軟體包
 yum install -y openstack-neutron-linuxbridge ebtables ipset 
配置neutron.conf
 cp /etc/neutron/neutron.conf /etc/neutron/neutron.conf.bak
 >/etc/neutron/neutron.conf

 openstack-config --set  /etc/neutron/neutron.conf DEFAULT auth_strategy  keystone
 openstack-config --set  /etc/neutron/neutron.conf DEFAULT advertise_mtu True
 openstack-config --set  /etc/neutron/neutron.conf DEFAULT dhcp_agents_per_network 2
 openstack-config --set  /etc/neutron/neutron.conf DEFAULT control_exchange neutron
 openstack-config --set  /etc/neutron/neutron.conf DEFAULT nova_url
 openstack-config --set  /etc/neutron/neutron.conf DEFAULT transport_url rabbit://openstack:123456@middleware
 openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken auth_uri 
 openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken auth_url 
 openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken memcached_servers  middleware:11211
 openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken auth_type  password
 openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken project_domain_name  default
 openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken user_domain_name  default
 openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken project_name  service
 openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken username  neutron
 openstack-config --set  /etc/neutron/neutron.conf keystone_authtoken password  123456
 openstack-config --set  /etc/neutron/neutron.conf oslo_concurrency  lock_path  /var/lib/neutron/tmp

配置/etc/neutron/plugins/ml2/linuxbridge_agent.ini
 cp /etc/neutron/plugins/ml2/linuxbridge_agent.ini /etc/neutron/plugins/ml2/linuxbridge_agent.ini.bak
>/etc/neutron/plugins/ml2/linuxbridge_agent.ini

 openstack-config --set  /etc/neutron/plugins/ml2/linuxbridge_agent.ini DEFAULT debug false
 openstack-config --set  /etc/neutron/plugins/ml2/linuxbridge_agent.ini DEFAULT verbose true
 openstack-config --set   /etc/neutron/plugins/ml2/linuxbridge_agent.ini  vxlan  enable_vxlan  True
 openstack-config --set   /etc/neutron/plugins/ml2/linuxbridge_agent.ini  vxlan  local_ip  10.2.2.2
 openstack-config --set   /etc/neutron/plugins/ml2/linuxbridge_agent.ini  vxlan l2_population  True
 openstack-config --set   /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup  enable_security_group  True
 openstack-config --set   /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup  firewall_driver  neutron.agent.linux.iptables_firewall.IptablesFirewallDriver

配置nova.conf

 openstack-config --set  /etc/nova/nova.conf neutron url 
 openstack-config --set  /etc/nova/nova.conf neutron auth_url 
 openstack-config --set  /etc/nova/nova.conf neutron auth_type  password
 openstack-config --set  /etc/nova/nova.conf neutron project_domain_name  default
 openstack-config --set  /etc/nova/nova.conf neutron user_domain_name  default
 openstack-config --set  /etc/nova/nova.conf neutron region_name  RegionOne
 openstack-config --set  /etc/nova/nova.conf neutron project_name  service
 openstack-config --set  /etc/nova/nova.conf neutron username  neutron
 openstack-config --set  /etc/nova/nova.conf neutron password  123456
重啟和相關服務
systemctl restart openstack-nova-compute.service neutron-linuxbridge-agent.service
systemctl enable neutron-linuxbridge-agent.service neutron-linuxbridge-agent.service


Compute節點搭建完畢,執行nova host-list可以檢視新加入的compute節點
如果需要再新增另外一個compute節點,只要重複下Compute節點部部分即可,計算機名和IP地址改下
建立配額命令controller上執行
openstack flavor create m1.tiny --id 1 --ram 1024 --disk 10 --vcpus 1
openstack flavor create m1.small --id 2 --ram 2048 --disk 20 --vcpus 1
openstack flavor create m1.medium --id 3 --ram 4096 --disk 40 --vcpus 2
openstack flavor create m1.large --id 4 --ram 8192 --disk 80 --vcpus 4
openstack flavor create m1.xlarge --id 5 --ram 16384 --disk 160 --vcpus 8
openstack flavor list
登入dashboard
http://192.168.100.111/dashboard


建立例項


一次選擇“源”->"例項型別"->"網路" 點選建立例項
建立一個名為test的例項,上圖中的test1是為了驗證建立過程新建的例項,test是已經建立的例項


例項有了,也分配了IP,此時的例項就可以出外網了,因為前面已經建立了provider網路,但外網還是不能進來,因為沒有繫結浮動IP。
分配floatingip


浮動IP關聯





建立安全組








驗證

















</eof

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27181165/viewspace-2150653/,如需轉載,請註明出處,否則將追究法律責任。

相關文章