配置nova-compute在不同的hypervisors上使用不同的存储后端

说明:
主参考:https://www.sunmite.com/openstack/use-local-storage-for-different-hypervisors.html

在控制节点上执行

1.配置nova调度程序支持AggregateInstanceExtraSpecsFilter过滤算法

openstack-config –set /etc/nova/nova.conf DEFAULT scheduler_default_filters RetryFilter,AvailabilityZoneFilter,RamFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter,AggregateInstanceExtraSpecsFilter
systemctl restart openstack-nova-scheduler.service

2.创建两个主机集合,包含ceph compute nodes 和 local storage compute nodes

nova aggregate-create ephemeral-compute-storage
nova aggregate-create ceph-compute-storage

3.查看计算节点的名称

source ~/admin-openrc
nova hypervisor-list
得到四台主机:
compute-1.ideal.yfb0801800.islab.net.cn
compute-2.ideal.yfb0801800.islab.net.cn
compute-3.ideal.yfb0801800.islab.net.cn
compute-4.ideal.yfb0801800.islab.net.cn

4.分别添加主机到不同的主机集合(一台主机只能添加到一个主机集合中)

nova aggregate-add-host ephemeral-compute-storage compute-1.ideal.yfb0801800.islab.net.cn
nova aggregate-add-host ephemeral-compute-storage compute-2.ideal.yfb0801800.islab.net.cn
nova aggregate-add-host ephemeral-compute-storage compute-3.ideal.yfb0801800.islab.net.cn
nova aggregate-add-host ceph-compute-storage compute-4.ideal.yfb0801800.islab.net.cn

5.为主机集合创建新的metadata

nova aggregate-set-metadata ephemeral-compute-storage ephemeralcomputestorage=true
nova aggregate-set-metadata ceph-compute-storage cephcomputestorage=true

6.为使用本地存储和ceph存储的虚拟机创建flavor

openstack flavor create –vcpus 2 –ram 4096 –disk 40 m1.ephemeral-compute-storage
openstack flavor create –vcpus 2 –ram 4096 –disk 40 m1.ceph-compute-storage

7.为flavor绑定指定的属性

nova flavor-key m1.ceph-compute-storage set aggregate_instance_extra_specs:cephcomputestorage=true
nova flavor-key m1.ephemeral-compute-storage set aggregate_instance_extra_specs:ephemeralcomputestorage=true

在计算节点上执行

1.本地存储配置

nova默认支持,无需配置。为了支持迁移可以配置共享存储(NFS等)

如果刚安装了cinder还没有配置nova的话,此时创建虚拟机时一定要如图所示那样,选择否。如果不选择否的话,虚拟机无法创建出来,因为cinder创建了卷,而nova却无法将其附加在libvirt上。

image

提供一下,一些可能有用的配置:

#单位是M
openstack-config –set /etc/nova/nova.conf libvirt file_backed_memory  1048576
openstack-config –set /etc/nova/nova.conf libvirt disk_cachemodes “file=directsync,block=none”
systemctl restart openstack-nova-compute && systemctl status openstack-nova-compute

2.ceph存储配置

编辑计算节点的 /etc/nova/nova.conf 文件加入修改以下选项,然后重启nova-compute服务(这里没有详细写,例如导入secret-uuid等操作请自行添加)
vim /etc/nova/nova.conf
[libvirt]
images_type = rbd
images_rbd_pool = vms
images_rbd_ceph_conf = /etc/ceph/ceph.conf
rbd_user = cinder
rbd_secret_uuid =20c3fd98-2bab-457a-b1e2-12e50dc6c98e
disk_cachemodes=”network=writeback”
inject_partition=-2
inject_key=False
live_migration_flag=VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_PERSIST_DEST

systemctl restart openstack-nova-compute.service

版权声明:本文为jipinglong原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/jipinglong/p/11222464.html