安装参考:https://docs.openstack.org/nova/rocky/install/controller-install-rdo.html
一、创建数据库并授权
MariaDB [(none)]> CREATE DATABASE nova_api;
MariaDB [(none)]> CREATE DATABASE nova;
MariaDB [(none)]> CREATE DATABASE nova_cell0; #证书相关的库
MariaDB [(none)]> CREATE DATABASE placement; #计算资源统计库
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_api.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'localhost' IDENTIFIED BY 'NOVA_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nova_cell0.* TO 'nova'@'%' IDENTIFIED BY 'NOVA_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'localhost' IDENTIFIED BY 'PLACEMENT_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON placement.* TO 'placement'@'%' IDENTIFIED BY 'PLACEMENT_DBPASS';
二、创建用户nova,给nova用户设置admin角色的权限,创建服务(名称nova,类型为compute),创建服务端点
[root@mon01 ~]# . keystone_admin
[root@mon01 ~]# openstack user create --domain default --password=nova nova #创建nova用户,密码为nova
[root@mon01 ~]# openstack role add --project service --user nova admin
[root@mon01 ~]# openstack service create --name nova --description "OpenStack Compute" compute
[root@mon01 ~]# openstack endpoint create --region RegionOne compute public http://mon01:8774/v2.1
[root@mon01 ~]# openstack endpoint create --region RegionOne compute internal http://mon01:8774/v2.1
[root@mon01 ~]# openstack endpoint create --region RegionOne compute admin http://mon01:8774/v2.1
#创建用户palcement(收集计算资源使用了多少,服务资源统计)并设置admin权限,创建placement服务和服务端点
[root@mon01 ~]# openstack user create --domain default --password=placement placement
[root@mon01 ~]# openstack role add --project service --user placement admin
[root@mon01 ~]# openstack service create --name placement --description "Placement API" placement
[root@mon01 ~]# openstack endpoint create --region RegionOne placement public http://mon01:8778
[root@mon01 ~]# openstack endpoint create --region RegionOne placement internal http://mon01:8778
[root@mon01 ~]# openstack endpoint create --region RegionOne placement admin http://mon01:8778
[root@mon01 ~]# openstack catalog list 查看各个服务的端点信息
三、安装和配置组件
[root@mon01 ~]# yum install openstack-nova-api openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler openstack-nova-placement-api -y
编辑配置文件 /etc/nova/nova.conf,内容如下
[DEFAULT] enabled_apis = osapi_compute,metadata transport_url = rabbit://openstack:admin@mon01 my_ip = 192.168.43.120 use_neutron = true firewall_driver = nova.virt.firewall.NoopFirewallDriver [api] auth_strategy = keystone [api_database] connection = mysql+pymysql://nova:NOVA_DBPASS@mon01/nova_api [barbican] [cache] [cells] [cinder] [compute] [conductor] [console] [consoleauth] [cors] [database] connection = mysql+pymysql://nova:NOVA_DBPASS@mon01/nova [devices] [ephemeral_storage_encryption] [filter_scheduler] [glance] api_servers = http://mon01:9292 [guestfs] [healthcheck] [hyperv] [ironic] [key_manager] [keystone] [keystone_authtoken] auth_url = http://mon01:5000/v3 memcached_servers = mon01: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://mon01:5000/v3 username = placement password = placement [placement_database] connection = mysql+pymysql://placement:PLACEMENT_DBPASS@mon01/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 = $my_ip server_proxyclient_address = $my_ip [workarounds] [wsgi] [xenserver] [xvp] [zvm]
编辑配置文件/etc/httpd/conf.d/00-nova-placement-api.conf,加入下列代码
<Directory /usr/bin> <IfVersion >= 2.4> Require all granted </IfVersion> <IfVersion < 2.4> Order allow,deny Allow from all </IfVersion> </Directory>
#重启httpd服务
[root@mon01 ~]# systemctl restart httpd
#同步数据到数据库
[root@mon01 ~]# su -s /bin/sh -c "nova-manage api_db sync" nova
[root@mon01 ~]# su -s /bin/sh -c "nova-manage cell_v2 map_cell0" nova
[root@mon01 ~]# su -s /bin/sh -c "nova-manage cell_v2 create_cell --name=cell1 --verbose" nova
[root@mon01 ~]# su -s /bin/sh -c "nova-manage db sync" nova
[root@mon01 ~]# su -s /bin/sh -c "nova-manage cell_v2 list_cells" nova
#设置开机自启动,启动服务
[root@mon01 ~]# systemctl enable openstack-nova-api.service openstack-nova-consoleauth openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
systemctl start openstack-nova-api.service openstack-nova-consoleauth openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.service
四、安装和配置计算节点
[root@mon01 yum.repos.d]# yum install openstack-nova-compute -y
如果报错 qemu-kvm-rhev >= 2.10.0
解决办法:
在CentOS-Base.repo文件末尾添加如下内容:
[Virt] name=CentOS-$releasever - Base baseurl=http://mirrors.aliyun.com/centos/7.9.2009/virt/x86_64/kvm-common/ gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
编辑 /etc/nova/nova.conf
控制节点配置计算节点只需要修改
[vnc] # ... enabled = true server_listen = 0.0.0.0 server_proxyclient_address = $my_ip novncproxy_base_url = http://mon01:6080/vnc_auto.html
五、查看是否支持虚拟化,并配置虚拟模块
egrep -c '(vmx|svm)' /proc/cpuinfo #如果输出值大于1,则支持虚拟化
修改 /etc/nova/nova.conf
[libvirt]
# ...
virt_type = qemu
[root@mon01 ~]# systemctl enable libvirtd.service openstack-nova-compute.service
[root@mon01 ~]# systemctl start libvirtd.service openstack-nova-compute.service
六、把计算节点添加到cell库
[root@mon01 ~]# openstack compute service list --service nova-compute
[root@mon01 ~]# openstack hypervisor list
[root@mon01 ~]# su -s /bin/sh -c "nova-manage cell_v2 discover_hosts --verbose" nova
添加新的计算节点,可以配置/etc/nova/nova.conf,自动发现
[scheduler] discover_hosts_in_cells_interval = 300