目录
测试环境
OpenStack Liberty: 双节点(192.168.1.1/192.168.1.2), 后续内容中分别以 node1/node2 表示双节点.
vCenter 环境:
- VMware vCenter Server Application(192.168.1.100) 账号: root/vmware
- vCenter 层级结构:
vCenter ==> Datacenter-1(datastore1) ==> Cluster-1 ==> Host(192.168.1.3)
Nova 配置(OpenStack 纳管 vCenter 虚拟机)
使用 vCenter 驱动配置.
现阶段而言, OpenStack 对 vCenter 虚拟机的管理包括 虚拟机的创建/删除/启停/休眠/唤醒/挂起/迁移 等. 但一些高级的 vCenter 功能如 DRS/DAS 等仍然不被支持.
- node1: vim /etc/nova/nova.conf
[DEFAULT]...force_config_drive=True...config_drive_format=iso9660compute_driver=vmwareapi.VMwareVCDriver[vmware]host_ip=192.168.1.100host_username=roothost_password=vmwarecluster_name=Cluster-1datastore_regex=datastore1wsdl_location=https://192.168.1.100/sdk/vimService.wsdlinsecure=True
- node2: vim /etc/nova/nova.conf
[DEFAULT]...force_config_drive=Trueconfig_drive_format=iso9660...compute_driver=vmwareapi.VMwareVCDriver[vmware]host_ip=192.168.1.100host_username=roothost_password=vmwarecluster_name=Cluster-1datastore_regex=datastore1wsdl_location=https://192.168.1.100/sdk/vimService.wsdlinsecure=True
Glance 配置(OpenStack 纳管 vCenter 镜像)
实际上在接入 vCenter 之后, Glance 的镜像仍能够存放在本地, 但当 vCenter 需要使用这个镜像来启动一个虚拟机时, 首先会将本地的镜像文件上传到 vCenter Datastore 之后才能开始创建, 相当耗时, 所以建议将镜像文件都上传到 Datastore 中.
OpenStack 对 vCenter 镜像的管理包括: 上传/下载 等功能.
- node1: vim /etc/glance/glance-api.conf
[DEFAULT]...known_stores = vmwaredefault_store = vsphere[glance_store]stores = file,http,vmwarevmware_server_host = 192.168.1.100vmware_server_username = rootvmware_server_password = vmwarevmware_datastore_name = datastore1vmware_datacenter_path = Datacenter-1vmware_datastores = Datacenter-1:datastore1vmware_task_poll_interval = 5vmware_store_image_dir = /openstack_glancevmware_api_insecure = True
Cinder 配置(OpenStack 纳管 vCenter 块设备)
其实这里与其说是 OpenStack 纳管 vCenter 块设备 不如说是 OpenStack Cinder 为 vCenter 提供块设备功能. 换句话来说, vCenter 能够使用 Cinder 提供的 Volumes 来创建虚拟机和作为存储使用. 除此之外, Cinder 仍能保持对块存储的管理功能, 如: Volumes 的 创建/删除/快照/挂载/卸载 等. 有以下两点需要注意:
- Volumes 的挂载与卸载操作需要关闭虚拟机电源
Cinder 不支持 Volumes 的备份功能
- node1: vim /etc/cinder/cinder.conf
[DEFAULT]...default_volume_type = vmwareenabled_backends = vmware[vmware]vmware_insecure=Truevmware_host_ip=192.168.1.100vmware_host_username=rootvmware_host_password=vmwarevmware_volume_folder=Volumesvmware_wsdl_location=https://192.168.1.100/sdk/vimService.wsdlvolume_driver=cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDrivervmware_insecure = True
- node2: vim /etc/cinder/cinder.conf
[DEFAULT]...default_volume_type = vmwareenabled_backends = vmware[vmware]vmware_insecure = truevmware_host_ip=192.168.1.100vmware_host_username=rootvmware_host_password=vmwarevmware_wsdl_location=https://192.168.1.100/sdk/vimService.wsdlvolume_driver = cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDrivervmware_insecure = True
NOTE: 需要创建名为 vmware 的类型
cinder type-create vmware
Ceilometer 配置
VMware 暴露的监控最小采集频率是 300s, OpenStack Ceilometer 目前仅提供了对虚拟机的监控能力, 但能够通过其他的 vSphere API 来拿到更多 Datacenter/Cluster/Host/VirtualMachine 的 runtime information, 基本上包含了 CPU/Mem/DiskIO/网络流量 四个常规的监控对象.
- node1: vim /etc/ceilometer/ceilometer.conf
[DEFAULT]...hypervisor_inspector=vsphere[node]virt_inspector=vmware[vmware]host_ip=192.168.1.100host_username=roothost_password=vmwarewsdl_location=https://192.168.1.100/sdk/vimService.wsdlinsecure=True[service_credentials]# 如果是多region,请更改下面配置项#os_region_name =
- node2: vim /etc/ceilometer/ceilometer.conf
[DEFAULT]...hypervisor_inspector=vsphere[node]virt_inspector=vmware[vmware]host_ip=192.168.1.100host_username=roothost_password=vmwarewsdl_location=https://192.168.1.100/sdk/vimService.wsdlinsecure=True[service_credentials]# 如果是多region,请更改下面配置项#os_region_name =
测试
- Step1: 重启相关服务
# node1 systemctl restart openstack-nova-compute.service openstack-nova-api.service openstack-nova-consoleauth.service openstack-nova-scheduler.service openstack-nova-conductor.service openstack-nova-novncproxy.servicesystemctl restart openstack-glance-api.servicesystemctl restart openstack-cinder-api.service openstack-cinder-volume.servicesystemctl restart openstack-ceilometer-collector.service openstack-ceilometer-api.service# node2systemctl restart openstack-nova-compute.service openstack-nova-api.servicesystemctl restart openstack-cinder-api.service openstack-cinder-volume.servicesystemctl restart openstack-ceilometer-collector.service openstack-ceilometer-api.service
- Step2: 尝试上传镜像文件, 在上传镜像的时候, 我们需要注意以下两点:
NOTE 1: 首先需要知道镜像文件的「disktype 和 adaptertype」, 使用指令 head -20 <vmdk_image_file>
就能够查看相关类型.
[root@seed ~]# head -20 cirros-0.3.2-i386-disk.vmdkKDMV�9��# Disk DescriptorFileversion=1CID=5350c0c0parentCID=ffffffffcreateType="monolithicSparse"# Extent descriptionRW 80325 SPARSE "cirros-0.3.2-i386-disk.vmdk"# The Disk Data Base#DDBddb.virtualHWVersion = "4"ddb.geometry.cylinders = "79"ddb.geometry.heads = "16"ddb.geometry.sectors = "63"ddb.adapterType = "ide" # adaptertype == ide���������
NOTE 2: 如果使用指令 qemu-img
将 qcow2/img 格式的镜像文件转换成 vmdk 格式镜像文件时, vmware_disktype
通常为 sparse
, 而 vmware_adaptertype
通常为 ide
, 所以相应的可以使用下面的镜像上传指令:
glance image-create \--name fanguiju-test-2 \--container-format bare \--disk-format vmdk \--property vmware_disktype="sparse" \--property vmware_adaptertype="ide" \< cirros-0.3.2-i386-disk.vmdk+--------------------+----------------------------------------------------------------------------------+| Property | Value |+--------------------+----------------------------------------------------------------------------------+| checksum | 3fd19141ff969dcb4926b610769e5ba4 || container_format | bare || created_at | 2017-04-19T08:27:25Z || direct_url | vsphere://192.168.1.100/folder/openstack_glance/70d581d4-1829-45c1-ac6c- || | ac1755da1650?dcPath=Datacenter-1&dsName=datastore1 || disk_format | vmdk || id | 70d581d4-1829-45c1-ac6c-ac1755da1650 || locations | [{"url": "vsphere://192.168.1.100/folder/openstack_glance/70d581d4-1829-45c1 || | -ac6c-ac1755da1650?dcPath=Datacenter-1&dsName=datastore1", "metadata": {}}] || min_disk | 0 || min_ram | 0 || name | fanguiju-test || owner | 1774b99ae7374d9b948fb4146fbf49fb || protected | False || size | 17104896 || status | active || tags | [] || updated_at | 2017-04-19T08:27:28Z || virtual_size | None || visibility | private || vmware_adaptertype | ide || vmware_disktype | sparse |+--------------------+----------------------------------------------------------------------------------+
PS: 建议使用测试镜像文件.
NOTE 3: 如果上传镜像文件失败, 并且通过 glance/api.log 看出为 glance_store 相关的 ERROR, 可以尝试升级 glance_store 的版本. L版管理vmware需要升级 glance-store 的步骤:
[root@seed yum.repos.d]# rpm -ivh https://repos.fedorapeople.org/repos/openstack/openstack-mitaka/rdo-release-mitaka-5.noarch.rpm[root@seed yum.repos.d]# vim rdo-release.repo[root@seed yum.repos.d]# yum makecache[root@seed yum.repos.d]# yum update python-glance-store
Datastore 创建了 openstack_glance 目录:
- Step 3: 启动虚拟机
vCenter 任务流:
在 vCenter 中启动成功:
- Step4: 创建 Cinder volumes 后能在 vCenter「虚拟机与模板」界面看到对应的 Volumes, 然后就可以使用这个 Volumes 来创建虚拟机或作为存储使用了.