一、openstack架构
确保iptables和selinux都是关闭状态
确保3台机器的/etc/hosts文件都包含如下内容:
10.40.30.65 compute65
10.40.30.64 compute64
10.40.30.60 control60
二、在控制节点上安装nfs-server
apt-get install nfs-kernel-server
在/etc/exports中加入
/var/lib/nova/instances 10.40.30.0/24(rw,nohide,insecure,sync,no_root_squash)
参数解释:
rw – 可读写
nohide - 如果被挂载的目录下的其他目录也是挂载的,此选项将使它们可见
insecure – 允许客户端不使用保留端口
sync - 每次写操作要同步到物理存储器上(而不是仅写入内存)
no_root_squash – 当客户端以root的UID/GID(=0)挂载时,不会分配一个匿名UID/GID(也就是说它创建的文件将属于root)
注意:必须保持控制节点和计算机节点上nova用户的uid和gid一致,否则会失败。
方法一:可以通过修改计算机节点上/etc/passwd和/etc/shadow文件,保持nova的uid和gid和控制节点的一致。如果你这样修改的话,很多目录权限需要重新赋予。
方法二:使用idmap映射用户的uid/gid。参照http://longgeek.com/2012/07/18/nfs4-idmap-mappings-are-used-in-the-users-uidgid/
三、在计算机节点上挂载共享目录
编辑/etc/fstab文件,添加如下内容:
10.40.30.60:/var/lib/nova/instances /var/lib/nova/instances nfs4 _netdev,auto 0 0
挂载到本地
mount -a -v
四、在计算机节点上配置libvirt
修改:/etc/libvirt/libvirtd.conf
before : #listen_tls = 0
after : listen_tls = 0
before : #listen_tcp = 1
after : listen_tcp = 1
add: auth_tcp=”none”
修改:/etc/init/libvirt-bin.confbefore : exec /usr/sbin/libvirtd -d
after : exec /usr/sbin/libvirtd -d -l
修改:/etc/default/libvirt-binbefore :libvirtd_opts=” -d”
after :libvirtd_opts=” -d -l”
修改:/etc/libvirt/qemu.conf去掉下面三行注释
vnc_listen = “0.0.0.0″
user = “root”
group = “root”
重新启动libvirt-binservice libvirt-bin restart
五、测试在线迁移
nova live-migration e11f0350-dd5e-46b1-b029-156411756000 compute64
六、遇到的问题
- 创建的虚拟机全部在控制节点上
原因:原来是计算机节点上的cpu没有启动VT功能,重启修改bios后正常。可通过kvm-ok 进行查看。
- Failed to connect to remote libvirt URI qemu+tcp://compute64/system
查看compute64的libvirt是否配置正确,可查看/var/log/libvirt/libvirtd.log;
lsof -i :16509 查看端口是否处于监听状态