簡介
本次部署nova組件,分別部署nova和nova-compute,nova部署到controller節點,nova-compute部署到另一臺設備,這樣部署說明nova-compute是可以部署多個進行橫向擴展的。下邊開始部署nova組件,controller節點IP 192.168.46.130,nova-compute節點IP 192.168.46.133
部署controller nova
創建數據庫
與其他組件的部署一樣,首先需要創建nova需要的數據庫,操作如下:
$ mysql -u root -p
創建nova_api、nova、nova_cell0數據庫
MariaDB [(none)]> CREATE DATABASE nova_api; MariaDB [(none)]> CREATE DATABASE nova; MariaDB [(none)]> CREATE DATABASE nova_cell0;
授權數據庫
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY 'nova'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'nova'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'nova'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'nova'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY 'nova'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY 'nova';
組件部署
首先設置所需要的環境變量,這個在前邊組件的部署中有過說明:
[root@localhost ~]# source admin-openstack.sh
1、創建nova user
$ openstack user create --domain default --password-prompt nova User Password: Repeat User Password: +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | 8a7dbf5279404537b1c7b86c033620fe | | name | nova | | options | {} | | password_expires_at | None | +---------------------+----------------------------------+
2、爲nova用戶設置admin角色和項目
$ openstack role add --project service --user nova admin
3、註冊服務
$ openstack service create --name nova --description "OpenStack Compute" compute +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Compute | | enabled | True | | id | 060d59eac51b4594815603d75a00aba2 | | name | nova | | type | compute | +-------------+----------------------------------+
4、註冊endpoints
$ openstack endpoint create --region RegionOne compute public http://192.168.46.130:8774/v2.1 +--------------+-------------------------------------------+ | Field | Value | +--------------+-------------------------------------------+ | enabled | True | | id | 3c1caa473bfe4390a11e7177894bcc7b | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 060d59eac51b4594815603d75a00aba2 | | service_name | nova | | service_type | compute | | url | http://192.168.46.130:8774/v2.1 | +--------------+-------------------------------------------+ $ openstack endpoint create --region RegionOne compute internal http://192.168.46.130:8774/v2.1 +--------------+-------------------------------------------+ | Field | Value | +--------------+-------------------------------------------+ | enabled | True | | id | e3c918de680746a586eac1f2d9bc10ab | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 060d59eac51b4594815603d75a00aba2 | | service_name | nova | | service_type | compute | | url | http://192.168.46.130:8774/v2.1 | +--------------+-------------------------------------------+ $ openstack endpoint create --region RegionOne compute admin http://192.168.46.130:8774/v2.1 +--------------+-------------------------------------------+ | Field | Value | +--------------+-------------------------------------------+ | enabled | True | | id | 38f7af91666a47cfb97b4dc790b94424 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 060d59eac51b4594815603d75a00aba2 | | service_name | nova | | service_type | compute | | url | http://192.168.46.130:8774/v2.1 | +--------------+-------------------------------------------+
5、創建Placement service
$ openstack user create --domain default --password-prompt placement User Password: Repeat User Password: +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | fa742015a6494a949f67629884fc7ec8 | | name | placement | | options | {} | | password_expires_at | None | +---------------------+----------------------------------+
6、爲Placement service添加項目和角色
$ openstack role add --project service --user placement admin
7、註冊Placement服務
$ openstack service create --name placement --description "Placement API" placement +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | Placement API | | enabled | True | | id | 2d1a27022e6e4185b86adac4444c495f | | name | placement | | type | placement | +-------------+----------------------------------+
8、爲Placement服務註冊endpoints
$ openstack endpoint create --region RegionOne placement public http://192.168.46.130:8778 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 2b1b2637908b4137a9c2e0470487cbc0 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 2d1a27022e6e4185b86adac4444c495f | | service_name | placement | | service_type | placement | | url | http://192.168.46.130:8778 | +--------------+----------------------------------+ $ openstack endpoint create --region RegionOne placement internal http://192.168.46.130:8778 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 02bcda9a150a4bd7993ff4879df971ab | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 2d1a27022e6e4185b86adac4444c495f | | service_name | placement | | service_type | placement | | url | http://192.168.46.130:8778 | +--------------+----------------------------------+ $ openstack endpoint create --region RegionOne placement admin http://192.168.46.130:8778 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 3d71177b9e0f406f98cbff198d74b182 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 2d1a27022e6e4185b86adac4444c495f | | service_name | placement | | service_type | placement | | url | http://192.168.46.130:8778 | +--------------+----------------------------------+
配置組件
- 安裝組件包
# yum install openstack-nova-api openstack-nova-conductor \ openstack-nova-console openstack-nova-novncproxy \ openstack-nova-scheduler openstack-nova-placement-api
- 修改/etc/nova/nova.conf配置文件
1、設置對外的API
[DEFAULT] # ... enabled_apis = osapi_compute,metadata
2、配置數據庫
[api_database] # ... connection = mysql+pymysql://nova:[email protected]/nova_api [database] # ... connection = mysql+pymysql://nova:[email protected]/nova
3、配置RabbitMQ
[DEFAULT] # ... transport_url = rabbit://openstack:[email protected]
4、打開keystone認證和配置認證token
[api] # ... auth_strategy = keystone [keystone_authtoken] auth_uri = http://192.168.46.130:5000 auth_url = http://192.168.46.130:35357 memcached_servers = 192.168.46.130:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = nova password = nova
5、關閉防火牆配置
[DEFAULT] # ... use_neutron = True firewall_driver = nova.virt.firewall.NoopFirewallDriver
6、vnc配置
[vnc] enabled = true # ... vncserver_listen = 192.168.46.130 vncserver_proxyclient_address = 192.168.46.130
7、配置本地鏡像服務API
[glance] # ... api_servers= http://192.168.46.130:9292
8、鎖文件路徑
[oslo_concurrency] # ... lock_path = /var/lib/nova/tmp
9、配置Placement API
[placement] os_region_name = RegionOne project_domain_name = Default project_name = service auth_type = password user_domain_name = Default auth_url = http://192.168.46.130:35357/v3 username = placement password = placement
10、修改當前版本bug,編輯/etc/httpd/conf.d/00-nova-placement-api.conf文件,增加以下代碼
<Directory /usr/bin> <IfVersion >= 2.4> Require all granted </IfVersion> <IfVersion < 2.4> Order allow,deny Allow from all </IfVersion> </Directory>
11、啓動httpd服務
# systemctl restart httpd
最後的配置
1、同步cell0數據庫
# su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
2、創建cell1
# su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova 109e1d4b-536a-40d0-83c6-5f121b82b650
3、同步nova數據庫
# su -s /bin/sh -c "nova-manage db sync" nova
4、驗證cell0和cell1
# nova-manage cell_v2 list_cells +-------+--------------------------------------+ | Name | UUID | +-------+--------------------------------------+ | cell1 | 109e1d4b-536a-40d0-83c6-5f121b82b650 | | cell0 | 00000000-0000-0000-0000-000000000000 | +-------+--------------------------------------+
配置服務自動啓動
# systemctl enable openstack-nova-api.service \ openstack-nova-consoleauth.service openstack-nova-scheduler.service \ openstack-nova-conductor.service openstack-nova-novncproxy.service # systemctl start openstack-nova-api.service \ openstack-nova-consoleauth.service openstack-nova-scheduler.service \ openstack-nova-conductor.service openstack-nova-novncproxy.service
部署compute node
1、安裝包
# yum install openstack-nova-compute
2、編輯/etc/nova/nova.conf配置文件
- 打開API
[DEFAULT] # ... enabled_apis = osapi_compute,metadata
- 配置RabbitMQ
[DEFAULT] # ... transport_url= rabbit://openstack:[email protected]
- 配置keystone認證
[api] # ... auth_strategy = keystone [keystone_authtoken] auth_uri = http://192.168.46.130:5000 auth_url = http://192.168.46.130:35357 memcached_servers = 192.168.46.130:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = nova password = nova
- 關閉防火牆驅動
[DEFAULT] # ... use_neutron = True firewall_driver = nova.virt.firewall.NoopFirewallDriver
- vnc配置
[vnc] # ... enabled = True vncserver_listen= 192.168.46.133 vncserver_proxyclient_address= 192.168.46.133 novncproxy_base_url=http://192.168.46.130:6080/vnc_auto.html
- 配置Glance服務API
[glance] # ... api_servers= http://192.168.46.130:9292
- 鎖文件路徑
[oslo_concurrency] # ... lock_path = /var/lib/nova/tmp
- 配置Placement API
[placement] os_region_name = RegionOne project_domain_name = Default project_name = service auth_type = password user_domain_name = Default auth_url = http://192.168.46.130:35357/v3 username = placement password = placement
- 配置libvirt,在生產環境中一般使用kvm
[libvirt] # ... virt_type = qemu
- 啓動服務
# systemctl enable libvirtd.service openstack-nova-compute.service //設置自動啓動 # systemctl start libvirtd.service openstack-nova-compute.service //啓動服務
問題記錄
在以上執行啓動服務時,命令行長時間卡住,一般說明連接RabbitMQ失敗,可以在/var/log/nova/nova-compute.log文件中查看詳細報錯,報錯如下:
2019-05-11 12:02:57.432 5308 ERROR oslo.messaging._drivers.impl_rabbit [req-503bd955-7075-44a8-b553-f70b9437ff3b - - - - -] [84517112-2f15-4dfa-b9f0-e195a80a67c2] AMQP server on 192.168.46.130:5672 is unreachable: [Errno 113] EHOSTUNREACH. Trying again in 32 seconds.: error: [Errno 113] EHOSTUNREACH 2019-05-11 12:03:29.606 5308 ERROR oslo.messaging._drivers.impl_rabbit [req-503bd955-7075-44a8-b553-f70b9437ff3b - - - - -] [84517112-2f15-4dfa-b9f0-e195a80a67c2] AMQP server on 192.168.46.130:5672 is unreachable: [Errno 113] EHOSTUNREACH. Trying again in 32 seconds.: error: [Errno 113] EHOSTUNREACH 2019-05-11 12:04:01.792 5308 ERROR oslo.messaging._drivers.impl_rabbit [req-503bd955-7075-44a8-b553-f70b9437ff3b - - - - -] [84517112-2f15-4dfa-b9f0-e195a80a67c2] AMQP server on 192.168.46.130:5672 is unreachable: [Errno 113] EHOSTUNREACH. Trying again in 32 seconds.: error: [Errno 113] EHOSTUNREACH
以上錯誤說明nova-compute節點連接controller節點的RabbitMQ失敗了,一般原因是controller上配置了iptables,需要設置iptables把RabbitMQ的5672端口打開。設置如下:
# iptables -I INPUT -p tcp --dport 5672 -j ACCEPT #添加規則 # service iptables save #保存設置 # service iptables restart # 重啓iptables,生效規則
添加compute node到cell數據庫
- 在controller node上查看,確定在數據庫中有nova-compute
[root@localhost ~]# source admin-openstack.sh [root@localhost ~]# openstack compute service list +----+------------------+-----------------------+----------+---------+-------+----------------------------+ | ID | Binary | Host | Zone | Status | State | Updated At | +----+------------------+-----------------------+----------+---------+-------+----------------------------+ | 1 | nova-consoleauth | localhost.localdomain | internal | enabled | up | 2019-05-12T10:36:09.000000 | | 2 | nova-conductor | localhost.localdomain | internal | enabled | up | 2019-05-12T10:36:09.000000 | | 3 | nova-scheduler | localhost.localdomain | internal | enabled | up | 2019-05-12T10:36:10.000000 | | 8 | nova-compute | node2 | nova | enabled | up | 2019-05-12T10:36:07.000000 | +----+------------------+-----------------------+----------+---------+-------+----------------------------+
- 發現compute node,每次添加新的compute nodes時,都需要在controller node上執行nova-manage cell_v2 discover_hosts註冊新的compute nodes
# su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova Found 2 cell mappings. Skipping cell0 since it does not contain hosts. Getting compute nodes from cell 'cell1': ad5a5985-a719-4567-98d8-8d148aaae4bc Found 1 computes in cell: ad5a5985-a719-4567-98d8-8d148aaae4bc Checking host mapping for compute host 'compute': fe58ddc1-1d65-4f87-9456-bc040dc106b3 Creating host mapping for compute host 'compute': fe58ddc1-1d65-4f87-9456-bc040dc106b3
通過以上的組件部署,nova-compute可以有多個,並且當配置完一個nova-compute時,其他的與此類似。