這個部分將描述如何在控制節點上安裝和配置 Compute 服務,即 nova。
一、前提條件
在你安裝和配置計算服務前,你必須創建數據庫,服務憑證和API端點。
1.完成下面的步驟以創建數據庫:
[root@Controller-Node ~]# mysql -uroot -p123456 MariaDB [(none)]> CREATE DATABASE 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)]> CREATE DATABASE nova_api; 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)]> CREATE DATABASE nova_cell0; 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'; MariaDB [(none)]> exit
2.獲得 admin 憑證來獲取只有管理員能執行命令的訪問權限
[root@Controller-Node ~]# source admin-openrc.sh
3.要創建服務證書,完成這些步驟:
1.> 創建 nova 用戶,設置密碼為nova:
$openstack user create --domain default --password-prompt nova 執行如下: [root@Controller-Node ~]# openstack user create --domain default --password-prompt nova User Password: Repeat User Password: +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | c7fe14104af14064a862d45a8331837b | | name | nova | | options | {} | | password_expires_at | None | +---------------------+----------------------------------+ [root@Controller-Node ~]#
2.>添加admin 角色到 nova 用戶:
[root@Controller-Node ~]# openstack role add --project service --user nova admin
3.>創建 nova 服務實體:
openstack service create --name nova \ --description "OpenStack Compute" compute 執行如下: [root@Controller-Node ~]# openstack service create --name nova \ > --description "OpenStack Compute" compute +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Compute | | enabled | True | | id | deec4fb34eb64f8f968d304a0bb85bd4 | | name | nova | | type | compute | +-------------+----------------------------------+ [root@Controller-Node ~]#
4.>創建計算服務API端點:
$ openstack endpoint create --region RegionOne \ compute public http://10.20.9.13:8774/v2/%\(tenant_id\)s $ openstack endpoint create --region RegionOne \ compute internal http://10.20.9.13:8774/v2/%\(tenant_id\)s $ openstack endpoint create --region RegionOne \ compute admin http://10.20.9.13:8774/v2/%\(tenant_id\)s 執行如下: [root@Controller-Node ~]# openstack endpoint create --region RegionOne \ > compute public http://10.20.9.13:8774/v2/%\(tenant_id\)s +--------------+-----------------------------------------+ | Field | Value | +--------------+-----------------------------------------+ | enabled | True | | id | 1ba627fcb3d145569fbb83c32c9c1e16 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | deec4fb34eb64f8f968d304a0bb85bd4 | | service_name | nova | | service_type | compute | | url | http://10.20.9.13:8774/v2/%(tenant_id)s | +--------------+-----------------------------------------+ [root@Controller-Node ~]# openstack endpoint create --region RegionOne \ > compute internal http://10.20.9.13:8774/v2/%\(tenant_id\)s +--------------+-----------------------------------------+ | Field | Value | +--------------+-----------------------------------------+ | enabled | True | | id | efd5e04872954088b09f9474da5c46d5 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | deec4fb34eb64f8f968d304a0bb85bd4 | | service_name | nova | | service_type | compute | | url | http://10.20.9.13:8774/v2/%(tenant_id)s | +--------------+-----------------------------------------+ [root@Controller-Node ~]# openstack endpoint create --region RegionOne \ > compute admin http://10.20.9.13:8774/v2/%\(tenant_id\)s +--------------+-----------------------------------------+ | Field | Value | +--------------+-----------------------------------------+ | enabled | True | | id | 0f21127572b94416bc6374edf6131c4b | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | deec4fb34eb64f8f968d304a0bb85bd4 | | service_name | nova | | service_type | compute | | url | http://10.20.9.13:8774/v2/%(tenant_id)s | +--------------+-----------------------------------------+ [root@Controller-Node ~]#
5.新建另一個用戶,密碼設為nova
[root@Controller-Node ~]# openstack user create --domain default --password-prompt placement User Password: Repeat User Password: +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | ab033f42e4064f898886447d07891d22 | | name | placement | | options | {} | | password_expires_at | None | +---------------------+----------------------------------+
加入管理員組
[root@Controller-Node ~]# openstack role add --project service --user placement admin
6.在服務目錄中創建Placement API條目
[root@Controller-Node ~]# openstack service create --name placement --description "Placement API" placement +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | Placement API | | enabled | True | | id | cccfe79b58c346928b1c56c38fb3d4b3 | | name | placement | | type | placement | +-------------+----------------------------------+ [root@Controller-Node ~]#
7.創建Placement API服務端點:
[root@Controller-Node ~]# openstack endpoint create --region RegionOne placement public http://10.20.9.13:8778 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | d80c7e76ff8f4a69a36c0f9cd891f734 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | cccfe79b58c346928b1c56c38fb3d4b3 | | service_name | placement | | service_type | placement | | url | http://10.20.9.13:8778 | +--------------+----------------------------------+ [root@Controller-Node ~]# openstack endpoint create --region RegionOne placement internal http://10.20.9.13:8778 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | baafdcbb3cb2460e89b3dd62fbeeb9fc | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | cccfe79b58c346928b1c56c38fb3d4b3 | | service_name | placement | | service_type | placement | | url | http://10.20.9.13:8778 | +--------------+----------------------------------+ [root@Controller-Node ~]# openstack endpoint create --region RegionOne placement admin http://10.20.9.13:8778 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 3c621088b21247679ce071bab4296dd1 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | cccfe79b58c346928b1c56c38fb3d4b3 | | service_name | placement | | service_type | placement | | url | http://10.20.9.13:8778 | +--------------+----------------------------------+ [root@Controller-Node ~]#
查看catalog列表
[root@Controller-Node ~]# openstack catalog list +-----------+-----------+------------------------------------------------------------------------+ | Name | Type | Endpoints | +-----------+-----------+------------------------------------------------------------------------+ | nova | compute | RegionOne | | | | internal: http://10.20.9.13:8774/v2/6effb77cf0ba48a7a65a2c2235bbb726 | | | | RegionOne | | | | public: http://10.20.9.13:8774/v2/6effb77cf0ba48a7a65a2c2235bbb726 | | | | RegionOne | | | | admin: http://10.20.9.13:8774/v2/6effb77cf0ba48a7a65a2c2235bbb726 | | | | | | keystone | identity | RegionOne | | | | public: http://10.20.9.13:5000/v3/ | | | | RegionOne | | | | admin: http://10.20.9.13:35357/v3/ | | | | RegionOne | | | | internal: http://10.20.9.13:5000/v3/ | | | | | | placement | placement | RegionOne | | | | public: http://10.20.9.13:8778 | | | | RegionOne | | | | internal: http://10.20.9.13:8778 | | | | RegionOne | | | | admin: http://10.20.9.13:8778 | | | | | | glance | image | RegionOne | | | | admin: http://10.20.9.13:9292 | | | | RegionOne | | | | public: http://10.20.9.13:9292 | | | | RegionOne | | | | internal: http://10.20.9.13:9292 | | | | | +-----------+-----------+------------------------------------------------------------------------+ [root@Controller-Node ~]#
二、安裝並配置組件
1.安裝軟件包:
$ yum install openstack-nova-api openstack-nova-cert \ openstack-nova-conductor openstack-nova-console \ openstack-nova-novncproxy openstack-nova-scheduler \ python-novaclient openstack-nova-placement-api
2.編輯/etc/nova/nova.conf文件並完成下面的操作:
1.> 在 [DEFAULT] 選項中,開啟計算和元數據API
[DEFAULT]
# ...
enabled_apis=osapi_compute,metadata
2.> 在 [DEFAULT] 選項中,配置消息隊列連接。
[DEFAULT] # ... transport_url=rabbit://openstack:openstack@10.20.9.13
3.> 在[DEFAULT]選項中,配置my_ip
[DEFAULT] # ... my_ip=10.20.9.13
4.> 在 [DEFAULT] 選項中開啟對網絡服務的支持
[DEFAULT] # ... use_neutron=True firewall_driver=nova.virt.firewall.NoopFirewallDriver
5.> 在 [api_database] 和 [database] 選項中,配置數據庫連接
[api_database] # ... connection = mysql://nova:nova@10.20.9.13/nova_api [database] # ... connection = mysql://nova:nova@10.20.9.13/nova
6.> 在 [api] 和 [keystone_authtoken] 選項中配置如下
[api] # ... auth_strategy=keystone [keystone_authtoken] # ... auth_uri=http://10.20.9.13:5000 auth_url=http://10.20.9.13:35357 memcached_servers=10.20.9.13:11211 auth_type=password project_domain_name=default user_domain_name=default project_name=service username=nova password=nova
7.> 在 [vnc] 選項中,配置VNC代理
[vnc] # ... enabled=true vncserver_listen=$my_ip vncserver_proxyclient_address=$my_ip
8.> 在 [glance] 選項中,配置鏡像服務API的位置。
[glance] # ... api_servers=http://10.20.9.13:9292
9.> 在 [oslo_concurrency] 選項中,配置鎖定路徑
[oslo_concurrency] # ... lock_path=/var/lib/nova/tmp
10.> 在 [placement] 選項中配置
[placement] # ... os_region_name=RegionOne project_domain_name=Default project_name=service auth_type=password user_domain_name=Default auth_url=http://10.20.9.13:35357/v3 username=placement password=nova
3.設置apache,在文件中追加如下內容,並重新啟動服務
vim /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>
[root@Controller-Node ~]# systemctl restart httpd
4.填充nova-api數據庫:
[root@Controller-Node ~]# su -s /bin/sh -c "nova-manage api_db sync" nova
5.注冊cell0數據庫:
[root@Controller-Node ~]# su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
6.創建cell1單元格:
[root@Controller-Node ~]# su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova c57ab09d-7da7-4abb-af21-448b62548b43 [root@Controller-Node ~]#
7.填充nova數據庫:
[root@Controller-Node ~]# su -s /bin/sh -c "nova-manage db sync" nova
8.驗證nova cell0和cell1是否正確注冊:
[root@Controller-Node ~]# nova-manage cell_v2 list_cells +-------+--------------------------------------+ | Name | UUID | +-------+--------------------------------------+ | cell0 | 00000000-0000-0000-0000-000000000000 | | cell1 | c57ab09d-7da7-4abb-af21-448b62548b43 | +-------+--------------------------------------+
9.完成安裝,開啟計算服務並設置開機啟動;
$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 $systemctl status openstack-nova-api.service \ openstack-nova-consoleauth.service \ openstack-nova-scheduler.service \ openstack-nova-conductor.service \ openstack-nova-novncproxy.service
10.獲取admin權限,並驗證每個服務組件都是否成功運行
[root@Controller-Node ~]# source admin-openrc.sh [root@Controller-Node ~]# [root@Controller-Node ~]# openstack host list +-----------------+-------------+----------+ | Host Name | Service | Zone | +-----------------+-------------+----------+ | Controller-Node | consoleauth | internal | | Controller-Node | conductor | internal | | Controller-Node | scheduler | internal | +-----------------+-------------+----------+ [root@Controller-Node ~]# nova service-list +----+------------------+-----------------+----------+---------+-------+----------------------------+-----------------+ | Id | Binary | Host | Zone | Status | State | Updated_at | Disabled Reason | +----+------------------+-----------------+----------+---------+-------+----------------------------+-----------------+ | 1 | nova-consoleauth | Controller-Node | internal | enabled | up | 2018-10-10T09:06:01.000000 | - | | 2 | nova-conductor | Controller-Node | internal | enabled | up | 2018-10-10T09:06:02.000000 | - | | 3 | nova-scheduler | Controller-Node | internal | enabled | up | 2018-10-10T09:06:01.000000 | - | +----+------------------+-----------------+----------+---------+-------+----------------------------+-----------------+ [root@Controller-Node ~]# openstack endpoint list +----------------------------------+-----------+--------------+--------------+---------+-----------+-----------------------------------------+ | ID | Region | Service Name | Service Type | Enabled | Interface | URL | +----------------------------------+-----------+--------------+--------------+---------+-----------+-----------------------------------------+ | 168ce73846e84b51aceb1d9fc043786a | RegionOne | nova | compute | True | internal | http://10.20.9.13:8774/v2/%(tenant_id)s | | 19df26f63e994c8ba0c81fa263dc60cd | RegionOne | keystone | identity | True | public | http://10.20.9.13:5000/v3/ | | 3ca232fd709f4e95b5a74ea074c5d341 | RegionOne | glance | image | True | admin | http://10.20.9.13:9292 | | 47a41ccb37d94396bf1878b0b4bf4910 | RegionOne | glance | image | True | public | http://10.20.9.13:9292 | | 5c1683647fe64bd19ddeeca2f44b4d29 | RegionOne | keystone | identity | True | admin | http://10.20.9.13:35357/v3/ | | 67a2fddef3b64789a51d4f74183f3715 | RegionOne | nova | compute | True | public | http://10.20.9.13:8774/v2/%(tenant_id)s | | 7d6ca6665b1b46e195aef4b0e264daf6 | RegionOne | keystone | identity | True | internal | http://10.20.9.13:5000/v3/ | | c675270a56b545af97408788c63b89fd | RegionOne | glance | image | True | internal | http://10.20.9.13:9292 | | d04b4f1de2ff4e79ad97b0a18bee46da | RegionOne | nova | compute | True | admin | http://10.20.9.13:8774/v2/%(tenant_id)s | +----------------------------------+-----------+--------------+--------------+---------+-----------+-----------------------------------------+ [root@Controller-Node ~]#
三、在計算節點安裝配置nova服務(10.20.9.14主機)
1.安裝nova-compute軟件包
[root@Compute-Node ~]# yum install openstack-nova-compute
2. 編輯/etc/nova/nova.conf文件.
1.> 在[DEFAULT]選項中,開啟計算和元數據API
[DEFAULT]
#...
enabled_apis=osapi_compute,metadata
2.> 在[DEFAULT]選項中,配置消息隊列權限
[DEFAULT] #... transport_url=rabbit://openstack:openstack@10.20.9.13
3.> 在[DEFAULT]選項中,配置my_ip參數,這個是本機IP地址
[DEFAULT] #... my_ip=10.20.9.14
4.> 在 [DEFAULT] 選項中,開啟網絡服務支持
[DEFAULT] #... use_neutron=True firewall_driver=nova.virt.firewall.NoopFirewallDriver
5.> 在 [api] 和 [keystone_authtoken] 選項中,配置認證服務權限
[api] #... auth_strategy=keystone [keystone_authtoken] #... auth_uri=http://10.20.9.13:5000 auth_url=http://10.20.9.13:35357 memcached_servers=10.20.9.13:11211 auth_type=password project_domain_name=default user_domain_name=default project_name=service username=nova password=nova
6.> 在 [vnc] 選項中,開啟並配置遠程控制台權限
[vnc] #... enabled=True vncserver_listen=0.0.0.0 vncserver_proxyclient_address=$my_ip novncproxy_base_url=http://10.20.9.13:6080/vnc_auto.html
7.> 在 [glance] 選項中,配置鏡像服務API地址
[glance] #... api_servers=http://10.20.9.13:9292
8.> 在 [oslo_concurrency] 選項,配置鎖定路徑
[oslo_concurrency] #... lock_path=/var/lib/nova/tmp
9.> 在 [placement] 段添加如下參數.
[placement] #... os_region_name=RegionOne project_domain_name=Default project_name=service auth_type=password user_domain_name=Default auth_url=http://10.20.9.13:35357/v3 username=placement password=nova
3. 檢查是否需要硬件加速
[root@Compute-Node ~]# egrep -c '(vmx|svm)' /proc/cpuinfo 0 [root@Compute-Node ~]#
如果為0則需要修改 #vi /etc/nova/nova.conf文件,[libvirt]段添加如下內容.
[libvirt]
# ...
virt_type=qemu
4.啟動服務,並查看服務狀態
# systemctl enable libvirtd.service openstack-nova-compute.service # systemctl start libvirtd.service openstack-nova-compute.service # systemctl status libvirtd.service openstack-nova-compute.service
三、驗證操作,在主控節點(10.20.9.13)上面操作.
1.獲取admin權限
[root@Controller-Node ~]# source admin-openrc.sh
2.將計算節點添加到單元數據庫,在控制節點上進行操作.
[root@Controller-Node ~]# 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': c57ab09d-7da7-4abb-af21-448b62548b43 Found 1 computes in cell: c57ab09d-7da7-4abb-af21-448b62548b43 Checking host mapping for compute host 'Compute-Node': 911f9117-ec3f-43fd-930e-b8571f04400f Creating host mapping for compute host 'Compute-Node': 911f9117-ec3f-43fd-930e-b8571f04400f [root@Controller-Node ~]#
3.查看 compute 節點
[root@Controller-Node ~]# openstack compute service list +----+------------------+-----------------+----------+---------+-------+----------------------------+ | ID | Binary | Host | Zone | Status | State | Updated At | +----+------------------+-----------------+----------+---------+-------+----------------------------+ | 1 | nova-consoleauth | Controller-Node | internal | enabled | up | 2018-10-11T02:59:37.000000 | | 2 | nova-conductor | Controller-Node | internal | enabled | up | 2018-10-11T02:59:35.000000 | | 3 | nova-scheduler | Controller-Node | internal | enabled | up | 2018-10-11T02:59:31.000000 | | 6 | nova-compute | Compute-Node | nova | enabled | up | 2018-10-11T02:59:38.000000 | +----+------------------+-----------------+----------+---------+-------+----------------------------+ [root@Controller-Node ~]#
4.查看catalog
[root@Controller-Node ~]# openstack catalog list +-----------+-----------+------------------------------------------------------------------------+ | Name | Type | Endpoints | +-----------+-----------+------------------------------------------------------------------------+ | | | | | nova | compute | RegionOne | | | | internal: http://10.20.9.13:8774/v2/6effb77cf0ba48a7a65a2c2235bbb726 | | | | RegionOne | | | | public: http://10.20.9.13:8774/v2/6effb77cf0ba48a7a65a2c2235bbb726 | | | | RegionOne | | | | admin: http://10.20.9.13:8774/v2/6effb77cf0ba48a7a65a2c2235bbb726 | | | | | | keystone | identity | RegionOne | | | | public: http://10.20.9.13:5000/v3/ | | | | RegionOne | | | | admin: http://10.20.9.13:35357/v3/ | | | | RegionOne | | | | internal: http://10.20.9.13:5000/v3/ | | | | | | placement | placement | RegionOne | | | | admin: http://10.20.9.13:8778 | | | | RegionOne | | | | internal: http://10.20.9.13:8778 | | | | RegionOne | | | | public: http://10.20.9.13:8778 | | | | | | glance | image | RegionOne | | | | admin: http://10.20.9.13:9292 | | | | RegionOne | | | | public: http://10.20.9.13:9292 | | | | RegionOne | | | | internal: http://10.20.9.13:9292 | | | | | +-----------+-----------+------------------------------------------------------------------------+ [root@Controller-Node ~]#
5.列出Image服務中的圖像以驗證與Image服務的連接性:
[root@Controller-Node ~]# openstack image list +--------------------------------------+--------+--------+ | ID | Name | Status | +--------------------------------------+--------+--------+ | f7041b87-bd78-475c-a877-919543886dc0 | cirros | active | +--------------------------------------+--------+--------+ [root@Controller-Node ~]#
6.檢查單元格和放置API正在成功工作:
[root@Controller-Node ~]# nova-status upgrade check +---------------------------+ | Upgrade Check Results | +---------------------------+ | Check: Cells v2 | | Result: Success | | Details: None | +---------------------------+ | Check: Placement API | | Result: Success | | Details: None | +---------------------------+ | Check: Resource Providers | | Result: Success | | Details: None | +---------------------------+ [root@Controller-Node ~]#
至此,主控和計算節點的nova服務都已經部署完成,兩者的互通都沒問題..
參考文檔:https://www.cnblogs.com/liang2580/articles/8157963.html
