Nova是OpenStack中最核心的组件,它负责根据需求提供虚拟机服务并管理虚拟机生命周期,包括虚拟机创建、虚拟机调度和热迁移等。
Nova的子组件包括nova-api、nova-compute、nova-scheduler、nova-conductor、nova-db、nova-console等等。
本文介绍Nova安装步骤,Nova需在控制节点和计算节点安装安装。
在按照本教程安装之前,请确保完成以下配置:
【Openstack Train安装】三、openstack安装
【Openstack Train安装】四、MariaDB/RabbitMQ 安装
【Openstack Train安装】五、Memcached/Etcd安装
【Openstack Train安装】六、Keystone安装
【Openstack Train安装】八、placement安装
安装环境如下
|--------------------|------------|
| VMware Workstation | V17.0 |
| 本机系统 | win11 |
| 虚拟机系统 | CentOS 7.5 |
一、控制节点配置
以下步骤在controller节点操作。
1、创建数据库
进入数据库控制台:
bash
mysql -u root -p
创建数据库:
bash
CREATE DATABASE nova_api;
CREATE DATABASE nova;
CREATE DATABASE nova_cell0;
授予权限并退出:
bash
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';
如下图:
2、创建用户和服务
登录admin账户:
bash
. admin-openrc
在domain:default创建用户nova(密码:123456):
bash
openstack user create --domain default --password-prompt nova
如下图:
添加admin权限给project:service,user:nova:
bash
openstack role add --project service --user nova admin
创建nova服务入口:
bash
openstack service create --name nova --description "OpenStack Compute" compute
创建计算服务的API端点:
bash
openstack endpoint create --region RegionOne compute public http://controller:8774/v2.1
openstack endpoint create --region RegionOne compute internal http://controller:8774/v2.1
openstack endpoint create --region RegionOne compute admin http://controller:8774/v2.1
结果如下:
3、安装并配置nova
安装包:
bash
yum install openstack-nova-api openstack-nova-conductor openstack-nova-novncproxy openstack-nova-scheduler -y
备份并删除 /etc/nova/nova.conf
的注释:
bash
mv /etc/nova/nova.conf /etc/nova/nova.conf.source
cat /etc/nova/nova.conf.source | grep -Ev "^#|^$" > /etc/nova/nova.conf
编辑/etc/nova/nova.conf,进行以下配置:
bash
[DEFAULT]
# ...
enabled_apis = osapi_compute,metadata
my_ip = 10.0.0.11
transport_url = rabbit://openstack:123456@controller:5672/
use_neutron = true
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[api_database]
# ...
connection = mysql+pymysql://nova:123456@controller/nova_api
[database]
# ...
connection = mysql+pymysql://nova:123456@controller/nova
[api]
# ...
auth_strategy = keystone
[keystone_authtoken]
# ...
www_authenticate_uri = http://controller:5000/
auth_url = http://controller:5000/
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = nova
password = 123456
[vnc]
# ...
enabled = true
server_listen = $my_ip
server_proxyclient_address = $my_ip
[glance]
# ...
api_servers = http://controller:9292
[oslo_concurrency]
# ...
lock_path = /var/lib/nova/tmp
[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 = 123456
同步数据库:
bash
su -s /bin/sh -c "nova-manage api_db sync" nova
创建cell0数据库:
bash
su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
创建cell:cell1:
bash
su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
同步nova数据库:
bash
su -s /bin/sh -c "nova-manage db sync" nova
确认cell0和cell1注册成功:
bash
su -s /bin/sh -c "nova-manage cell_v2 list_cells" nova
如下图:
设置开机自启,并启动服务:
bash
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
控制节点配置结束。
二、计算节点配置
在compute节点进行以下操作。
安装nova-compute:
bash
yum install openstack-nova-compute -y
备份并删除 /etc/nova/nova.conf
的注释:
bash
mv /etc/nova/nova.conf /etc/nova/nova.conf.source
cat /etc/nova/nova.conf.source | grep -Ev "^#|^$" > /etc/nova/nova.conf
对/etc/nova/nova.conf进行以下配置:
bash
[DEFAULT]
# ...
enabled_apis = osapi_compute,metadata
transport_url = rabbit://openstack:123456@controller
my_ip = 10.0.0.31
use_neutron = true
firewall_driver = nova.virt.firewall.NoopFirewallDriver
[api]
# ...
auth_strategy = keystone
[keystone_authtoken]
# ...
www_authenticate_uri = http://controller:5000/
auth_url = http://controller:5000/
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = nova
password = 123456
[vnc]
# ...
enabled = true
server_listen = 0.0.0.0
server_proxyclient_address = $my_ip
novncproxy_base_url = http://controller:6080/vnc_auto.html
[glance]
# ...
api_servers = http://controller:9292
[oslo_concurrency]
# ...
lock_path = /var/lib/nova/tmp
[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 = 123456
查看计算节点是否支持虚拟化加速(大于0就是支持):
bash
egrep -c '(vmx|svm)' /proc/cpuinfo
在/etc/nova/nova.conf添加以下内容(官方文档中写道:如果上一步的值大于0则不用进行配置,但是实测不配置可能后续镜像加载出现问题,建议配置):
bash
[libvirt]
# ...
virt_type = qemu
设置开机自启,并启动该服务:
bash
systemctl enable libvirtd.service openstack-nova-compute.service
systemctl start libvirtd.service openstack-nova-compute.service
三、将计算节点添加到数据库
在控制节点运行以下命令:
bash
. admin-openrc
openstack compute service list --service nova-compute
如下图:
寻找计算节点:
bash
su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova
如下图:
当有新的计算节点要添加时,要手动在控制节点使用命令"nova-manage cell_v2 discover_hosts"来添加计算节点,也可以对/etc/nova/nova.conf进行以下配置,使得控制节点定时搜索计算节点:
bash
[scheduler]
discover_hosts_in_cells_interval = 300
四、验证
在控制节点进行以下操作:
bash
. admin-openrc
查看计算服务列表:
bash
openstack compute service list
如下所示:
查看端点列表:
bash
openstack catalog list
如下图:
查看镜像列表:
bash
openstack image list
如下图:
检查cell和placement API状态:
bash
nova-status upgrade check
如下图:
计算服务(Nova)配置完成。