【Openstack Train安装】九、Nova安装

Nova是OpenStack中最核心的组件,它负责根据需求提供虚拟机服务并管理虚拟机生命周期,包括虚拟机创建、虚拟机调度和热迁移等。

Nova的子组件包括nova-api、nova-compute、nova-scheduler、nova-conductor、nova-db、nova-console等等。

本文介绍Nova安装步骤,Nova需在控制节点和计算节点安装安装。

在按照本教程安装之前,请确保完成以下配置:

【Openstack Train安装】一、虚拟机创建

【Openstack Train安装】二、NTP安装

【Openstack Train安装】三、openstack安装

【Openstack Train安装】四、MariaDB/RabbitMQ 安装

【Openstack Train安装】五、Memcached/Etcd安装

【Openstack Train安装】六、Keystone安装

【Openstack Train安装】七、glance安装

【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)配置完成。

相关推荐
終不似少年遊*4 天前
云计算HCIP-OpenStack01
云原生·云计算·学习笔记·openstack·hcip·虚拟化
終不似少年遊*7 天前
云计算HCIP-OpenStack03
linux·网络·云原生·云计算·学习笔记·openstack·hcip
終不似少年遊*7 天前
云计算HCIP-OpenStack02
云原生·云计算·学习笔记·openstack·hcip
終不似少年遊*7 天前
云计算HCIP-OpenStack04
云原生·云计算·学习笔记·openstack·hcip·虚拟化
終不似少年遊*8 天前
华为云(openstack)常用命令行
linux·服务器·网络·华为云·云计算·操作系统·openstack
ZVAyIVqt0UFji15 天前
openstack内部rpc消息通信源码分析
网络·网络协议·rpc·openstack
four-hour20 天前
openstack 报错合集
openstack
葡萄爱23 天前
构建高可用系统设计OpenStack、Docker、Mesos和Kubernetes(简称K8s)
docker·kubernetes·openstack
four-hour24 天前
四:工具、环境准备-compute node
linux·ubuntu·openstack
胖胖不胖、1 个月前
解决:Openstack创建实例进入控制台报错Something went wrong, connection is closed
linux·服务器·openstack