雲端計算管理平臺之OpenStack計算服務nova

1874發表於2020-10-30

  一、nova簡介

  nova是openstack中的計算服務,其主要作用是幫助我們在計算節點上管理虛擬機器的核心服務;這裡的計算節點就是指用於提供執行虛擬機器例項的主機,通常像這種計算節點有很多臺,那麼虛擬機器到底在哪個server上啟動?如何啟動?這就是nova需要做的;對於openstack使用者來講,底層到底在哪臺server上啟動虛擬機器以及怎麼啟動的,我們可以不關心;因為nova服務幫我們搞定;

  nova架構圖

  nova服務有很多元件,其中核心元件有nova-api、nova-scheduler、nova-conductor、nova-console、nova-novncproxy、nova-placement和nova-compute ;其中nava-api主要用來接收客戶端請求,並將請求資訊放到對應的訊息佇列中,同時將使用者的請求寫入到nova資料庫中,相當於服務的入口;nova-scheduler主要用於排程使用者的請求,比如建立虛擬機器需要排程到哪臺物理server上建立都是由nova-scheduler來決策;它會將其排程結果放到對應的訊息佇列中同時它也會把排程資訊寫入nova資料庫中;nova-conductor主要用來幫助其他元件修改虛擬機器後的資訊,將其寫入到nova 資料庫中的;所有佇列中有關寫資料庫的請求都會先丟給nova-conductor所訂閱的訊息佇列中,然後nova-conductor會按照一定的速度向資料庫中寫;這樣做主要是減少資料庫的壓力,避免資料庫壓力過大而出現異常;nova-console主要用來給虛擬機器提供控制檯服務,並將其控制檯地址寫入到nova資料庫中;nova-novncproxy主要作用是代理使用者通過novnc訪問虛擬機器控制檯;nova-placement主要作用是跟蹤每個資料節點的資源使用情況;nova-computer主要用來呼叫資料節點的hypervisor,來管理虛擬機器;這些元件都是基於一個訊息佇列服務來相互呼叫的;從而實現各元件解耦;所以nova服務是嚴重依賴訊息佇列服務的;

  nova核心工作流程

  當nova-api接收到使用者的請求,比如建立一個虛擬機器例項,nova-api會把這個請求放到訊息佇列中,並把使用者的請求資訊寫入到nova資料庫中,然後繼續接收其他使用者的請求;nova-api把使用者請求放到未排程的訊息佇列中,nova-scheduler會從未排程的訊息佇列中取出使用者的請求進行排程,把排程結果又返回給對應計算節點所訂閱的訊息佇列中,同時它也會把排程結果寫到nova資料庫中,然後由對應的資料節點nova-computer取出排程後的訊息進行處理;nova-computer的處理就是呼叫本地的hypervisor來建立虛擬機器,最後把建立成功的訊息,丟給訊息佇列,然後由nova-api到訊息佇列中取得虛擬機器例項建立成功的訊息,nova-api再把訊息返回給使用者;對於其他元件的工作原理也是類似,他們都是把處理的結果放到對應的訊息佇列中,然後由其他元件去訊息佇列中取結果,從而完成各元件間的互相呼叫;

  二、nova服務的安裝、配置、測試

  1、建立資料庫、使用者、授權使用者

[root@node02 ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 10.1.20-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE nova_api;
Query OK, 1 row affected (0.01 sec)

MariaDB [(none)]> CREATE DATABASE nova;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> CREATE DATABASE nova_cell0;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> CREATE DATABASE placement;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%'  IDENTIFIED BY 'nova123';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%'  IDENTIFIED BY 'nova123';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%'  IDENTIFIED BY 'nova123';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%'  IDENTIFIED BY 'nova123';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| glance             |
| information_schema |
| keystone           |
| mysql              |
| nova               |
| nova_api           |
| nova_cell0         |
| performance_schema |
| placement          |
| test               |
+--------------------+
10 rows in set (0.05 sec)

MariaDB [(none)]>

  提示:以上主要建立了四個資料庫,分別是nova_api,nova,nova_cell0,placement;然後建立了兩個使用者,一個是nova使用者,並授權它能夠從任意主機連線到資料庫,並對nova_api,nova,nova_cell0這三個庫下的有所有表有增刪查改的許可權;一個使用者是placement,並授權該使用者能夠從任意主機連線到placement資料庫對placment庫下的所有表增刪查改的許可權;

  驗證:用其他主機使用nova使用者連線mariadb,看看是否能夠正常連線?是否能夠看到nova_api,nova,nova_cell0這三個庫?

[root@node01 ~]# mysql -unova -pnova123 -hnode02
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.1.20-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| nova               |
| nova_api           |
| nova_cell0         |
| test               |
+--------------------+
5 rows in set (0.00 sec)

MariaDB [(none)]> exit
Bye
[root@node01 ~]# 

  提示:使用nova使用者和nova使用者的密碼連線資料能夠看到我們之前授權的三個庫,說明我們建立nova使用者並授權的操作沒有問題;

  驗證:用其他主機使用placement使用者連線mariadb,看看是否可正常連線?是否能夠看到placement這個庫?

[root@node01 ~]# mysql -uplacement -pnova123 -hnode02
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.1.20-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| placement          |
| test               |
+--------------------+
3 rows in set (0.00 sec)

MariaDB [(none)]> exit
Bye
[root@node01 ~]# 

  說明:能夠看到placement庫就說明placement賬號沒有問題;

  2、在控制節點上安裝、配置nova服務

  匯出admin使用者的環境變數,建立nova使用者,設定其密碼為nova

[root@node01 ~]# source admin.sh 
[root@node01 ~]# openstack user create --domain default --password-prompt nova
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | 47c0915c914c49bb8670703e4315a80f |
| enabled             | True                             |
| id                  | 8e0ed287f92749e098a913a3edb90c74 |
| name                | nova                             |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+
[root@node01 ~]# 

  將nova使用者授權為admin角色,並指明是一個service專案

[root@node01 ~]# openstack role add --project service --user nova admin
[root@node01 ~]# 

  建立nova服務,並將其型別設定為compute 

[root@node01 ~]# openstack service create --name nova \
>   --description "OpenStack Compute" compute
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Compute                |
| enabled     | True                             |
| id          | 8e002dd8e3ba4bd98a15b433dede19a3 |
| name        | nova                             |
| type        | compute                          |
+-------------+----------------------------------+
[root@node01 ~]# 

  建立compute API endport (服務端點,註冊服務)

  建立公共端點

[root@node01 ~]# openstack endpoint create --region RegionOne \
>   compute public http://controller:8774/v2.1
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 7524a1aa1c6f4c21ac4917c1865667f3 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 8e002dd8e3ba4bd98a15b433dede19a3 |
| service_name | nova                             |
| service_type | compute                          |
| url          | http://controller:8774/v2.1      |
+--------------+----------------------------------+
[root@node01 ~]# 

  建立私有端點

[root@node01 ~]# openstack endpoint create --region RegionOne \
>   compute internal http://controller:8774/v2.1
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 1473a41427174c24b8d84c62b25262f6 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 8e002dd8e3ba4bd98a15b433dede19a3 |
| service_name | nova                             |
| service_type | compute                          |
| url          | http://controller:8774/v2.1      |
+--------------+----------------------------------+
[root@node01 ~]# 

  建立管理端點

[root@node01 ~]# openstack endpoint create --region RegionOne \
>   compute admin http://controller:8774/v2.1
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 3427fe37f3564252bffe0ee2f6bc766c |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 8e002dd8e3ba4bd98a15b433dede19a3 |
| service_name | nova                             |
| service_type | compute                          |
| url          | http://controller:8774/v2.1      |
+--------------+----------------------------------+
[root@node01 ~]# 

  建立placement使用者,並設定密碼為placement

[root@node01 ~]# openstack user create --domain default --password-prompt placement
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | 47c0915c914c49bb8670703e4315a80f |
| enabled             | True                             |
| id                  | a75c42cd405b4ea4885141df228b4caf |
| name                | placement                        |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+
[root@node01 ~]# 

  將placement使用者授權為admin角色,並指明是一個service專案

[root@node01 ~]# openstack role add --project service --user placement admin
[root@node01 ~]# 

  建立placement服務,並將其型別設定為placement

[root@node01 ~]# openstack service create --name placement \
>   --description "Placement API" placement
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | Placement API                    |
| enabled     | True                             |
| id          | de21b8c49adb4a8d88c38a08d5db2d59 |
| name        | placement                        |
| type        | placement                        |
+-------------+----------------------------------+
[root@node01 ~]# 

  建立placement API endport (服務端點,註冊服務)

  公共端點

[root@node01 ~]# openstack endpoint create --region RegionOne \
>   placement public http://controller:8778
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 222b6f91a2674ea993524c94e41a5757 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | de21b8c49adb4a8d88c38a08d5db2d59 |
| service_name | placement                        |
| service_type | placement                        |
| url          | http://controller:8778           |
+--------------+----------------------------------+
[root@node01 ~]# 

  私有端點

[root@node01 ~]# openstack endpoint create --region RegionOne \
>   placement internal http://controller:8778
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 04fa958200a943f4905893c6063389ab |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | de21b8c49adb4a8d88c38a08d5db2d59 |
| service_name | placement                        |
| service_type | placement                        |
| url          | http://controller:8778           |
+--------------+----------------------------------+
[root@node01 ~]# 

  管理端點

[root@node01 ~]# openstack endpoint create --region RegionOne \
>   placement admin http://controller:8778
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 6ddf51b6d9d8467e92cbf22c40e1ba1c |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | de21b8c49adb4a8d88c38a08d5db2d59 |
| service_name | placement                        |
| service_type | placement                        |
| url          | http://controller:8778           |
+--------------+----------------------------------+
[root@node01 ~]# 

  驗證:在控制節點上檢視是端點列表,看看nova和placement服務端點是否都建立成功?

[root@node01 ~]# openstack endpoint list 
+----------------------------------+-----------+--------------+--------------+---------+-----------+-----------------------------+
| ID                               | Region    | Service Name | Service Type | Enabled | Interface | URL                         |
+----------------------------------+-----------+--------------+--------------+---------+-----------+-----------------------------+
| 04cd3747614b42a3ba086cef39a1acd9 | RegionOne | glance       | image        | True    | admin     | http://controller:9292      |
| 04fa958200a943f4905893c6063389ab | RegionOne | placement    | placement    | True    | internal  | http://controller:8778      |
| 09f5ec434ea24d4c8dc9efe2bbb62b01 | RegionOne | glance       | image        | True    | internal  | http://controller:9292      |
| 1473a41427174c24b8d84c62b25262f6 | RegionOne | nova         | compute      | True    | internal  | http://controller:8774/v2.1 |
| 222b6f91a2674ea993524c94e41a5757 | RegionOne | placement    | placement    | True    | public    | http://controller:8778      |
| 3427fe37f3564252bffe0ee2f6bc766c | RegionOne | nova         | compute      | True    | admin     | http://controller:8774/v2.1 |
| 358ccfc245264b60a9d1a0c113dfa628 | RegionOne | glance       | image        | True    | public    | http://controller:9292      |
| 3bd05493999b462eb4b4af8d5e5c1fa9 | RegionOne | keystone     | identity     | True    | admin     | http://controller:5000/v3   |
| 5293ad18db674ea1b01d8f401cb2cf14 | RegionOne | keystone     | identity     | True    | public    | http://controller:5000/v3   |
| 6593f8d808094b01a6311828f2ef72bd | RegionOne | keystone     | identity     | True    | internal  | http://controller:5000/v3   |
| 6ddf51b6d9d8467e92cbf22c40e1ba1c | RegionOne | placement    | placement    | True    | admin     | http://controller:8778      |
| 7524a1aa1c6f4c21ac4917c1865667f3 | RegionOne | nova         | compute      | True    | public    | http://controller:8774/v2.1 |
+----------------------------------+-----------+--------------+--------------+---------+-----------+-----------------------------+
[root@node01 ~]# 

  提示:如果在端點列表中有3個nova和3個placement的端點,分別對應public、internal和admin介面,說明我們配置nova和placement服務端端點註冊沒有問題;

  安裝nova服務元件包

[root@node01 ~]# yum install openstack-nova-api openstack-nova-conductor \
>   openstack-nova-console openstack-nova-novncproxy \
>   openstack-nova-scheduler openstack-nova-placement-api
Loaded plugins: fastestmirror
base                                                                                                   | 3.6 kB  00:00:00     
centos-ceph-luminous                                                                                   | 3.0 kB  00:00:00     
centos-openstack-rocky                                                                                 | 3.0 kB  00:00:00     
centos-qemu-ev                                                                                         | 3.0 kB  00:00:00     
epel                                                                                                   | 4.7 kB  00:00:00     
extras                                                                                                 | 2.9 kB  00:00:00     
updates                                                                                                | 2.9 kB  00:00:00     
(1/2): epel/x86_64/updateinfo                                                                          | 1.0 MB  00:00:00     
(2/2): epel/x86_64/primary_db                                                                          | 6.9 MB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * centos-qemu-ev: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package openstack-nova-api.noarch 1:18.3.0-1.el7 will be installed
--> Processing Dependency: openstack-nova-common = 1:18.3.0-1.el7 for package: 1:openstack-nova-api-18.3.0-1.el7.noarch
---> Package openstack-nova-conductor.noarch 1:18.3.0-1.el7 will be installed
---> Package openstack-nova-console.noarch 1:18.3.0-1.el7 will be installed
--> Processing Dependency: python-websockify >= 0.8.0 for package: 1:openstack-nova-console-18.3.0-1.el7.noarch
---> Package openstack-nova-novncproxy.noarch 1:18.3.0-1.el7 will be installed
……省略部分內容……
Installed:
  openstack-nova-api.noarch 1:18.3.0-1.el7                        openstack-nova-conductor.noarch 1:18.3.0-1.el7              
  openstack-nova-console.noarch 1:18.3.0-1.el7                    openstack-nova-novncproxy.noarch 1:18.3.0-1.el7             
  openstack-nova-placement-api.noarch 1:18.3.0-1.el7              openstack-nova-scheduler.noarch 1:18.3.0-1.el7              

Dependency Installed:
  novnc.noarch 0:0.5.1-2.el7                                      openstack-nova-common.noarch 1:18.3.0-1.el7                
  python-kazoo.noarch 0:2.2.1-1.el7                               python-nova.noarch 1:18.3.0-1.el7                          
  python-oslo-versionedobjects-lang.noarch 0:1.33.3-1.el7         python-paramiko.noarch 0:2.1.1-9.el7                       
  python-websockify.noarch 0:0.8.0-1.el7                          python2-microversion-parse.noarch 0:0.2.1-1.el7            
  python2-os-traits.noarch 0:0.9.0-1.el7                          python2-os-vif.noarch 0:1.11.2-1.el7                       
  python2-oslo-reports.noarch 0:1.28.0-1.el7                      python2-oslo-versionedobjects.noarch 0:1.33.3-1.el7        
  python2-psutil.x86_64 0:5.6.7-1.el7                             python2-pyroute2.noarch 0:0.5.2-4.el7                      
  python2-redis.noarch 0:2.10.6-1.el7                             python2-tooz.noarch 0:1.62.1-1.el7                         
  python2-voluptuous.noarch 0:0.11.5-1.el7.1                      python2-zake.noarch 0:0.2.2-2.el7                          

Complete!
[root@node01 ~]# 

  編輯配置/etc/nova/nova.conf檔案,在【DEFAULT】配置段配置僅啟用計算和後設資料api和rabbitmq地址資訊

  在【api_daabase】配置段配置連線nova_api資料庫相關資訊

  在【database】配置段配置連線nova資料庫的相關資訊

  在【placement_database】配置段配置連線placlement資料庫相關資訊

  在【api】配置段配置使用keystone驗證

  在【keystone_authtoken】配置段配置keystone相關資訊

  在【DEFAULT】配置段配置支援使用neutron以及相關驅動

  在【vnc】配置段配置啟用vnc,並設定vnc監聽地址和客戶端代理使用的ip地址,這裡都用controller的解析地址即可;

  在【glance】配置段配置連線glance的地址

  在【oslo_concurrency】配置段配置鎖檔案存放路徑

  在【placement】配置段配置plancement api服務相關資訊

  /etc/nova/nova.conf最終配置

[root@node01 ~]# grep -i ^"[a-z\[]" /etc/nova/nova.conf
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:openstack123@node02
use_neutron = true
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[api]
auth_strategy = keystone
[api_database]
connection = mysql+pymysql://nova:nova123@node02/nova_api
[barbican]
[cache]
[cells]
[cinder]
[compute]
[conductor]
[console]
[consoleauth]
[cors]
[database]
connection = mysql+pymysql://nova:nova123@node02/nova
[devices]
[ephemeral_storage_encryption]
[filter_scheduler]
[glance]
api_servers = http://controller:9292
[guestfs]
[healthcheck]
[hyperv]
[ironic]
[key_manager]
[keystone]
[keystone_authtoken]
auth_url = http://controller:5000/v3
memcached_servers = node02:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = nova
password = nova
[libvirt]
[matchmaker_redis]
[metrics]
[mks]
[neutron]
[notifications]
[osapi_v21]
[oslo_concurrency]
lock_path=/var/lib/nova/tmp
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_messaging_zmq]
[oslo_middleware]
[oslo_policy]
[pci]
[placement]
region_name = RegionOne
project_domain_name = Default
project_name = service
auth_type = password
user_domain_name = Default
auth_url = http://controller:5000/v3
username = placement
password = placement
[placement_database]
connection = mysql+pymysql://placement:nova123@node02/placement
[powervm]
[profiler]
[quota]
[rdp]
[remote_debug]
[scheduler]
[serial_console]
[service_user]
[spice]
[upgrade_levels]
[vault]
[vendordata_dynamic_auth]
[vmware]
[vnc]
enabled = true
server_listen = controller
server_proxyclient_address = controller
[workarounds]
[wsgi]
[xenserver]
[xvp]
[zvm]
[root@node01 ~]# 

  編輯/etc/httpd/conf.d/00-nova-placement-api.conf配置檔案,新增對placement api 的訪問控制,在配置檔案末尾新增

<Directory /usr/bin>
   <IfVersion >= 2.4>
      Require all granted
   </IfVersion>
   <IfVersion < 2.4>
      Order allow,deny
      Allow from all
   </IfVersion>
</Directory>

  重啟httpd

  提示:重啟httpd服務後,確保5000和8778埠能夠正常監聽;

  初始化資料庫

  初始化nova_api資料庫和placement資料庫

[root@node01 ~]# su -s /bin/sh -c "nova-manage api_db sync" nova
[root@node01 ~]# 

  驗證:檢視nova-api庫和placement庫是否有表生成?

MariaDB [(none)]> use nova_api
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [nova_api]> show tables;
+------------------------------+
| Tables_in_nova_api           |
+------------------------------+
| aggregate_hosts              |
| aggregate_metadata           |
| aggregates                   |
| allocations                  |
| build_requests               |
| cell_mappings                |
| consumers                    |
| flavor_extra_specs           |
| flavor_projects              |
| flavors                      |
| host_mappings                |
| instance_group_member        |
| instance_group_policy        |
| instance_groups              |
| instance_mappings            |
| inventories                  |
| key_pairs                    |
| migrate_version              |
| placement_aggregates         |
| project_user_quotas          |
| projects                     |
| quota_classes                |
| quota_usages                 |
| quotas                       |
| request_specs                |
| reservations                 |
| resource_classes             |
| resource_provider_aggregates |
| resource_provider_traits     |
| resource_providers           |
| traits                       |
| users                        |
+------------------------------+
32 rows in set (0.00 sec)

MariaDB [nova_api]> use placement
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [placement]> show tables;
+------------------------------+
| Tables_in_placement          |
+------------------------------+
| aggregate_hosts              |
| aggregate_metadata           |
| aggregates                   |
| allocations                  |
| build_requests               |
| cell_mappings                |
| consumers                    |
| flavor_extra_specs           |
| flavor_projects              |
| flavors                      |
| host_mappings                |
| instance_group_member        |
| instance_group_policy        |
| instance_groups              |
| instance_mappings            |
| inventories                  |
| key_pairs                    |
| migrate_version              |
| placement_aggregates         |
| project_user_quotas          |
| projects                     |
| quota_classes                |
| quota_usages                 |
| quotas                       |
| request_specs                |
| reservations                 |
| resource_classes             |
| resource_provider_aggregates |
| resource_provider_traits     |
| resource_providers           |
| traits                       |
| users                        |
+------------------------------+
32 rows in set (0.00 sec)

MariaDB [placement]> 

  註冊cell0

[root@node01 ~]# su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
[root@node01 ~]# 

  建立cell1

[root@node01 ~]# su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
2ad18452-0e55-4505-ba5e-76cbf071b0d6
[root@node01 ~]# 

  驗證cell0和cell1是否註冊正確

[root@node01 ~]# su -s /bin/sh -c "nova-manage cell_v2 list_cells" nova
+-------+--------------------------------------+--------------------------------+---------------------------------------------+----------+
|  Name |                 UUID                 |         Transport URL          |             Database Connection             | Disabled |
+-------+--------------------------------------+--------------------------------+---------------------------------------------+----------+
| cell0 | 00000000-0000-0000-0000-000000000000 |             none:/             | mysql+pymysql://nova:****@node02/nova_cell0 |  False   |
| cell1 | 2ad18452-0e55-4505-ba5e-76cbf071b0d6 | rabbit://openstack:****@node02 |    mysql+pymysql://nova:****@node02/nova    |  False   |
+-------+--------------------------------------+--------------------------------+---------------------------------------------+----------+
[root@node01 ~]#

  提示:能夠看到以上資訊就表示cell0和cell1註冊沒有問題;

  初始化nova資料庫

[root@node01 ~]# su -s /bin/sh -c "nova-manage db sync" nova
/usr/lib/python2.7/site-packages/pymysql/cursors.py:170: Warning: (1831, u'Duplicate index `block_device_mapping_instance_uuid_virtual_name_device_name_idx`. This is deprecated and will be disallowed in a future release.')
  result = self._query(query)
/usr/lib/python2.7/site-packages/pymysql/cursors.py:170: Warning: (1831, u'Duplicate index `uniq_instances0uuid`. This is deprecated and will be disallowed in a future release.')
  result = self._query(query)
[root@node01 ~]# 

  提示:這裡提示兩個警告資訊,說兩個指令在未來的版本中不允許這樣使用;我們可以忽略這些警告資訊;

  驗證:檢視nova資料庫中是否有表生成?

MariaDB [placement]> use nova
Database changed
MariaDB [nova]> show tables;
+--------------------------------------------+
| Tables_in_nova                             |
+--------------------------------------------+
| agent_builds                               |
| aggregate_hosts                            |
| aggregate_metadata                         |
| aggregates                                 |
| allocations                                |
| block_device_mapping                       |
| bw_usage_cache                             |
| cells                                      |
| certificates                               |
| compute_nodes                              |
| console_auth_tokens                        |
| console_pools                              |
| consoles                                   |
| dns_domains                                |
| fixed_ips                                  |
| floating_ips                               |
| instance_actions                           |
| instance_actions_events                    |
| instance_extra                             |
| instance_faults                            |
| instance_group_member                      |
| instance_group_policy                      |
| instance_groups                            |
| instance_id_mappings                       |
| instance_info_caches                       |
| instance_metadata                          |
| instance_system_metadata                   |
| instance_type_extra_specs                  |
| instance_type_projects                     |
| instance_types                             |
| instances                                  |
| inventories                                |
| key_pairs                                  |
| migrate_version                            |
| migrations                                 |
| networks                                   |
| pci_devices                                |
| project_user_quotas                        |
| provider_fw_rules                          |
| quota_classes                              |
| quota_usages                               |
| quotas                                     |
| reservations                               |
| resource_provider_aggregates               |
| resource_providers                         |
| s3_images                                  |
| security_group_default_rules               |
| security_group_instance_association        |
| security_group_rules                       |
| security_groups                            |
| services                                   |
| shadow_agent_builds                        |
| shadow_aggregate_hosts                     |
| shadow_aggregate_metadata                  |
| shadow_aggregates                          |
| shadow_block_device_mapping                |
| shadow_bw_usage_cache                      |
| shadow_cells                               |
| shadow_certificates                        |
| shadow_compute_nodes                       |
| shadow_console_pools                       |
| shadow_consoles                            |
| shadow_dns_domains                         |
| shadow_fixed_ips                           |
| shadow_floating_ips                        |
| shadow_instance_actions                    |
| shadow_instance_actions_events             |
| shadow_instance_extra                      |
| shadow_instance_faults                     |
| shadow_instance_group_member               |
| shadow_instance_group_policy               |
| shadow_instance_groups                     |
| shadow_instance_id_mappings                |
| shadow_instance_info_caches                |
| shadow_instance_metadata                   |
| shadow_instance_system_metadata            |
| shadow_instance_type_extra_specs           |
| shadow_instance_type_projects              |
| shadow_instance_types                      |
| shadow_instances                           |
| shadow_key_pairs                           |
| shadow_migrate_version                     |
| shadow_migrations                          |
| shadow_networks                            |
| shadow_pci_devices                         |
| shadow_project_user_quotas                 |
| shadow_provider_fw_rules                   |
| shadow_quota_classes                       |
| shadow_quota_usages                        |
| shadow_quotas                              |
| shadow_reservations                        |
| shadow_s3_images                           |
| shadow_security_group_default_rules        |
| shadow_security_group_instance_association |
| shadow_security_group_rules                |
| shadow_security_groups                     |
| shadow_services                            |
| shadow_snapshot_id_mappings                |
| shadow_snapshots                           |
| shadow_task_log                            |
| shadow_virtual_interfaces                  |
| shadow_volume_id_mappings                  |
| shadow_volume_usage_cache                  |
| snapshot_id_mappings                       |
| snapshots                                  |
| tags                                       |
| task_log                                   |
| virtual_interfaces                         |
| volume_id_mappings                         |
| volume_usage_cache                         |
+--------------------------------------------+
110 rows in set (0.00 sec)

MariaDB [nova]> 

  提示:可以看到nova資料庫中生成了很多張表,說明初始nova資料庫沒有問題;

  啟動nova相關服務,並將其設定為開機啟動

[root@node01 ~]# systemctl start openstack-nova-api.service \
>   openstack-nova-consoleauth openstack-nova-scheduler.service \
>   openstack-nova-conductor.service openstack-nova-novncproxy.service
[root@node01 ~]# systemctl enable openstack-nova-api.service \
>   openstack-nova-consoleauth openstack-nova-scheduler.service \
>   openstack-nova-conductor.service openstack-nova-novncproxy.service
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-api.service to /usr/lib/systemd/system/openstack-nova-api.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-consoleauth.service to /usr/lib/systemd/system/openstack-nova-consoleauth.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-scheduler.service to /usr/lib/systemd/system/openstack-nova-scheduler.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-conductor.service to /usr/lib/systemd/system/openstack-nova-conductor.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-novncproxy.service to /usr/lib/systemd/system/openstack-nova-novncproxy.service.
[root@node01 ~]#

  驗證對應服務的埠是否處於監聽狀態?

  提示:6080是nova-novncproxy服務所監聽的埠;8774和8775是nova-api所監聽的埠;8778是placement服務所監聽的埠;如果能夠看到這四個埠啟動起來了,說明在控制節點的nova服務配置就沒有什麼問題;

  到此nova服務在控制節點上就安裝配置完畢

  3、在計算節點上安裝配置nova服務

  安裝nova-compute包

[root@node03 ~]# yum install openstack-nova-compute -y

  編輯/etc/nova/nova.conf配置檔案,在【DEFAULT】配置段配置僅啟用計算和後設資料api和rabbitmq地址資訊

  在【api】配置段配置使用keystone服務進行驗證

  在【keystone_authtoken】配置段配置keystone服務相關資訊

  在【DEFAULT】配置段配置支援使用neutron以及相關驅動

  在【vnc】配置段配置啟用vpn,以及vncserver的地址和novncproxy的介面地址

  提示:server_proxyclient_address這個可以寫ip地址或者主機名,如果是主機名請將其解析到對應計算節點的ip上;

  在【glance】配置段配置連線glance服務端相關資訊

  在【oslo_concurrency】配置段配置鎖檔案存放路徑

  在【placement】配置段配置placement服務相關資訊

  驗證計算節點是否支援硬體虛擬化

[root@node03 ~]# egrep -c '(vmx|svm)' /proc/cpuinfo
0
[root@node03 ~]# 

  提示:如果以上命令執行返回0,表示該計算節點不支援硬體虛擬化,如果返回非0,表示該計算節點支援硬體虛擬化;如果計算節點支援硬體虛擬化,到此計算節點上的nova配置就完成了;如果不支援硬體虛擬化,我們需要在【libvirt】配置段明確指明使用的virt_type為qemu,而不是kvm;

  在【libvirt】配置段明確指明使用qemu

  nova.conf最終配置

[root@node03 ~]# grep -i ^"[a-z\[]" /etc/nova/nova.conf               
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:openstack123@node02
use_neutron = true
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[api]
auth_strategy = keystone
[api_database]
[barbican]
[cache]
[cells]
[cinder]
[compute]
[conductor]
[console]
[consoleauth]
[cors]
[database]
[devices]
[ephemeral_storage_encryption]
[filter_scheduler]
[glance]
api_servers = http://controller:9292
[guestfs]
[healthcheck]
[hyperv]
[ironic]
[key_manager]
[keystone]
[keystone_authtoken]
auth_url = http://controller:5000/v3
memcached_servers = node02:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = nova
password = nova
[libvirt]
virt_type = qemu
[matchmaker_redis]
[metrics]
[mks]
[neutron]
[notifications]
[osapi_v21]
[oslo_concurrency]
lock_path=/var/lib/nova/tmp
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_messaging_zmq]
[oslo_middleware]
[oslo_policy]
[pci]
[placement]
region_name = RegionOne
project_domain_name = Default
project_name = service
auth_type = password
user_domain_name = Default
auth_url = http://controller:5000/v3
username = placement
password = placement
[placement_database]
[powervm]
[profiler]
[quota]
[rdp]
[remote_debug]
[scheduler]
[serial_console]
[service_user]
[spice]
[upgrade_levels]
[vault]
[vendordata_dynamic_auth]
[vmware]
[vnc]
enabled = true
server_listen = 0.0.0.0
server_proxyclient_address = node03
novncproxy_base_url = http://controller:6080/vnc_auto.html
[workarounds]
[wsgi]
[xenserver]
[xvp]
[zvm]
[root@node03 ~]# 

  啟動nova-compute和libvirtd服務,並將其設定為開機啟動

[root@node03 ~]# systemctl start libvirtd.service openstack-nova-compute.service
[root@node03 ~]# systemctl enable libvirtd.service openstack-nova-compute.service     
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-nova-compute.service to /usr/lib/systemd/system/openstack-nova-compute.service.
[root@node03 ~]# 

  在控制節點上匯出admin使用者的環境變數,將計算節點資訊新增到cell資料庫中

[root@node01 ~]# source admin.sh 
[root@node01 ~]# openstack compute service list --service nova-compute
+----+--------------+-----------------+------+---------+-------+----------------------------+
| ID | Binary       | Host            | Zone | Status  | State | Updated At                 |
+----+--------------+-----------------+------+---------+-------+----------------------------+
|  9 | nova-compute | node03.test.org | nova | enabled | up    | 2020-10-29T16:46:34.000000 |
+----+--------------+-----------------+------+---------+-------+----------------------------+
[root@node01 ~]# 

  手動掃描發現計算節點

[root@node01 ~]# 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 computes from cell 'cell1': 2ad18452-0e55-4505-ba5e-76cbf071b0d6
Checking host mapping for compute host 'node03.test.org': 24beeca9-7c6e-4025-ada4-f6cfffb89b5d
Creating host mapping for compute host 'node03.test.org': 24beeca9-7c6e-4025-ada4-f6cfffb89b5d
Found 1 unmapped computes in cell: 2ad18452-0e55-4505-ba5e-76cbf071b0d6
[root@node01 ~]# 

  設定自動發現計算節點,並自動完成計算節點註冊的間隔時間

  提示:這個配置要在控制節點的nova.conf中配置,上述配置表示每隔300秒自動掃描一下有沒有新的計算節點加入;

  到此,計算節點上的nova服務就安裝配置完成了

  驗證:在控制節點匯出admin使用者的環境變數,列出服務元件,驗證每個流程的成功啟動和註冊

[root@node01 ~]# source admin.sh 
[root@node01 ~]# openstack compute service list 
+----+------------------+-----------------+----------+---------+-------+----------------------------+
| ID | Binary           | Host            | Zone     | Status  | State | Updated At                 |
+----+------------------+-----------------+----------+---------+-------+----------------------------+
|  1 | nova-consoleauth | node01.test.org | internal | enabled | up    | 2020-10-29T16:57:33.000000 |
|  2 | nova-scheduler   | node01.test.org | internal | enabled | up    | 2020-10-29T16:57:33.000000 |
|  6 | nova-conductor   | node01.test.org | internal | enabled | up    | 2020-10-29T16:57:34.000000 |
|  9 | nova-compute     | node03.test.org | nova     | enabled | up    | 2020-10-29T16:57:34.000000 |
+----+------------------+-----------------+----------+---------+-------+----------------------------+
[root@node01 ~]# 

  提示:能夠看到controller節點上啟用的三個服務元件和compute節點上啟用的一個服務元件。能夠看到上述資訊,表示nova服務工作正常;

  驗證:列出通過keystone驗證的API端點

[root@node01 ~]# openstack catalog list
+-----------+-----------+-----------------------------------------+
| Name      | Type      | Endpoints                               |
+-----------+-----------+-----------------------------------------+
| nova      | compute   | RegionOne                               |
|           |           |   internal: http://controller:8774/v2.1 |
|           |           | RegionOne                               |
|           |           |   admin: http://controller:8774/v2.1    |
|           |           | RegionOne                               |
|           |           |   public: http://controller:8774/v2.1   |
|           |           |                                         |
| keystone  | identity  | RegionOne                               |
|           |           |   admin: http://controller:5000/v3      |
|           |           | RegionOne                               |
|           |           |   public: http://controller:5000/v3     |
|           |           | RegionOne                               |
|           |           |   internal: http://controller:5000/v3   |
|           |           |                                         |
| glance    | image     | RegionOne                               |
|           |           |   admin: http://controller:9292         |
|           |           | RegionOne                               |
|           |           |   internal: http://controller:9292      |
|           |           | RegionOne                               |
|           |           |   public: http://controller:9292        |
|           |           |                                         |
| placement | placement | RegionOne                               |
|           |           |   internal: http://controller:8778      |
|           |           | RegionOne                               |
|           |           |   public: http://controller:8778        |
|           |           | RegionOne                               |
|           |           |   admin: http://controller:8778         |
|           |           |                                         |
+-----------+-----------+-----------------------------------------+
[root@node01 ~]# 

  驗證:檢查cell和placement是否工作正常

[root@node01 ~]# 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                  |
+--------------------------------+
| Check: Ironic Flavor Migration |
| Result: Success                |
| Details: None                  |
+--------------------------------+
| Check: API Service Version     |
| Result: Success                |
| Details: None                  |
+--------------------------------+
| Check: Request Spec Migration  |
| Result: Success                |
| Details: None                  |
+--------------------------------+
| Check: Console Auths           |
| Result: Success                |
| Details: None                  |
+--------------------------------+
[root@node01 ~]# 

  提示:這個檢查必須要全部都是成功的才沒有問題;到此nova服務的安裝配置和測試就完了;後續我們還差一個neutron網路服務,就可以在openstack上啟動虛擬機器了;

相關文章