本操作通常在计算节点上完成。
安装nova-kvm软件包
root@compute:~# apt install nova-compute-kvm nova-compute -y
配置nova
由于官方配置文件修改较为麻烦,这里直接创建一个新的配置文件
root@compute:~# mv /etc/nova/nova.conf /etc/nova/nova.conf.org
root@compute:~# vi /etc/nova/nova.conf
# 添加以下内容,保存退出
[DEFAULT]
# 设置控制节点IP
my_ip = 10.0.0.7
state_path = /var/lib/nova
enabled_apis = osapi_compute,metadata
log_dir = /var/log/nova
transport_url = rabbit://openstack:root@controller
[api]
auth_strategy = keystone
[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 = $state_path/tmp
[keystone_authtoken]
auth_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 = root
[placement]
auth_url = http://controller:5000
os_region_name = RegionOne
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = placement
password = root
[wsgi]
api_paste_config = /etc/nova/api-paste.ini
因为配置文件是新建的,这里把权限加回去
root@compute:~# chmod 640 /etc/nova/nova.conf
root@compute:~# chgrp nova /etc/nova/nova.conf
重启nova-compute
root@compute:~# systemctl restart nova-compute
检查虚拟化开启状态
检查虚拟化是否开启,如返回非0则为开启
root@compute:~# egrep -c '(vmx|svm)' /proc/cpuinfo
2
如果上面命令执行结果不为0,则跳过这一步,如果为0,则需要执行下面这一步
root@compute:~# vi /etc/nova/nova-compute.conf
# 找到[libvirt]这一项,将其中的virt_type修改为以下样式,没有这一项则手动添加
[libvirt]
virt_type = qemu
初始化数据库并查看服务列表
注意本操作在控制节点上运行
root@controller ~(keystone)# su -s /bin/bash nova -c "nova-manage cell_v2 discover_hosts"
查看nova服务状态
root@controller ~(keystone)# openstack compute service list
+----+------------------+------------+----------+---------+-------+----------------------------+
| ID | Binary | Host | Zone | Status | State | Updated At |
+----+------------------+------------+----------+---------+-------+----------------------------+
| 3 | nova-conductor | controller | internal | enabled | up | 2020-04-26T07:36:56.000000 |
| 4 | nova-scheduler | controller | internal | enabled | up | 2020-04-26T07:36:57.000000 |
| 5 | nova-consoleauth | controller | internal | enabled | up | 2020-04-26T07:36:54.000000 |
| 6 | nova-compute | compute | nova | enabled | up | 2020-04-26T07:36:55.000000 |
+----+------------------+------------+----------+---------+-------+----------------------------+
创建flavor,供后续创建虚机使用
root@controller ~(keystone)# openstack flavor create --id 0 --vcpus 1 --ram 2048 --disk 10 m1.small
+----------------------------+----------+
| Field | Value |
+----------------------------+----------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| disk | 10 |
| id | 0 |
| name | m1.small |
| os-flavor-access:is_public | True |
| properties | |
| ram | 2048 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 1 |
+----------------------------+----------+