XenServer 命令行工具 xe 跨宿主异地备份 vm克隆( vm-snapshot vm-copy vm-install )

注:XenServer7 是已过时的版本,但愿你用不到

xe版本

# cat /etc/redhat-release
XenServer release 7.2.0 (xenenterprise)
# rpm -qf /opt/xensource/bin/xe
xapi-xe-1.30.0-1.x86_64

组建XEN主机池

登录主机A,记录下资源池uuid:

xe pool-list

登录主机B,将B加入到主机A的资源池:
要求:

  • The host joining the pool cannot have any running VMs. #B主机不能有正在运行的虚拟机
  • The host joining the pool cannot contain any shared storage. #B主机不能有共享存储
xe pool-join master-address=主机A的IP master-username=root master-password=主机A的密码 pool-uuid=UUID
#Host agent will restart and attempt to join pool in 10.000 seconds...

执行成功后,在 A 或者 B 上查看主机列表:

xe host-list

关机状态下,基于虚机复制虚机备机

xe vm-copy name-label=虚机名 new-name-label=新虚机名

注意:vm-copy 和 vm-clone 不同。

不停机状态下,基于快照复制虚机备机

查看主机B的SR存储仓库列表,记录下LocalStorageUUID:

xe sr-list |grep -2 Local

登录主机A,对目标虚机新建快照

xe vm-snapshot name-label=虚机名 new-name-label=快照名
xe snapshot-list #查看结果
xe vm-copy name-label=快照名 new-name-label=模板名 #将快照制作成模板

用模板在 主机B 的SR上创建虚机备机

xe vm-install template-name-label=模板名 new-name-label=虚机名BAK sr-uuid=B主机的LocalStorage

xe vm-list | grep -2 虚机名  #查看结果
posted @ 2025-03-12 15:11  M1927  阅读(51)  评论(0)    收藏  举报