KVM热迁移

KVM热迁移

  • 前情提要
hostname网卡模式ip硬盘大小
centosNAT192.168.200.10100G
kvm01桥接192.168.200.10030G
kvm02桥接192.168.200.20030G

一、环境配置

mv /etc/yum.repos.d/* /media/

vi /etc/yum.repos.d/local.repo

cat /etc/yum.repos.d/local.repo

[centos]

name=centos

baseurl=file:///mnt

gpgcheck=0

enabled=1

yum clean all && yum -y install rpcbind nfs-utils *qemu* *virt*

yum -y group install gnome-desktop

systemctl disable firewalld --now;setenforce 0

sed -i 's/SELINUX=enforcing/SELINUX=disabled' /etc/selinux/config

systemctl start libvirtd && systemctl enable libvirtd

#nmcli g hostname centos;su -
#以上搭建好桌面环境

二、Kvm虚拟机搭建以及NFS共享目录

#Kvm虚拟机搭建鼠标点击一下即可,这里讲一下NFS共享目录搭建(在虚拟机上搭建)

vi /etc/exports

cat /etc/exports

/data/nfs *(rw,sync,no_root_squash)

mkdir -p /data/nfs

systemctl start rpcbind;systemctl start nfs

showmount -e

三、Kvm虚拟机配置

–kvm01
#这里ip,本地源就不讲了,自行配置即可

yum -y install rpcbind nfs-utils *qemu* *virt* tigervnc-server

yum -y group install gnome-desktop

systemctl disable firewalld --now;setenforce 0

sed -i 's/SELINUX=enforcing/SELINUX=disabled' /etc/selinux/config

nmcli g hostname kvm01;su -

#NFS目录挂载
systemctl start rpcbind nfs

mkdir -p /data/nfs

mount -t nfs 192.168.200.10:/data/nfs /data/nfs

echo "192.168.200.10:/data/nfs /data/nfs defaults 0 0" >> /etc/fstab

#Vnc开启
vncserver :1  #密码设置为000000
–kvm02
yum -y install rpcbind nfs-utils *qemu* *virt*

yum -y group install gnome-desktop

systemctl disable firewalld --now;setenforce 0

sed -i 's/SELINUX=enforcing/SELINUX=disabled' /etc/selinux/config

nmcli g hostname kvm02;su -

echo -e "192.168.200.100 kvm01\n192.168.200.200 kvm02" >> /etc/hosts

ssh-keygen

ssh-copy-id kvm01

scp /etc/hosts kvm01:/etc/hosts

#NFS目录挂载
systemctl start rpcbind nfs

mkdir -p /data/nfs

mount -t nfs 192.168.200.10:/data/nfs /data/nfs

echo "192.168.200.10:/data/nfs /data/nfs defaults 0 0" >> /etc/fstab

四、Kvm热迁移

–kvm01
virsh pool-create-as --name nfs --type dir --target /data/nfs

cd /data/nfs

#此前需将Centos1511传到/data/nfs下(可以用scp,也可以用ssh)

qemu-img create -f qcow2 centos.qcow2 10G

virt-install --name=centos --vcpus=2 --disk=centos.qcow2 --ram=512 --cdrom=CentOS-7-x86_64-DVD-1511.iso --graphics vnc --os-type=linux

#将虚拟机安装好
–热迁移
#开启virt-manager

#点击 "File" 然后点击 "Add Connection..."添加kvm02

#然后右击 centos ,点击 "Migrate" ,将虚拟机迁移到kvm02上
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值