雲計算管理平台之OpenStack計算服務nova


  一、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上啟動虛擬機了;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM