KVM nfs共享存储以及虚拟机动态迁移

动态迁移简要配置步骤:
1、实现两台主机无密码ssh登录,1)运行:ssh-keygen -t rsa ; 2)然后拍两下回车(均选择默认) ; 3)运行:
ssh-copy-id -i /root/.ssh/id_rsa.pub root@target_host; 4)再输入163机器上的root密码。
2、关闭源与目标主机的防火墙
(否则出现错误“Unable to migrate guest: unable to connect to
server at ‘target_addr:49152’: No route to host”)。
3、关闭Selinux
[root@host36]# grep “SELINUX=enforcing” /etc/selinux/config
SELINUX=enforcing
[root@host36 ]# sed -i ‘s/SELINUX=.*$/SELINUX=disabled/g’ /etc/selinux/config
[root@host36]# setenforce 0[root@KVM-1 ~]# getenforce
Permissive
4、源主机端打开virt-manager,Add Connection,添加对目标主机的链接。
5、在源主机创建虚拟机,并在目标主机相同的路径创建大于等于源虚拟机大小,相同格式相同名称的镜像文件(否则出现error:Unable to migrate guest: Cannot access storage file ‘/home/images/vm01.qcow2’
(as uid:107, gid:107): No such file or directory)。
6、可以使用virt-manage进行libvirtd、tcp在线迁移,如命令:virsh migrate –live –copy-storage-all vmname qemu+ssh(or tcp)😕/dest_ip/system
原文链接:https://blog.csdn.net/yu_jinyu/article/details/53083571

Kvm nfs 动态迁移常见问题以及处理
Question 1:
error: internal error hostname on destination resolved to localhost, but migration requires an FQDN
解决办法很简单,因为默认情况下hostname 是 localhost,我们需要把目标的hostname修改一下,临时的也可以。

配置主机FQDN
[root@localhost ~]# hostname --fqdn
localhost
[root@localhost ~]# sed -i “s/HOSTNAME=.*$/HOSTNAME=host36/g” /etc/sysconfig/network
[root@localhost ~]# hostname KVM-1
[root@KVM-1 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6
[root@host36 ~]# echo “192.168.117.36 host36” >> /etc/hosts
[root@host154 ~]# echo “192.168.115.154 host154” >> /etc/hosts
[root@host36 ~]# hostname --fqdn
Host36

Question 2:
error: internal error Attempt to migrate guest to the same host 00020003-0004-0005-0006-000700080009
这个在mail list 中有大牛说是服务器提供商的问题,
你可以用#dmidecode -s system-uuid 查看一下这个ID,理论上是#virsh sysinfo | grep uuid 及# virsh capabilities | grep uuid
这三个ID是一样的。(之前看论坛里发的解决方法是需要下载一个dmidecode 命令的文件去替换系统的,达到修改的目的,不过我只是修改了libvirt的配置文件就可以了,可能是版本的问题)
我们修改一下libvirtd的配置文件
#sed -i “/#host_uuid/ahost_uuid = “uuidgen”” /etc/libvirt/libvirtd.conf
重启一下libvirtd 服务

/etc/init.d/libvirtd restart

然后再查看一下

virsh capabilities | grep uuid

安装配置nfs:

1、 宿主机上安装nfs 服务端(192.168.115.155)

yum -y install rpcbind nfs-utils

2、修改共享配置文件 /etc/exports/

3、查看 cat /etc/exports

#/home/testpool 192.168.112.19 (rw,sysnc)

/home/testpool *(rw,sync,no_root_squash)

4、在客户机中访问 NFS 共享资源

安装 nfs-utils、rpcbind 软件包

rpm -q rpcbind nfs-utils

yum -y install nfs-utils rpcbind

5、启动服务

systemctl start rpcbind

6、开机启动

systemctl enable rpcbind

7、客户端创建网络共享存储

8、nfs客户端挂载

/usr/bin/mount 192.168.115.155:/home/testpool /opt/kvm-share -o nodev,nosuid,noexec

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值