我们的云计算头结点这周到货了,采用的是 Dell PowerEdge R710,Intel Xeon CPU E5645 @2.40GHz (12 Cores), 4x300GB SAS (15K), 96GB 内存。这样的配置对于我们的头结点来说过于强大,我们可能考虑用 VMware ESXi 虚拟后用其中的一台虚拟机做 OpenStack/OpenNebula 头结点,用 VMware ESXi 有个问题,免费版本的 VMware ESXi 5.0 虚拟出来的单台虚拟机最多只能支持8核心,而这台服务器逻辑上有24核心,有点浪费。图片最上面的是头结点(Dell PowerEdge R710),中间的是计算结点(Dell PowerEdge M710HD),最下面的是存储。
OpenStack 几乎支持现在所有主流的虚拟技术和 Hypervisor,如 KVM, Hyper-V, LXC, QEMU, UML, VMWare ESX/ESXi, Xen/XenServer 等,未来还会支持 OpenVZ 和 VirtualBox. 不过 OpenStack 首选的 Hypervisor 是 KVM,OpenStack 安装后默认使用的是 KVM (–libvirt_type=kvm),不需要特别配置。如果由于某种原因,比如服务器 CPU 不支持 Intel VT-x/AMD-V 不能使用 KVM 或者想简单尝试一下另外一种 Hypervisor 怎么办呢?方法很容易,1、更改 OpenStack Nova 的配置文件(–libvirt_type);2、给所有的 Compute 结点装上相应的 Hypervisor 就可以了。以下以 LXC 为例来说明如何更换 OpenStack Nova 的 Hypervisor,LXC 使用的是与 Xen 和 KVM 完全不同的虚拟技术,和 OpenVZ 的容器技术有点类似。
首先在所有 openstack nova compute 结点上替换现有的 nova-compute-kvm 到 nova-compute-lxc:
$ sudo apt-get install nova-compute-lxc
LXC 使用 cgroup 文件系统来限制资源和进程,libvirt 需要 cgroup 文件系统来运行 LXC,我们只要在 nova compute 上创建一个 ctroups 目录并且在 /etc/fstab 最后加上 none /cgroups cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0 这行就可以了,别忘了重启系统:
$ sudo mkdir /cgroups
$ vi /etc/fstab
none /cgroups cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0
$ sudo reboot
重启后可以看到 /cgroups 下面多了很多东西:
$ ls /cgroup/
blkio.io_merged cpu.shares
blkio.io_queued devices.allow
blkio.io_service_bytes devices.deny
blkio.io_serviced devices.list
blkio.io_service_time libvirt
blkio.io_wait_time memory.failcnt
blkio.reset_stats memory.force_empty
blkio.sectors memory.limit_in_bytes
blkio.throttle.io_service_bytes memory.max_usage_in_bytes
blkio.throttle.io_serviced memory.memsw.failcnt
blkio.throttle.read_bps_device memory.memsw.limit_in_bytes
blkio.throttle.read_iops_device memory.memsw.max_usage_in_bytes
blkio.throttle.write_bps_device memory.memsw.usage_in_bytes
blkio.throttle.write_iops_device memory.move_charge_at_immigrate
blkio.time memory.numa_stat
blkio.weight memory.oom_control
blkio.weight_device memory.soft_limit_in_bytes
cgroup.clone_children memory.stat
cgroup.event_control memory.swappiness
cgroup.procs memory.usage_in_bytes
cpuacct.stat memory.use_hierarchy
cpuacct.usage notify_on_release
cpuacct.usage_percpu release_agent
cpu.rt_period_us tasks
cpu.rt_runtime_us
修改 OpenStack Nova 配置,将 nova-compute.conf 里面的 –libvirt_type=kvm 改成 lxc:
$ sudo vi /etc/nova/nova-compute.conf
--libvirt_type=lxc
$ sudo restart nova-compute
重启所有 nova compute 结点上的 nova-compute 服务,有必要的话重启所有 nova compute 结点。
那镜像怎么办呢?以前为 KVM 上传的镜像也可以用在 LXC 上吗?嗯,可以。下载 oneiric-server-cloudimg-amd64.tar.gz 解压并镜像到 OpenStack:
$ wget
$ tar zxvf oneiric-server-cloudimg-amd64.tar.gz