Nova 是 OpenStack 最核心的服务,负责维护和管理云环境的计算资源。OpenStack 作为 IaaS 的云操作系统,虚拟机生命周期管理也就是通过 Nova 来实现的。
用途与功能 :
nova-api:实现了RESTful API功能,是外部访问Nova的唯一途径。接收外部的请求并通过Message Queue将请求发送给其他的服务组件,同时也兼容EC2 API,所以也可以用EC2的管理工具对nova进行日常管理。
nova-scheduler:决策虚拟机创建在哪个主机(计算节点)上。决策一个虚拟机应该调度到某物理节点,需要分为两个步骤:
nova-compute:负责虚拟机的生命周期管理,创建并终止虚拟机实例的工作后台程序hypervisor api
nova-conductor:计算节点访问数据的中间件,nova-compute服务和数据库之间的中间件。它消除了对云数据库的直接访问。
nova-api-metadata:从实例中接收元数据请求。nova-api-metadata服务通常在nova-network安装时使用的是多宿主模式运行。
nova-placement-api:跟踪每个计算提供者的仓库和使用情况。
nova-consoleauth:用于控制台的授权验证,授权控制台代理提供的用户令牌。此服务必须运行用于控制台代理工作。您可以运行任何类型的代理,而不是集群配置中的单nova-consoleauth服务。
Queue:在守护进程之间传递消息的中心。通常使用RabbitMQ,也可以用另一个基于AMQP的消息队列,例如ZeroMQ。
# 创建数据库
CREATE DATABASE nova_api;
CREATE DATABASE nova;
CREATE DATABASE nova_cell0;
# 创建用户
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' \
IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' \
IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' \
IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' \
IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' \
IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' \
IDENTIFIED BY '123456';
# 非交互式创建用户nova密码nova
openstack user create --domain default --password nova nova
# 交互式创建用户
# openstack user create --domain default --password-prompt nova
# 授权到admin角色
openstack role add --project service --user nova admin
# 检验
[root@master01 ~]# openstack user list
+----------------------------------+-----------+
| ID | Name |
+----------------------------------+-----------+
| d8cd16895f8d4421975a3e22396af49a | admin |
| d5935c2448ff4adb91758635718ea7a8 | glance |
| 45dc96ccfbde4da0b042c715781dbf06 | placement |
| a39969441ac94974ae36fb738fb3ea78 | nova |
+----------------------------------+-----------+
[root@master01.boysec.cn ~]# openstack role assignment list
+----------------------------------+----------------------------------+-------+----------------------------------+--------+--------+-----------+
| Role | User | Group | Project | Domain | System | Inherited |
+----------------------------------+----------------------------------+-------+----------------------------------+--------+--------+-----------+
| 9ccb729edfb945f4bc4ea5b4abcb305c | 45dc96ccfbde4da0b042c715781dbf06 | | e605a87cc5c34ae0869226db49b48162 | | | False |
| 9ccb729edfb945f4bc4ea5b4abcb305c | a39969441ac94974ae36fb738fb3ea78 | | e605a87cc5c34ae0869226db49b48162 | | | False |
| 9ccb729edfb945f4bc4ea5b4abcb305c | d5935c2448ff4adb91758635718ea7a8 | | e605a87cc5c34ae0869226db49b48162 | | | False |
| 9ccb729edfb945f4bc4ea5b4abcb305c | d8cd16895f8d4421975a3e22396af49a | | e40a3e215adc41fa89b7c6ddf9443dc3 | | | False |
| 9ccb729edfb945f4bc4ea5b4abcb305c | d8cd16895f8d4421975a3e22396af49a | | | | all | False |
+----------------------------------+----------------------------------+-------+----------------------------------+--------+--------+-----------+
openstack service create --name nova \
--description "OpenStack Compute" compute
openstack endpoint create --region RegionOne \
compute public http://master01.boysec.cn:8774/v2.1
openstack endpoint create --region RegionOne \
compute internal http://master01.boysec.cn:8774/v2.1
openstack endpoint create --region RegionOne \
compute admin http://master01.boysec.cn:8774/v2.1
# 检查命令
openstack service list
openstack endpoint list
yum install openstack-nova-api openstack-nova-conductor \
openstack-nova-novncproxy openstack-nova-scheduler -y
# openstack-nova-conductor 负责数据库
# openstack-nova-novncproxy 负责云主机连接
# openstack-nova-scheduler 负责调度调度
[root@master01 ~]# cp /etc/nova/nova.conf{,.bak}
[root@master01 ~]# grep -Ev "^$|#" /etc/nova/nova.conf.bak > /etc/nova/nova.conf
[root@master01 ~]# cat /etc/nova/nova.conf
[DEFAULT]
my_ip = 10.1.1.100
# 启动neutron服务,禁用nova内置防火墙
use_neutron = true
firewall_driver = nova.virt.firewall.NoopFirewallDriver
# 启动计算服务api,metadata定义虚拟机的api
enabled_apis = osapi_compute,metadata
# 连接消息队列rabbitmq
transport_url = rabbit://openstack:openstack@master01.boysec.cn:5672/
[api]
auth_strategy = keystone
# nova_api连接数据库配置
[api_database]
connection = mysql+pymysql://nova:123456@master01.boysec.cn/nova_api
[barbican]
[cache]
[cinder]
[compute]
[conductor]
[console]
[consoleauth]
[cors]
# nova连接数据库配置
[database]
connection = mysql+pymysql://nova:123456@master01.boysec.cn/nova
[devices]
[ephemeral_storage_encryption]
[filter_scheduler]
[glance]
api_servers = http://master01.boysec.cn:9292
[guestfs]
[healthcheck]
[hyperv]
[ironic]
[key_manager]
[keystone]
[keystone_authtoken]
www_authenticate_uri = http://master01.boysec.cn:5000/
auth_url = http://master01.boysec.cn:5000/
memcached_servers = master01.boysec.cn:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = nova
password = nova
[libvirt]
[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_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://master01.boysec.cn:5000/v3
username = placement
password = placement
[powervm]
[privsep]
[profiler]
[quota]
[rdp]
[remote_debug]
[scheduler]
[serial_console]
[service_user]
[spice]
[upgrade_levels]
[vault]
[vendordata_dynamic_auth]
[vmware]
# VNC连接配置
[vnc]
enabled = true
server_listen = $my_ip
server_proxyclient_address = $my_ip
[workarounds]
[wsgi]
[xenserver]
[xvp]
[zvm]
su -s /bin/sh -c "nova-manage api_db sync" nova
su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
su -s /bin/sh -c "nova-manage db sync" nova
# 检查
[root@master01.boysec.cn ~]# 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:****@master01.boysec.cn/nova_cell0 | False |
| cell1 | d9de97cb-10e5-4d25-97e9-85e4ecd46f12 | rabbit://openstack:****@master01.boysec.cn:5672/ | mysql+pymysql://nova:****@master01.boysec.cn/nova | False |
+-------+--------------------------------------+----------------------------------------+-----------------------------------------------+----------+
[root@master01.boysec.cn ~]# nova-manage cell_v2 list_cells
systemctl enable \
openstack-nova-api.service \
openstack-nova-scheduler.service \
openstack-nova-conductor.service \
openstack-nova-novncproxy.service
systemctl start \
openstack-nova-api.service \
openstack-nova-scheduler.service \
openstack-nova-conductor.service \
openstack-nova-novncproxy.service
[root@master01.boysec.cn ~]# openstack compute service list
+----+----------------+--------------------+----------+---------+-------+----------------------------+
| ID | Binary | Host | Zone | Status | State | Updated At |
+----+----------------+--------------------+----------+---------+-------+----------------------------+
| 1 | nova-conductor | master01.boysec.cn | internal | enabled | up | 2021-12-26T03:55:16.000000 |
| 2 | nova-scheduler | master01.boysec.cn | internal | enabled | up | 2021-12-26T03:55:07.000000 |
+----+----------------+--------------------+----------+---------+-------+----------------------------+
验证操作
1、列出服务组件以验证每个进程的成功启动和注册
# openstack compute service list
2、列出Identity服务中的API端点以验证与Identity服务的连接
# openstack catalog list
3、检查单元格和放置API是否成功运行
[root@master01 ~]# nova-status upgrade check
+--------------------------------+
| Upgrade Check Results |
+--------------------------------+
| Check: Cells v2 |
| Result: Success |
| Details: None |
+--------------------------------+
| Check: Placement API |
| Result: Success |
| Details: None |
+--------------------------------+
| Check: Ironic Flavor Migration |
| Result: Success |
| Details: None |
+--------------------------------+
| Check: Cinder API |
| Result: Success |
| Details: None |
+--------------------------------+
yum install openstack-nova-compute -y
cp /etc/nova/nova.conf{,.bak}
grep -Ev "^$|#" /etc/nova/nova.conf.bak > /etc/nova/nova.conf
cat /etc/nova/nova.conf
[DEFAULT]
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:openstack@master01.boysec.cn
my_ip = 10.1.1.120
use_neutron = true
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[api]
auth_strategy = keystone
[api_database]
[barbican]
[cache]
[cinder]
[compute]
[conductor]
[console]
[consoleauth]
[cors]
[database]
[devices]
[ephemeral_storage_encryption]
[filter_scheduler]
[glance]
api_servers = http://master01.boysec.cn:9292
[guestfs]
[healthcheck]
[hyperv]
[ironic]
[key_manager]
[keystone]
[keystone_authtoken]
www_authenticate_uri = http://master01.boysec.cn:5000/
auth_url = http://master01.boysec.cn:5000/
memcached_servers = master01.boysec.cn:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = nova
password = nova
[libvirt]
[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_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://master01.boysec.cn:5000/v3
username = placement
password = placement
[powervm]
[privsep]
[profiler]
[quota]
[rdp]
[remote_debug]
[scheduler]
discover_hosts_in_cells_interval = 300
[serial_console]
[service_user]
[spice]
[upgrade_levels]
[vault]
[vendordata_dynamic_auth]
[vmware]
[vnc]
enabled = true
server_listen = 0.0.0.0
server_proxyclient_address = $my_ip
novncproxy_base_url = http://master01.boysec.cn:6080/vnc_auto.html
[workarounds]
[wsgi]
[xenserver]
[xvp]
[zvm]
# 查看是否支持cpu虚拟化
egrep -c '(vmx|svm)' /proc/cpuinfo
# 启动
systemctl enable libvirtd.service openstack-nova-compute.service
[root@master01.boysec.cn ~]# openstack compute service list
+----+----------------+--------------------+----------+---------+-------+----------------------------+
| ID | Binary | Host | Zone | Status | State | Updated At |
+----+----------------+--------------------+----------+---------+-------+----------------------------+
| 1 | nova-conductor | master01.boysec.cn | internal | enabled | up | 2021-12-26T05:57:52.000000 |
| 2 | nova-scheduler | master01.boysec.cn | internal | enabled | up | 2021-12-26T05:57:52.000000 |
| 5 | nova-compute | node01.boysec.cn | nova | enabled | up | 2021-12-26T05:57:57.000000 |
| 6 | nova-compute | node02.boysec.cn | nova | enabled | up | 2021-12-26T05:57:59.000000 |
+----+----------------+--------------------+----------+---------+-------+----------------------------+
# 主机发现或者更新主机
su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova
# 控制节点配置主机发现
vim /etc/nova/nova.conf
[scheduler]
discover_hosts_in_cells_interval = 300