Xenserver中的虚拟机导出,然后导入到另一台Xenserver。

两台运行Xenserver的服务器分别为Dell R710(导出)、IBM x3650(导入),导出文件临时存储的设备为移动硬盘一块。

1、关闭你要导出的虚拟机,利用XenCenter关闭或者直接在Xenserver的控制台里关闭。

2、移动硬盘(Xen对NTFS格式几乎无法支持,更改移动硬盘分区到Ext2或3)连接到要导出虚拟机的那台Xenserver上,进入CLI命令行模式,执行下面命令查看移动硬盘的设备名,可以看到/dev/sdb1  或者 sdc1,不尽相同。

fdisk -l

3、将移动硬盘挂载到/mnt/vm目录

mkdir /mnt/vm     在mnt目录中创建一个vm目录

mount /dev/sdb1 /mnt/vm          映射移动硬盘到vm目录

4、执行导出命令,导出完成后会提示successful。

xe vm-export vm=虚拟机名         filename=/mnt/vm/虚拟机名.xva

5、导入到另一台Xenserver中,执行2-3步骤,执行导出命令。

xe vm-import       filename=/mnt/vm/虚拟机的名字.xva


注:虚拟机名可以在XenCenter中看到,XenCenter的Log界面可以查看导入的进程。

xenserver backup + restore

Citrix XenServer has a number of ways to backup your VMs from the server and onto another location. A simple Export of a vm creates a conveinient Xenserver Virtual Appliance [.XVA file]. From here you can import this xva into any other XenServer host, and bring it back to life.

metadata

The metadata for a Virtual machine contains info about the VM, such as Name, Description and UUID [universally unique identifier]. Also the VM configuration, such as number of virtual CPUs and ammount of virtual memory [RAM]. It also contains information about the use of resources on the host, or Resource Pool [such as Virtual Networks, Storage Repositories, ISO Library, etc].
Most metadata configuration data is written when the VM is created and is updated if you make changes to the VM configuration. This means that it is not always necessary to perform daily exports of all the VM metadata. Adding a metadata export command to your change-control checklist will ensure that the information is available if needed.

backup the pool metadata

Run this: xe pool-dump-database file-name=[filepath and name]
example: xe pool-dump-database file-name=/dev/mnt/dbdump
To check the target machine has an appropriate number of appropriately named NICs run this;
xe pool-restore-database file-name=[file path and name] dry-run=true
example: xe pool-restore-database file-name=/dev/mnt/dbdump dry-run=true

backup host configuration and software

To backup the pool metadata run this;
xe host-backup host=[hostname] file-name=[filepath and name.xbk]
example: xe host-backup host=xenbx1 file-name=/dev/mnt/xenbx1.xbk
NOTE: To complete a restore of this, you need to boot from the original XenServer install CD
NOTE: This data can only be restored to the original machine

imports and exports

The Export feature of XenServer is perfect for use in Disaster Recovery strategy. The exports contain all data necessary to restore and get the VM backup and running, including the vCPUs and RAM required. One thing to note is the Hard Drive sizes, there needs to be ample free space available on the intended Storage Repository for restore to be successful.

export a vm for backup purposes

Ensure that the VM is offline [turned off] and run this;
First use xe vm-list to show a list of vm’s and their UUID’s.
Then use xe vm-export vm=[vm_uuid] filename=[filepath and filename.xva]
example: xe vm-export vm=XXX…xx filename=/dev/mnt/server1.xva
To only backup the virtual machines metadata run this;
xe vm-export vm=[vm_uuid] filename=[filepath and filename.xva] –metadata
example: xe vm-export vm=XXX…XX filename=/dev/mnt/server1.xva –metadata

import a vm from backup

Make sure your backup source, if external, is mounted. Once this is confirmed perform this command for import.
First use xe sr-list to show a list of Storage Repositorys available and their UUID’s.
xe vm-import sr=[SR_UUID] filename=[filepath and filename.xva]
example: xe vm-import sr=RAID5 filename=/dev/mnt/server1.xva

create a snapshot of a vm

First Use xe vm-list to show a list of vm’s and their UUID’s.
The xe vm-snapshot vm=[vm_uuid] new-name-label=[vm snapshot name]
example: xe vm-snapshot vm=xxx…xx new-name-label=server1snap1

create a snaphot with quiesce of a vm

The XEN VSS Provider must be installed in the VM guest in order to perform a Quiesced Snapshot. To install this run: %systemdrive%Program FilesCitrixXenToolsinstall-XenProvider.cmd
Quiesced snapshots take advantage of the Windows Volume Shadow Copy Service [vss] to generate application consistent point-in-time snapshots.The VSS framework helps VSS-aware applications [such as Exchange or SQL] flush data to disk and prepare for the snapshot to be taken. Xenserver supports Quiesced snapshots on Windows 2003 and Server 2008 for both 32 and 64bit variants. Windows 2000, XP and Vista are unsupported. To create the snapshot;
First use xe vm-list to show a list of vm’s and their UUID’s.
Then xe vm-snapshot-with-quiesce vm=[vm_uuid] new-name-label=[vm snapshot name]
example: xe vm-snapshot-with-quiesce vm=xxx…xx new-name-label=server1snapq1

create a snapshot with memory of a vm

These save a VMs storage and metadata. Snapshots with memory also save the VMs state [RAM]. Reverting back to a snapshot with memory, doesn’t require a reboot of the VM.
A snapshot with memory requires at least 4MB of disk space per disk, plus the size of the RAM, plus around 20% overhead. So a checkpoint with 256MB RAM would require approx: 300MB of storage.
First use xe vm-list to show a list of vm’s and their UUID’s.
[td]xe vm-checkpoint vm=[vm_uuid] new-name-label=[vm checkpoint name]
example: xe vm-checkpoint vm=xxx…xx new-name-label=server1snapmem1
Once XenServer has finished creating the snapshot with memory, its UUID is displayed.

list snapshots for a vm or a xenserver pool

To list all Snapshots in the XenServer pool;
xe snapshot-list
To List Snapshots on a particular VM;
First use xe vm-list to show a list of vm’s and their UUID’s.
Then xe snapshot-list snapshot-of=[vm uuid]
example: xe snapshot-list snapshot-of=xxx…xx

restore a vm to a previous state

Use these commands to restore a VM using a Snapshot or Checkpoint. Note: It is possible to revert to any snapshot or checkpoint in time, forwards or backwards. Existing snapshots and checkpoints are not deleted during a revert.
First use xe snapshot-list to show a list of Snapshots or Checkpoints and their UUID’s
Then xe snapshot-revert snapshot-uuid=[Snapshot uuid]
example: xe snapshot-revert snapshot-uuid=xxx…xx

deleting a snapshot or checkpoint

First use xe snapshot-list to show a list of Snapshots or Checkpoints and their UUID’s
The xe snapshot-uninstall snapshot-uuid=[Snapshot uuid]
example: xe snapshot-uninstall snapshot-uuid=xxx…xx
A confirmation is displayed for the deletion, type YES to confirm.
If you only want to delete the metadata for the snapshot or checkpoint, run this;
xe snapshot-destroy snapshot-uuid=[Snapshot uuid]
example: xe snapshot-destroy snapshot-uuid=xxx…xx

1. 备份和还原pool中的metadata:

备份命令: xe pool-dump-database file-name=[filepath and name]
例子: xe pool-dump-database file-name=/dev/mnt/dbdump

还原命令:xe pool-restore-database file-name=[file path and name] dry-run=true
例子: xe pool-restore-database file-name=/dev/mnt/dbdump dry-run=true

2. 备份和还原xenserver host系统:

备份命令:xe host-backup host=[hostname] file-name=[filepath and name.xbk]
例子: xe host-backup host=xenbx1 file-name=/dev/mnt/xenbx1.xbk

注意:还原系统重启xenserver,从xenserver安装盘启动,选择“Restore from backup”,而且只能换到本机

3. 备份和还原xenserver vm虚拟机:
(1). 导出vm所有数据
       a. 关闭vm
       b. 用xe vm-list,获取vm的uuid
       c. 执行命令进行导出vm所有数据:
       xe vm-export vm=[vm_uuid] filename=[filepath and filename.xva]
      如:xe vm-export vm=XXX…xx filename=/dev/mnt/server1.xva

      如果只是导出metadata,则
      xe vm-export vm=[vm_uuid] filename=[filepath and filename.xva] –metadata
      如: xe vm-export vm=XXX…XX filename=/dev/mnt/server1.xva –metadata

(2). 导入vm
     xe vm-import sr=[SR_UUID] filename=[filepath and filename.xva]
     如: xe vm-import sr=RAID5 filename=/dev/mnt/server1.xva

4.  创建vm快照snapshot:
xe vm-snapshot vm=[vm_uuid] new-name-label=[vm snapshot name]
如: xe vm-snapshot vm=xxx…xx new-name-label=server1snap1

更多可见
http://druku.net/xenbup.html
http://docs.vmd.citrix.com/XenSe … b/installation.html

XenServer中VM的存储格式对空间以及性能的影响  http://xenme.com/1133


XenServer中虚拟机导出与导入

1. 备份和还原pool中的metadata:

备份命令: xe pool-dump-database file-name=[filepath and name]
例子: xe pool-dump-database file-name=/dev/mnt/dbdump

还原命令:xe pool-restore-database file-name=[file path and name] dry-run=true
例子: xe pool-restore-database file-name=/dev/mnt/dbdump dry-run=true

2. 备份和还原xenserver host系统:

备份命令:xe host-backup host=[hostname] file-name=[filepath and name.xbk]
例子: xe host-backup host=xenbx1 file-name=/dev/mnt/xenbx1.xbk

注意:还原系统重启xenserver,从xenserver安装盘启动,选择“Restore from backup”,而且只能换到本机

3. 备份和还原xenserver vm虚拟机:
(1). 导出vm所有数据
a. 关闭vm
b. 用xe vm-list,获取vm的uuid
c. 执行命令进行导出vm所有数据:
xe vm-export vm=[vm_uuid] filename=[filepath and filename.xva]
如:xe vm-export vm=XXX…xx filename=/dev/mnt/server1.xva

如果只是导出metadata,则
xe vm-export vm=[vm_uuid] filename=[filepath and filename.xva] –metadata
如: xe vm-export vm=XXX…XX filename=/dev/mnt/server1.xva –metadata

(2). 导入vm
xe vm-import sr=[SR_UUID] filename=[filepath and filename.xva]
如: xe vm-import sr=RAID5 filename=/dev/mnt/server1.xva

4. 创建vm快照snapshot:
xe vm-snapshot vm=[vm_uuid] new-name-label=[vm snapshot name]
如: xe vm-snapshot vm=xxx…xx new-name-label=server1snap1

发表评论

电子邮件地址不会被公开。 必填项已用*标注