Diapositiva 1

Introducing XenServer 2/2
Monforte Salvatore
CCR – Virtualization Tutorial
Catania 1-3 December 2010
XenServer Backups
Backups
• it might be very useful to backup your VMs running on a Citrix XenServer Host/Pool
• there are several ways to perform VMs backups
▫ at a very high-level there are basically two categories of backups
 cold backups
▫ VMs should be offline before taking the backup
 hot backups
▫ VMs can be backed up without incurring in any downtime
•
In addition XenServer provides commands for backing-up/restore
▫ host configuration
xe host-backup file-name=<host backup>
▫xe pool
configuration
host-restore
file-name=<host backup>
xe pool-dump-database file-name=<pool metadata backup>
xe pool-restore-database file-name=<pool metadata backup> --dry-run
XenServer Backups
Cold VM Backups
• Ensure that the VM to be backed up is offline
• Run the command
xe vm-export vm=<vm_uuid> file-name=<backup>
▫ this backup also backs up all of the VM's data
 when importing a VM, you can specify the storage mechanism to use for the
backed up
▫ this process backs up all of the VM data
 it can take some time to complete
•
In addition it is possible to backup only VM metadata
▫ Running the command
xe vm-export vm=<vm_uuid> file-name=<backup> --metadata
XenServer Backups
Full metadata backup and disaster recovery
• Full metadata backups are based on the concept of Portable Storage Repositories
(Portable SRs)
▫ contain all of the information necessary to recreate all the Virtual Machines (VMs)
with Virtual Disk Images (VDIs) stored on the XenServer hosts and resource pools
SR after re-attaching the SR to a different host or pool
• Portable SRs work by creating a dedicated metadata VDI within the specified SR
▫ this metadata VDI is used to store
 copies of the pool and host database
 metadata describing each VM's configuration
▫ as a result the SR becomes fully self-contained, or portable, allowing it to be
detached from one host and re-attached to another as a new SR.
 once the SR is re-attached a restore process is used to recreate all of the VMs
on the SR from the metadata VDI
• For disaster recovery the metadata backup can be scheduled to run regularly to
ensure the metadata SR is updated periodically
XenServer Backups
• The text console on the XenServer host provides the
Backup, Update and Restore menu
▫ you can use these menu items to perform 3 operations
 Schedule a regular metadata backup to the default pool SR, either daily,
weekly or monthly
▫ regularly rotate metadata backups and ensure that the latest metadata is present
for that SR without any user intervention
 Trigger an immediate metadata backup to the SR of your choice
▫ will create a backup VDI if necessary, attach it to the host and backup all the
metadata to that SR
 use this option if you have made some changes which you want to see reflected in the
backup immediately
 Perform a metadata restoration operation
 prompt you to choose an SR to restore from
▫ restoring only VM records associated with that SR
▫ all the VM records found
XenServer Backups
• Create and move a portable SR using Local Console and XenCenter
▫
On the source host or pool, within the Local Console
 select the Backup, Restore, and Update menu option
 select the Backup Virtual Machine Metadata option
 select the desired SR
▫
within XenCenter
 shutdown all running VMs with VDIs on the SR to be moved
 select the SR to be moved and detach it
 select forget to remove the SR record from the source host or pool
 select the destination host/pool
 create and reattach the storage
▫
within the Local Console on the destination host
 select the Backup, Restore, and Update menu option
 select the Restore Virtual Machine Metadata option
 select the newly re-attached SR
XenServer Backups
Hot VM Backups
• Basically XenServer provides two methods for creating hot VM backups
▫ manual snapshots / exports
 through XenCenter or CLI
▫ scripted snapshots / exports
 through XenAPI or CLI
• Snapshot are templates containing storage information and VM configuration
▫ two types of VM snapshots are supported
 regular
▫ crash consistent and can be performed on all VM types, including Linux VMs
 quiesced
▫ take advantage of the Windows Volume Snapshot Service (VSS) for services that
support it, so that a supported application can flush data to disk
XenServer Snapshots
Hot VM Backups via Snapshot
• Basically XenServer provides two methods for creating hot VM backups
▫ manual snapshots / exports
 through XenCenter or CLI
▫ scripted snapshots / exports
 through XenAPI or CLI
▫ requires additional knowledge of XenAPI and CLI
• Snapshot contains storage information and VM configuration
▫ two types of VM snapshots are supported
 regular
▫ crash consistent and can be performed on all VM types, including Linux VMs.
 quiesced
▫ take advantage of the Windows Volume Snapshot Service (VSS) for services that
support it, so that a supported application can flush data to disk
XenServer Snapshots
• There are two possible locations where we can execute our scripts
▫ on the administration workstation with XenCenter installed
▫ VB Script for the logic
▫ Scheduled Tasks for the automation
 the workstation should be always on to execute scripts
 a network connection to the storage is required
▫ on the XenServer host
▫ Shell or Python scripts for the logic
▫ Linux CRONs for automation
 the XenServer is (in most cases) always on
 network connection to the storage is already in place
XenServer Snapshots
Creating Hot VM Backups via Snapshot using the CLI
• Create the Snapshot
▫ with quiesce
xe vm-snapshot-with-quiesce vm=<vm_uuid> new-name-label=<shapshot_label>
▫ regular
xe vm-snapshot vm=<vm_uuid> new-name-label=<shapshot_label>
• Remove the template flag from the Snapshot
xe template-param-set is-a-template=false uuid=<snapshot_uuid>
• Export the Snapshot to backup share
xe vm-export uuid=<snapshot_uuid> filename=<backup>.xva
• Delete Snapshot from XenServer host to save space on the SR
xe vm-unistall uuid=<vm_uuid> force=true
XenServer Snapshots
Backups / Snapshot automation
• Before getting crazy start coding have a look to what the Citrix Community provides
▫ the first interesting scripts is from Jeff Riechers
 Visual Basic Script
 published on the Citrix Community Forun
▫ http://forums.citrix.com/thread.jspa?threadID=250128&tstart=0
 very good documented and is configurable with parameters
▫ second script comes from Andy Burton
 shell script
 can be downloaded at the following URL
▫ http://www.andy-burton.co.uk/blog
 very well documented and configurable using a configuration file
 there are a lot of enhancements to this script on the Citrix Community Forum
▫ third scripts from Mark (?)
 shell script
 can be downloaded at the following URL
▫ http://www.markround.com/archives/61-Xenserver-snapshot-and-template-basedbackup-script.html
 very well documented configurable using both configuration files and custom fields
XenServer Snapshots
Understanding Snapshots
• Snapshot behavior and storage consumption is determined by the type of storage
repository (SR) used
▫ Volume-based
 iSCSI and Hardware HBA Fiber Channel and local disks
▫ File-based
 NFS
• Snapshot on Volume-based Storage Repositories
▫
▫
Consider a 20GB iSCSI storage repositories
Create a Linux VM with one 5 GB disk
 in the iSCSI SR the entire 5 GB of space required by the VDI is consumed at the time it is
provisioned
XenServer Snapshots
▫
After the snapshot is performed the storage consumption is reported as follows
▫
After deleting the snapshot the storage consumption does not change
XenServer Snapshots
•
After VM creation, the VM has one VDI of 5 GB
▫ VDI is thick provisioned and is assigned a UUID
A
•
After snapshot is created, the following steps occur
▫ VDI A contains data up to the point of the snapshot
 this VDI is deflated to conserve space
▫ UUID remapping from A to B occurs
▫ VDI B becomes the active node
▫ VDI C is empty
 except for VHD header information
5GB
UUID: 01D4…
base
A
B
1.2 GB
5GB
UUID: 01D4…
After the snapshot is deleted, the following steps occur
▫ VDI C is deleted
▫ VDI A does not change
 continues to have data up to the point of the snapshot
base
A
 even though the snapshot was technically deleted
▫
VDI B continues to be used for writes
B
active
0 GB
snapshot
active
•
C
1.2 GB
5GB
UUID: 01D4…
XenServer Snapshots
• Snapshot on File-based Storage Repositories
▫
▫
Consider a 20GB NFS storage repository
Create a Linux VM with one 5 GB disk
 in the NFS SR the 5 GB of space required by the VDI is thin provisioned
XenServer Snapshots
▫
After the snapshot is performed the storage consumption is reported as follows
▫
After deleting the snapshot the storage consumption returns back to what it was before the
snapshot was taken
XenServer Snapshots
•
•
After VM creation, the VM has one VDI of 5 GB
▫ VDI is thin provisioned and is assigned a UUID
 only the space required is actually allocated
After snapshot is created, the following steps occur
▫ VDI A contains data up to the point of the snapshot
▫ VDI B and C are empty
 except for VHD header information
▫ UUID remapping from A to B occurs
A
176 MB
UUID: 2E1F…
base
A
B
176 MB
UUID: 2E1F…
base
After the snapshot is deleted, the following steps occur
▫ VDI C is deleted
▫ VDI A does not change
 continues to have data up to the point of the snapshot
 even though the snapshot was technically deleted
▫
VDI B continues to be used for writes
 will grow over time
A
B
active
0 GB
snapshot
active
•
C
176 MB
5GB
UUID: 2E1F…
XenServer Snapshots
Coalescing scenarios
• XenServer includes the ability to collapse VDI chains
▫ eliminate redundant nodes that result from creation and
deletion of snapshots
• This process is known as coalescing
▫ occurs as a background process
base
A
base
•
C
B
Consider a VM having two snapshot
▫ VDI C and VDI E
snapshot
D
E
active
snapshot
base
A
base
base
•
A+B
When snapshot C is deleted
▫ parent B is no longer required
 will be coalesced into A
B
D
active
D
E
active
snapshot
E
snapshot
XenServer Snapshots
base
•
If the remaining snapshot E is deleted
▫ VDI B and coalesced VDI A+B remains
A+B
D
active
•
When snapshot G is subsequently taken
▫ parent D is coalesced into A+B
 three VDIs will exist for the VM at this
base
A+B
base
base
A+B+D
D
F
active
G
snapshot
F
active
G
snapshot
XenServer SDKs
SDKs
• XenServer includes a XML-RPC based API
▫ providing programmatic access to the extensive set of XenServer management
features and tools
• XenServer API can be called from a remote system as well as local to the XenServer
host
▫ remote calls are generally made securely over HTTPS
• There are five SDKs available, one for each of C, C#, Java, PowerShell, and Python
▫ provided under an open-source license
 LGPL or GPL with the common linking exception
 this allows use (unmodified) in both closed-and open-source applications
▫ http://community.citrix.com/display/xs/Download+SDKs
• There are also several example code samples also provided for download
▫ demonstrate creating a VM
▫ running VM power operations
▫ and watching for events
XenServer SDKs
XAPI objects class diagram