#=============================== XEN虚拟机复制 ==============================
#关闭运行中的虚拟机
xm shutdown web_001
#复制虚拟机的镜像文件和配置文件
cp /data/vm/web_001.img /data/vm/web_002.img
cp /etc/xen/web_001 /etc/xen/web_002
#修改新复制虚拟机的配置文件
vi /etc/xen/web_002
#原内容为:
name = "web_001"
uuid = "21e3bccf-4778-747e-c3b7-a87cadfa29fa"
maxmem = 512
memory = 512
vcpus = 1
bootloader = "/usr/bin/pygrub"
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
disk = [ "tap:aio:/data/vm/web_001.img,xvda,w" ]
vif = [ "mac=00:16:36:64:98:f1,bridge=xenbr0,script=vif-bridge" ]
#修改后的内容为:
name = "web_002"
uuid = "21e3bccf-4778-747e-c3b7-a87cadfa29fd"
maxmem = 512
memory = 512
vcpus = 1
bootloader = "/usr/bin/pygrub"
on_poweroff = "destroy"
on_reboot = "restart"
on_crash = "restart"
disk = [ "tap:aio:/data/vm/web_002.img,xvda,w" ]
vif = [ "mac=00:16:36:64:98:f5,bridge=xenbr0,script=vif-bridge" ]
#保证name、uuid、mac的唯一性,还有就是disk路径
#启动并进入新复制的虚拟机
xm create -c web_002
#修改主机名
vi /etc/hosts
将web_001修改为web_002
vi /etc/sysconfig/network
将web_001修改为web_002
#修改IP
vi /etc/sysconfig/network-scripts/ifcfg-eth0
# Xen Virtual Ethernet
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.9.255
HWADDR=00:16:36:64:98:f5
IPADDR=192.168.9.222
NETMASK=255.255.255.0
NETWORK=192.168.9.0
ONBOOT=yes
#查看虚拟机列表及各虚拟机网络测试
xm list