简介
计算服务Nova
使用OpenStack Compute来托管和管理云计算系统。 OpenStack Compute是基础架构即服务(IaaS)系统的主要部分。 主要模块用Python实现。
OpenStack Compute与OpenStack Identity交互以进行身份验证; 用于磁盘和服务器映像的OpenStack映像服务; 和OpenStack Dashboard用于用户和管理界面。
图像访问受项目和用户的限制; 配额是按项目限制的(例如,实例数)。 OpenStack Compute可以在标准硬件上水平扩展,并将图像下载到启动实例。
一、组件说明
OpenStack计算服务由下列组件所构成:
nova-api服务
接收和响应来自最终用户的计算API请求。此服务支持OpenStack计算服务API,Amazon EC2 API,以及特殊的管理API用于赋予用户做一些管理的操作。它会强制实施一些规则,发起多数的编排活动,例如运行一个实例。
NOVA-API-metadata服务
接受来自实例的元数据请求。 当您在具有nova-network安装的多主机模式下运行时,通常会使用nova-api-metadata服务。 有关详细信息,请参阅“OpenStack管理员指南”中的元数据服务。
NOVA-API-metadata服务
接受来自实例的元数据请求。 当您在具有nova-network安装的多主机模式下运行时,通常会使用nova-api-metadata服务。 有关详细信息,请参阅“OpenStack管理员指南”中的元数据服务。
nova-compute服务
一个持续工作的守护进程,通过Hypervior的API来创建和销毁虚拟机实例。例如:
XenServer/XCP 的 XenAPI
KVM 或 QEMU 的 libvirt
VMware 的 VMwareAPI
过程是蛮复杂的。最为基本的,守护进程同意了来自队列的动作请求,转换为一系列的系统命令如启动一个KVM实例,然后,到数据库中更新它的状态。
nova-placement-api服务
跟踪每个提供商的库存和使用情况。
NOVA-scheduler服务
拿到一个来自队列请求虚拟机实例,然后决定那台计算服务器主机来运行它。
NOVA-conductor模块
调解nova-compute服务与数据库之间的交互。它消除了nova-compute服务对云数据库的直接访问。 nova-conductor模块水平缩放。但是,请勿将其部署在运行nova-compute服务的节点上。有关更多信息,请参阅“配置参考指南”
nova-cert模块
服务器守护进程向Nova Cert服务提供X509证书。用来为``euca-bundle-image``生成证书。仅仅是在EC2 API的请求中使用
nova-consoleauth模块
为控制台代理提供的用户授权令牌。请参阅nova-novncproxy和nova-xvpvncproxy。必须运行此服务才能使控制台代理生效。您可以针对群集配置中的单个nova-consoleauth服务运行任一类型的代理。有关信息,请参阅关于nova-consoleauth。
nova-novncproxy模块
提供一个代理,用于访问正在运行的实例,通过VNC协议,支持基于浏览器的novnc客户端。
NOVA-spicehtml5proxy守护进程
提供一个代理,用于访问正在运行的实例,通过SPICE协议,支持基于浏览器的HTML5客户端。
nova-xvpvncproxy守护进程
提供一个代理,用于访问正在运行的实例,通过VNC协议,支持OpenStack的特定的Java的客户端。
队列用于在守护进程之间传递消息的中央集线器。通常用RabbitMQ实现,也可以用另一个AMQP消息队列实现,比如
- ZeroMQ。
- SQL数据库
存储构建时和运行时的状态,为云基础设施,包括有:
- 可用实例类型
- 使用中的实例
从理论上讲,OpenStack Compute可以支持SQLAlchemy支持的任何数据库。常见的数据库是用于测试和开发工作的SQLite3,MySQL,MariaDB和PostgreSQL。
二、安装和配置计算服务
这个部分描述如何在控制节点上安装和配置计算服务,即 nova
环境描述
主机名 |
内存 |
硬盘 |
网卡 |
系统 |
ct |
8 |
300+300 |
VM1:192.168.100.100 |
Centos7.6 |
NAT:20.0.0.10 |
||||
c1 |
8 |
300+300 |
VM1:192.168.100.101 |
Centos7.6 |
NAT:20.0.0.20 |
||||
c2 |
8 |
300+300 |
VM1:192.168.100.102 |
Centos7.6 |
NAT:20.0.0.30 |
三、OpenStack-placement模块部署(ct上安装)
3.1、创建数据库实例和数据库用户
1 [root@ct ~]# mysql -uroot -p123456
2 MariaDB [(none)]> CREATE DATABASE placement;
3 MariaDB [(none)]> GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'localhost' IDENTIFIED BY 'PLACEMENT_DBPASS';
4 MariaDB [(none)]> GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' IDENTIFIED BY 'PLACEMENT_DBPASS';
5 MariaDB [(none)]> flush privileges;
6 MariaDB [(none)]> exit;
3.2、创建Placement服务用户和API的endpoint
①创建placement用户
1 [root@ct ~]# openstack user create --domain default --password PLACEMENT_PASS placement
②给与placement用户对service项目拥有admin权限
1 [root@ct ~]# openstack role add --project service --user placement admin
③创建一个placement服务,服务类型为placement
1 [root@ct ~]# openstack service create --name placement --description "Placement API" placement
④注册API端口到placement的service中;注册的信息会写入到mysql中
1 [root@ct ~]# openstack endpoint create --region RegionOne placement public http://ct:8778
2 [root@ct ~]# openstack endpoint create --region RegionOne placement internal http://ct:8778
3 [root@ct ~]# openstack endpoint create --region RegionOne placement admin http://ct:8778
⑤安装placement服务
1 [root@controller ~]# yum -y install openstack-placement-api
⑥修改placement配置文件
1 cp -p /etc/placement/placement.conf{,.bak}
2 grep -Ev '^$|#' /etc/placement/placement.conf.bak > /etc/placement/placement.conf
3 openstack-config --set /etc/placement/placement.conf placement_database connection mysql+pymysql://placement:PLACEMENT_DBPASS@ct/placement
4 openstack-config --set /etc/placement/placement.conf api auth_strategy keystone
5 openstack-config --set /etc/placement/placement.conf keystone_authtoken auth_url http://ct:5000/v3
6 openstack-config --set /etc/placement/placement.conf keystone_authtoken memcached_servers ct:11211
7 openstack-config --set /etc/placement/placement.conf keystone_authtoken auth_type password
8 openstack-config --set /etc/placement/placement.conf keystone_authtoken project_domain_name Default
9 openstack-config --set /etc/placement/placement.conf keystone_authtoken user_domain_name Default
10 openstack-config --set /etc/placement/placement.conf keystone_authtoken project_name service
11 openstack-config --set /etc/placement/placement.conf keystone_authtoken username placement
12 openstack-config --set /etc/placement/placement.conf keystone_authtoken password PLACEMENT_PASS
⑦导入数据库
1 [root@ct~]# su -s /bin/sh -c "placement-manage db sync" placement
⑧修改Apache配置文件
1 00-placemenct-api.conf(安装完placement服务后会自动创建该文件-虚拟主机配置)
2 [root@ct conf.d]# cd /etc/httpd/conf.d/
3 [root@ct conf.d]# cat 00-placement-api.conf #安装完placement会自动创建此文件
4 Listen 8778
5
6 <VirtualHost *:8778>
7 WSGIProcessGroup placement-api
8 WSGIApplicationGroup %{GLOBAL}
9 WSGIPassAuthorization On
10 WSGIDaemonProcess placement-api processes=3 threads=1 user=placement group=placement
11 WSGIScriptAlias / /usr/bin/placement-api
12 <IfVersion >= 2.4>
13 ErrorLogFormat "%M"
14 </IfVersion>
15 ErrorLog /var/log/placement/placement-api.log
16 #SSLEngine On
17 #SSLCertificateFile ...
18 #SSLCertificateKeyFile ...
19 </VirtualHost>
20
21 Alias /placement-api /usr/bin/placement-api
22 <Location /placement-api>
23 SetHandler wsgi-script
24 Options +ExecCGI
25 WSGIProcessGroup placement-api
26 WSGIApplicationGroup %{GLOBAL}
27 WSGIPassAuthorization On
28 </Location>
29 <Directory /usr/bin> #此处是bug,必须添加下面的配置来启用对placement api的访问,否则在访问apache的
30 <IfVersion >= 2.4> #api时会报403;添加在文件的最后即可
31 Require all granted
32 </IfVersion>
33 <IfVersion < 2.4> #apache版本;允许apache访问/usr/bin目录;否则/usr/bin/placement-api将不允许被访问
34 Order allow,deny
35 Allow from all #允许apache访问
36 </IfVersion>
37 </Directory>
38
39 重新启动apache
40 [root@ct placement]# systemctl restart httpd
⑨测试
1 curl 测试访问
2 [root@ct conf.d]# curl ct:8778
3 {"versions": [{"status": "CURRENT", "min_version": "1.0", "max_version": "1.36", "id": "v1.0", "links": [{"href": "", "rel": "self"}]}]}
4
5 查看端口占用(netstat、lsof)
6 [root@ct conf.d]# netstat -anpt | grep 8778
7 tcp 0 0 192.168.100.100:56856 192.168.100.100:8778 TIME_WAIT -
8 tcp6 0 0 :::8778 :::* LISTEN 59378/httpd
9 tcp6 0 0 192.168.100.100:8778 192.168.100.101:52862 ESTABLISHED 60167/httpd
10 tcp6 0 0 192.168.100.100:8778 192.168.100.102:42474 TIME_WAIT -
11 tcp6 0 0 192.168.100.100:8778 192.168.100.102:42476 FIN_WAIT2 -
12 tcp6 0 0 192.168.100.100:8778 192.168.100.101:52860 TIME_WAIT -
13
14 检查placement状态
15 [root@ct conf.d]# placement-status upgrade check
16 +----------------------------------+
17 | Upgrade Check Results |
18 +----------------------------------+
19 | Check: Missing Root Provider IDs |
20 | Result: Success |
21 | Details: None |
22 +----------------------------------+
23 | Check: Incomplete Consumers |
24 | Result: Success |
25 | Details: None |
26 +----------------------------------+
小结
Placement提供了placement-apiWSGI脚本,用于与Apache,nginx或其他支持WSGI的Web服务器一起运行服务(通过nginx或apache实现python入口代理)。根据用于部署OpenStack的打包解决方案,WSGI脚本可能位于/usr/bin 或中/usr/local/binPlacement服务是从 S 版本,从nova服务中拆分出来的组件,作用是收集各个node节点的可用资源,把node节点的资源统计写入到mysql,Placement服务会被nova scheduler服务进行调用 Placement服务的监听端口是8778
四、OpenStack-nova组件部署
4.1、控制节点ct上安装
①控制节点主要服务
- nova-api(nova主服务)
- nova-scheduler(nova调度服务)
- nova-conductor(nova数据库服务,提供数据库访问)
- nova-novncproxy(nova的vnc服务,提供实例的控制台)
②创建nova数据库,并执行授权操作
1 [root@ct ~]# mysql -uroot -p123456
2 MariaDB [(none)]> CREATE DATABASE nova_api;
3 MariaDB [(none)]> CREATE DATABASE nova;
4 MariaDB [(none)]> CREATE DATABASE nova_cell0;
5 MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS';
6 MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS';
7 MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS';
8 MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS';
9 MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS';
10 MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS';
11 MariaDB [(none)]> flush privileges;
12 MariaDB [(none)]> exit
③创建nova用户
1 [root@ct conf.d]# openstack user create --domain default --password NOVA_PASS nova
2 +---------------------+----------------------------------+
3 | Field | Value |
4 +---------------------+----------------------------------+
5 | domain_id | default |
6 | enabled | True |
7 | id | a1042031dead4021b069c0d8bf13afb5 |
8 | name | nova |
9 | options | {} |
10 | password_expires_at | None |
11 +---------------------+----------------------------------+
④把nova用户添加到service项目,拥有admin权限
1 [root@ct conf.d]# openstack user list
2 +----------------------------------+-----------+
3 | ID | Name |
4 +----------------------------------+-----------+
5 | d6e16b92bebd4fd7a7a3f55eee931efb | admin |
6 | 7d023fd9e22d455aafe2e12749a7a676 | glance |
7 | afeb6037114f4a8f8833a450a48f25da | placement |
8 | a1042031dead4021b069c0d8bf13afb5 | nova |
9 +----------------------------------+-----------+
10 [root@ct conf.d]# openstack role add --project service --user nova admin
⑤创建nova服务
1 [root@ct conf.d]# openstack service create --name nova --description "OpenStack Compute" compute
2 +-------------+----------------------------------+
3 | Field | Value |
4 +-------------+----------------------------------+
5 | description | OpenStack Compute |
6 | enabled | True |
7 | id | e0082dacfd224602adcb12a80da973ae |
8 | name | nova |
9 | type | compute |
10 +-------------+----------------------------------+
⑥给Nova服务关联endpoint(端点)
1 [root@ct conf.d]# openstack endpoint create --region RegionOne compute public http://ct:8774/v2.1
2 +--------------+----------------------------------+
3 | Field | Value |
4 +--------------+----------------------------------+
5 | enabled | True |
6 | id | 13cdbde451ee4a3b8e669daba818fc00 |
7 | interface | public |
8 | region | RegionOne |
9 | region_id | RegionOne |
10 | service_id | e0082dacfd224602adcb12a80da973ae |
11 | service_name | nova |
12 | service_type | compute |
13 | url | http://ct:8774/v2.1 |
14 +--------------+----------------------------------+
15 [root@ct conf.d]# openstack endpoint create --region RegionOne compute internal http://ct:8774/v2.1
16 +--------------+----------------------------------+
17 | Field | Value |
18 +--------------+----------------------------------+
19 | enabled | True |
20 | id | 9282d33c703c40e39eeaa545eeae8a09 |
21 | interface | internal |
22 | region | RegionOne |
23 | region_id | RegionOne |
24 | service_id | e0082dacfd224602adcb12a80da973ae |
25 | service_name | nova |
26 | service_type | compute |
27 | url | http://ct:8774/v2.1 |
28 +--------------+----------------------------------+
29 [root@ct conf.d]# openstack endpoint create --region RegionOne compute admin http://ct:8774/v2.1
30 +--------------+----------------------------------+
31 | Field | Value |
32 +--------------+----------------------------------+
33 | enabled | True |
34 | id | 868b1526f86c4647bb42ca5c27de80ff |
35 | interface | admin |
36 | region | RegionOne |
37 | region_id | RegionOne |
38 | service_id | e0082dacfd224602adcb12a80da973ae |
39 | service_name | nova |
40 | service_type | compute |
41 | url | http://ct:8774/v2.1 |
42 +--------------+----------------------------------+
⑦安装nova组件
1 [root@ct ~]# yum -y install openstack-nova-api openstack-nova-conductor openstack-nova-novncproxy openstack-nova-scheduler
⑧修改nova配置文件
1 [root@ct ~]# cp -a /etc/nova/nova.conf{,.bak}
2 [root@ct ~]# grep -Ev '^$|#' /etc/nova/nova.conf.bak > /etc/nova/nova.conf
3 openstack-config --set /etc/nova/nova.conf DEFAULT enabled_apis osapi_compute,metadata
4 openstack-config --set /etc/nova/nova.conf DEFAULT my_ip 20.0.0.10 ####修改为 ct的IP(内部IP)
5 openstack-config --set /etc/nova/nova.conf DEFAULT use_neutron true
6 openstack-config --set /etc/nova/nova.conf DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver
7 openstack-config --set /etc/nova/nova.conf DEFAULT transport_url rabbit://openstack:RABBIT_PASS@ct
8 openstack-config --set /etc/nova/nova.conf api_database connection mysql+pymysql://nova:NOVA_DBPASS@ct/nova_api
9 openstack-config --set /etc/nova/nova.conf database connection mysql+pymysql://nova:NOVA_DBPASS@ct/nova
10 openstack-config --set /etc/nova/nova.conf placement_database connection mysql+pymysql://placement:PLACEMENT_DBPASS@ct/placement
11 openstack-config --set /etc/nova/nova.conf api auth_strategy keystone
12 openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_url http://ct:5000/v3
13 openstack-config --set /etc/nova/nova.conf keystone_authtoken memcached_servers ct:11211
14 openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_type password
15 openstack-config --set /etc/nova/nova.conf keystone_authtoken project_domain_name Default
16 openstack-config --set /etc/nova/nova.conf keystone_authtoken user_domain_name Default
17 openstack-config --set /etc/nova/nova.conf keystone_authtoken project_name service
18 openstack-config --set /etc/nova/nova.conf keystone_authtoken username nova
19 openstack-config --set /etc/nova/nova.conf keystone_authtoken password NOVA_PASS
20 openstack-config --set /etc/nova/nova.conf vnc enabled true
21 openstack-config --set /etc/nova/nova.conf vnc server_listen ' $my_ip'
22 openstack-config --set /etc/nova/nova.conf vnc server_proxyclient_address ' $my_ip'
23 openstack-config --set /etc/nova/nova.conf glance api_servers http://ct:9292
24 openstack-config --set /etc/nova/nova.conf oslo_concurrency lock_path /var/lib/nova/tmp
25 openstack-config --set /etc/nova/nova.conf placement region_name RegionOne
26 openstack-config --set /etc/nova/nova.conf placement project_domain_name Default
27 openstack-config --set /etc/nova/nova.conf placement project_name service
28 openstack-config --set /etc/nova/nova.conf placement auth_type password
29 openstack-config --set /etc/nova/nova.conf placement user_domain_name Default
30 openstack-config --set /etc/nova/nova.conf placement auth_url http://ct:5000/v3
31 openstack-config --set /etc/nova/nova.conf placement username placement
32 openstack-config --set /etc/nova/nova.conf placement password PLACEMENT_PASS
⑨初始化数据库
1 初始化nova_api数据库
2 [root@ct conf.d]# su -s /bin/sh -c "nova-manage api_db sync" nova
3
4 注册cell0数据库;nova服务内部把资源划分到不同的cell中,把计算节点划分到不同的cell中;openstack内部基于cell把计算节点进行逻辑上的分组
5 [root@ct ~]# su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
6
7 创建cell1单元格
8 [root@ct conf.d]# su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
9 d8cfb3d9-7ccd-4ffb-a5d4-9cf7010d76c4
10
11 初始化nova数据库
12 [root@ct conf.d]# su -s /bin/sh -c "nova-manage db sync" nova
13
14 验证cell0和cell1是否注册成功
15 [root@ct conf.d]# su -s /bin/sh -c "nova-manage cell_v2 list_cells" nova
16 +-------+--------------------------------------+----------------------------+-----------------------------------------+----------+
17 | 名称 | UUID | Transport URL | 数据库连接 | Disabled |
18 +-------+--------------------------------------+----------------------------+-----------------------------------------+----------+
19 | cell0 | 00000000-0000-0000-0000-000000000000 | none:/ | mysql+pymysql://nova:****@ct/nova_cell0 | False |
20 | cell1 | d8cfb3d9-7ccd-4ffb-a5d4-9cf7010d76c4 | rabbit://openstack:****@ct | mysql+pymysql://nova:****@ct/nova | False |
21 +-------+--------------------------------------+----------------------------+-----------------------------------------+----------+
⑩启动Nova服务
1 [root@ct ~]# systemctl enable openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
2 [root@ct ~]# systemctl start openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
11.检查nova服务端口
1 [root@ct conf.d]# netstat -anpt | egrep '8774|8775'
2 tcp 0 0 0.0.0.0:8775 0.0.0.0:* LISTEN 61473/python2
3 tcp 0 0 0.0.0.0:8774 0.0.0.0:* LISTEN 61473/python2
4 [root@ct conf.d]# curl http://ct:8774
5 {"versions": [{"status": "SUPPORTED", "updated": "2011-01-21T11:33:21Z", "links": [{"href": "http://ct:8774/v2/", "rel": "self"}], "min_version": "", "version": "", "id": "v2.0"}, {"status": "CURRENT", "updated": "2013-07-23T11:33:21Z", "links": [{"href": "http://ct:8774/v2.1/", "rel": "self"}], "min_version": "2.1", "version": "2.79", "id": "v2.1"}]}
4.2、计算节点c1、c2上安装(c1上演示)
①计算节点服务
- nova-compute(nova计算服务)
②安装nova-compute组件
1 [root@c1 ~]# yum -y install openstack-nova-compute
③修改配置文件
1 cp -a /etc/nova/nova.conf{,.bak}
2 grep -Ev '^$|#' /etc/nova/nova.conf.bak > /etc/nova/nova.conf
3 openstack-config --set /etc/nova/nova.conf DEFAULT enabled_apis osapi_compute,metadata
4 openstack-config --set /etc/nova/nova.conf DEFAULT transport_url rabbit://openstack:RABBIT_PASS@ct
5 openstack-config --set /etc/nova/nova.conf DEFAULT my_ip 20.0.0.20 #修改为对应节点的内部IP
6 openstack-config --set /etc/nova/nova.conf DEFAULT use_neutron true
7 openstack-config --set /etc/nova/nova.conf DEFAULT firewall_driver nova.virt.firewall.NoopFirewallDriver
8 openstack-config --set /etc/nova/nova.conf api auth_strategy keystone
9 openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_url http://ct:5000/v3
10 openstack-config --set /etc/nova/nova.conf keystone_authtoken memcached_servers ct:11211
11 openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_type password
12 openstack-config --set /etc/nova/nova.conf keystone_authtoken project_domain_name Default
13 openstack-config --set /etc/nova/nova.conf keystone_authtoken user_domain_name Default
14 openstack-config --set /etc/nova/nova.conf keystone_authtoken project_name service
15 openstack-config --set /etc/nova/nova.conf keystone_authtoken username nova
16 openstack-config --set /etc/nova/nova.conf keystone_authtoken password NOVA_PASS
17 openstack-config --set /etc/nova/nova.conf vnc enabled true
18 openstack-config --set /etc/nova/nova.conf vnc server_listen 0.0.0.0
19 openstack-config --set /etc/nova/nova.conf vnc server_proxyclient_address ' $my_ip'
20 openstack-config --set /etc/nova/nova.conf vnc novncproxy_base_url http://20.0.0.10:6080/vnc_auto.html #指向控制节点IP
21 openstack-config --set /etc/nova/nova.conf glance api_servers http://ct:9292
22 openstack-config --set /etc/nova/nova.conf oslo_concurrency lock_path /var/lib/nova/tmp
23 openstack-config --set /etc/nova/nova.conf placement region_name RegionOne
24 openstack-config --set /etc/nova/nova.conf placement project_domain_name Default
25 openstack-config --set /etc/nova/nova.conf placement project_name service
26 openstack-config --set /etc/nova/nova.conf placement auth_type password
27 openstack-config --set /etc/nova/nova.conf placement user_domain_name Default
28 openstack-config --set /etc/nova/nova.conf placement auth_url http://ct:5000/v3
29 openstack-config --set /etc/nova/nova.conf placement username placement
30 openstack-config --set /etc/nova/nova.conf placement password PLACEMENT_PASS
31 openstack-config --set /etc/nova/nova.conf libvirt virt_type qemu
④开启服务
1 [root@c1 ~]# systemctl enable libvirtd.service openstack-nova-compute.service
2 [root@c1 ~]# systemctl start libvirtd.service openstack-nova-compute.service
⑤控制节点ct上操作
1 查看compute节点是否注册到controller上,通过消息队列;需要在controller节点执行
2 [root@ct conf.d]# openstack compute service list --service nova-compute
3 +----+--------------+------+------+---------+-------+----------------------------+
4 | ID | Binary | Host | Zone | Status | State | Updated At |
5 +----+--------------+------+------+---------+-------+----------------------------+
6 | 8 | nova-compute | c1 | nova | enabled | up | 2020-12-28T08:12:57.000000 |
7 | 9 | nova-compute | c2 | nova | enabled | up | 2020-12-28T08:13:00.000000 |
8 +----+--------------+------+------+---------+-------+----------------------------+
9
10 扫描当前openstack中有哪些计算节点可用,发现后会把计算节点创建到cell中,后面就可以在cell中创建虚拟机;相当于openstack内部对计算节点进行分组,把计算节点分配到不同的cell中
11 [root@ct conf.d]# su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova
12 Found 2 cell mappings.
13 Skipping cell0 since it does not contain hosts.
14 Getting computes from cell 'cell1': d8cfb3d9-7ccd-4ffb-a5d4-9cf7010d76c4
15 Checking host mapping for compute host 'c1': 86258d6e-aefe-45f6-9f37-140f67b58bab
16 Creating host mapping for compute host 'c1': 86258d6e-aefe-45f6-9f37-140f67b58bab
17 Checking host mapping for compute host 'c2': 664e3f94-4afb-4c7d-af8e-ee6af6085df0
18 Creating host mapping for compute host 'c2': 664e3f94-4afb-4c7d-af8e-ee6af6085df0
19 Found 2 unmapped computes in cell: d8cfb3d9-7ccd-4ffb-a5d4-9cf7010d76c4
20
21 默认每次添加个计算节点,在控制端就需要执行一次扫描,这样会很麻烦,所以可以修改控制端nova的主配置文件
22 [root@ct ~]# vim /etc/nova/nova.conf
23 [scheduler]
24 discover_hosts_in_cells_interval = 300 #每300秒扫描一次
25 [root@ct ~]# systemctl restart openstack-nova-api.service
⑥验证计算节点服务(ct上验证)
1 检查 nova 的各个服务是否都是正常,以及 compute 服务是否注册成功
2 [root@ct conf.d]# openstack compute service list
3 +----+----------------+------+----------+---------+-------+----------------------------+
4 | ID | Binary | Host | Zone | Status | State | Updated At |
5 +----+----------------+------+----------+---------+-------+----------------------------+
6 | 3 | nova-conductor | ct | internal | enabled | up | 2020-12-28T08:16:26.000000 |
7 | 4 | nova-scheduler | ct | internal | enabled | up | 2020-12-28T08:16:29.000000 |
8 | 8 | nova-compute | c1 | nova | enabled | up | 2020-12-28T08:16:27.000000 |
9 | 9 | nova-compute | c2 | nova | enabled | up | 2020-12-28T08:16:30.000000 |
10 +----+----------------+------+----------+---------+-------+----------------------------+
11
12 查看各个组件的 api 是否正常
13 [root@ct conf.d]# openstack catalog list
14 +-----------+-----------+---------------------------------+
15 | Name | Type | Endpoints |
16 +-----------+-----------+---------------------------------+
17 | glance | image | RegionOne |
18 | | | admin: http://ct:9292 |
19 | | | RegionOne |
20 | | | public: http://ct:9292 |
21 | | | RegionOne |
22 | | | internal: http://ct:9292 |
23 | | | |
24 | nova | compute | RegionOne |
25 | | | public: http://ct:8774/v2.1 |
26 | | | RegionOne |
27 | | | admin: http://ct:8774/v2.1 |
28 | | | RegionOne |
29 | | | internal: http://ct:8774/v2.1 |
30 | | | |
31 | keystone | identity | RegionOne |
32 | | | admin: http://ct:5000/v3/ |
33 | | | RegionOne |
34 | | | internal: http://ct:5000/v3/ |
35 | | | RegionOne |
36 | | | public: http://ct:5000/v3/ |
37 | | | |
38 | placement | placement | RegionOne |
39 | | | public: http://ct:8778 |
40 | | | RegionOne |
41 | | | admin: http://ct:8778 |
42 | | | RegionOne |
43 | | | internal: http://ct:8778 |
44 | | | |
45 +-----------+-----------+---------------------------------+
46
47 查看是否能够拿到镜像
48 [root@ct conf.d]# openstack image list
49 +--------------------------------------+--------+--------+
50 | ID | Name | Status |
51 +--------------------------------------+--------+--------+
52 | fd197925-4879-4330-aa57-b89f108973e0 | cirros | active |
53 +--------------------------------------+--------+--------+
54
55 查看cell的api和placement的api是否正常,只要其中一个有误,后期无法创建虚拟机
56 [root@ct conf.d]# nova-status upgrade check
57 +--------------------------------+
58 | Upgrade Check Results |
59 +--------------------------------+
60 | Check: Cells v2 |
61 | Result: Success |
62 | Details: None |
63 +--------------------------------+
64 | Check: Placement API |
65 | Result: Success |
66 | Details: None |
67 +--------------------------------+
68 | Check: Ironic Flavor Migration |
69 | Result: Success |
70 | Details: None |
71 +--------------------------------+
72 | Check: Cinder API |
73 | Result: Success |
74 | Details: None |
75 +--------------------------------+
总结
Nova分为控制节点、计算节点
Nova组件核心功能是调度资源,在配置文件中需要体现的部分:指向认证节点位置(URL、ENDPOINT)、调用服务、注册、提供支持等,配置文件中的所有配置参数基本都是围绕此范围进行设置