1 / 34

Jerome Reid

Jerome Reid . Disaster recovery and automation with XenServer. Agenda. Introduction . Backup and recovery tools. XenServer CLI basics. Sample Scripts. Agenda. Introduction . Introduction . Backup and recovery tools. Backup and recovery tools. XenServer CLI basics. Sample Scripts.

yukio
Download Presentation

Jerome Reid

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Jerome Reid Disaster recovery and automation with XenServer

  2. Agenda Introduction Backup and recovery tools XenServer CLI basics Sample Scripts

  3. Agenda Introduction Introduction Backup and recovery tools Backup and recovery tools XenServer CLI basics Sample Scripts

  4. Why backup? • Failure can result in wider impact as a result of workload consolidation • A properly designed backup plan will minimize downtime • Comprehensive backup up plan needed for Disaster recovery

  5. What can be backed up • Pool configuration database (state.db) • VM Metadata • XenServer Control Domain

  6. Pool db • Master maintains pool db • The UUIDs of all objects are tracked in the pool db • Slaves take pool db backup Master Active pool db Xen Hypervisor Xen Hypervisor Xen Hypervisor Xen Hypervisor Xen Hypervisor Xen Hypervisor Xen Hypervisor Xen Hypervisor Xen Hypervisor db RPC Passive snapshot Slaves

  7. Vm metadata • Contained within the pool db • Contains VM information: name, description, uuid • VM configuration: amount of virtual memory, virtual CPU‘s

  8. XenServer Control Domain • The privileged Control Domain that runs Xen and the XenServer agent • The Control Domain software is installed on the primary partition.

  9. Backup and recovery tools • Metadata Backup • xe-backup-metadata, xe-restore-metadata • Also available via the XenServer console (xsconsole) • Pool db backup • xe pool-dump-database , xe pool-restore-database • Vm metadata • xe vm-export --metadata, xe vm-import --metadata • XenServer Control Domain • xe host-backup

  10. backup-metadata • When a metadata backup is first taken, a special backup VDI is created on a SR. This VDI stores the following backups: • A full pool-database backup. • Individual VM metadata backups, partitioned by the SRs in which the VM has disks. • SR-level metadata which can be used to recreate the SR description when the storage is reattached. • The metadata backup and restore works at the command-line script level • Also supported in the menu-driven text console.

  11. backup-metadata • Metadata backup/restore can also be performed and scehduled via the XS console:

  12. backup-metadata • Metadata backup/restore can be run and scripted via the CLI: xe-backup-metadata,xe-restore-metadata • xe-backup-metadata provides an interface to create the backup VDIs • xe-backup-metadata -h • xe-backup-metadata -c -u <sr uuid> • xe-backup-metadata -d -u <sr uuid>

  13. Simplifying Disaster Recovery • Automated backup of VM metadata to SR • Replication of SR includes Virtual Disks and VM metadata • Attach replicated SR • Restore of VM metadata will recreate VMs 1 2 4 3 1 3 Xen Hypervisor Xen Hypervisor Xen Hypervisor Xen Hypervisor Xen Hypervisor Xen Hypervisor 4 Shared Storage Shared Storage 2 DR Site Production Site

  14. pool-dump-database • Downloads a copy of the entire pool db and dumps it into a file on the client • Only available via the CLI • xe pool-dump-database • file-name= • xe pool-restore-database • File-name= • Can be scripted and saved to a network share. See Citrix article CTX116632

  15. pool-dump-database pool-restore-database Single Host xe-toolstack-restart Pool db Xen Hypervisor Xen Hypervisor Xen Hypervisor Pool db backup

  16. pool-dump-database Master pool-restore-database xe-toolstack-restart Pool db Pool db backup Xen Hypervisor Xen Hypervisor Xen Hypervisor Xen Hypervisor Xen Hypervisor Xen Hypervisor Xen Hypervisor Xen Hypervisor Xen Hypervisor Slaves

  17. vm-export metadata • xe vm-export • filename=<filename> • vm=<vm name-label> • metadata=true • xe vm-import • filename=<filename> • metadata=true • Can be scripted • Can be saved to network share. Please see Citrix article CTX117258

  18. host-backup • xe host-backup • file-name= • host= <host_selector_value> • Archives the active partition to a specified file • xe host-restore • file-name= • host= <host_selector_value>. • extracts the archive created by xe host-backup over the host's currently inactive disk partition

  19. host-backup • The backup partition can then be made active by booting off the installation CD and choosing the Restore option.

  20. Agenda Introduction Introduction Backup and recovery tools XenServer CLI basics Sample Scripts

  21. CLI Basics • The XenServer CLI provides additional functionality over the XenCenter Interface • New features are often developed in the CLI before being available in the GUI • CLI enables scripts for automating system administration tasks

  22. Object model • The object model and classes are key to understanding the CLI • Host and VM interact with the storage,virtual disk and network objects using connecttor objects VM Config VM Network Config Disk Config VIF VBD Network VDI SR PBD PIF HOST Host Config

  23. Object model VM VIF Network

  24. CLI Basics • Basic Syntax • xe <command-name> <argument=value> <argument=value> • Object commands • xe <class>-<TAB> • Where class can be: bond,console,host,network, patch, pbd, pif, pool,sr, task, template, vbd, vdi, vif, vlan, vm • Object List commands • xe <class>list-<TAB> • xe vm-list • Object Param commands • xe <class>-param-<TAB> • xe vm-param-list, vm-param-set, vm-param-get,vm-param-clear

  25. CLI Basics • Filtering • vm-list HVM-boot-policy="BIOS order" power-state=halted • Parameterization • xe vm-list params=name-label • Parameterization and filtering can be combined • xe vm-list HVM-boot-policy="BIOS order" power-state=halted params=name-label • Minimal Output • xe vm-list HVM-boot-policy="BIOS order" power-state=halted params=name-label --minimal

  26. Agenda Introduction Introduction Backup and recovery tools XenServer CLI basics Sample Scripts Sample Scripts

  27. Sample Scripts • List all loaded CD and set to empty • Pool-dump database script • Modify a VIF parameter on all VM's • VLAN creation

  28. List all loaded CD and set to empty #!/bin/bash # this section returns a list of VBD's of type CD, unpluggable false (to avoid listing xentools) # and empty is false to return only loaded CD roms this is all filtering #we are only returning the parameter vm uuid and minimal, the sed utility is used to replace the ,delimitation with spaces #the result is place in the cdlist variable cdlist=`xe vbd-list type=CD unpluggable=false empty=false params=vm-uuid --minimal | sed s/,/" "/g` #we loop through the cdlist and for each instance we get the name label using the uuid, print it out # and we eject the the CDusing the vm uuid for vm in $cdlist do echo $vm vmname=`xe vm-list uuid=$vm params=name-label --minimal` echo "eject CD from $vmname" xe vm-cd-eject uuid="$vm" done

  29. List all loaded CD and set to empty (Powershell 1) #script to connect to xenserver farm and eject all media $xdsnapin = 'XenServerPSSnapIn' $xsfarmurl = 'http://10.54.76.173' $xsuser = 'root' $xspass = 'citrix‘ #Load XS Snapin if(Get-PSSnapin| Where-Object -FilterScript {$_.Name -contains $xdsnapin}) { Write-Host "snapin already loaded" } else { #load snapin $ret = Add-PSSnapin -Name $xdsnapin -PassThru if(!$ret) { #error write-host "snapin error" break } else { Write-Host "snapin added" } }

  30. List all loaded CD and set to empty (Powershell 2) #connect to xenserver farm $xs = connect-XenServer -url $xsfarmurl -username $xsuser -password $xspass #comment out -password to force prompt #get list of virtual block devices $vbds = get-XenServer:VBD foreach($vbd in $vbds) { #check to see if its a cd and attached if ($vbd.type -ieq 'cd' -and $vbd.unpluggable -ieq $False -and $vbd.empty -ieq $False) { #get VM name (there might be a better way) $pht = @{} $pht.Add('opaque_ref',$vbd.VM.ServerOpaqueRef.ToString()) $vm = get-xenserver:VM -Properties $pht Write-Host "removing cd $($vbd.uuid) from vm $($vm.name_label)" $ret = Invoke-XenServer:VBD.eject -besteffort -runasync -vbd $vbd $ret = wait-xenserver:task -Task $ret -besteffort –showprogress if ($ret) { Write-Host "failed to remove cd $($vbd.uuid) from vm $($vm.name_label):$($ret)" } } } write-Host 'finished'

  31. Pool-dump database script # THIS SECTION VERIFIES IF THE LocalDirectoryName HAS NOT BEEN MOUNTED. IF NOT IT WILL MOUNT THE SHARE. MountName="" MountName=`mount -l | grep LocalDirectoryName` if [ "$MountName" = "" ]; then mount -t nfs <NFSSERVERNAME>:/<NFSShareNAME> /<LocalDirectoryName> echo "MOUNT POINT SUCCESSFULL /n" Fi # THIS SECTION WILL VERIIFY IF THE MOUNT POINT EXISTS BEFORE PERFORMING THE BACKUP OPERATION. MountTest="" MountTest=`mount -l | grep LocalDirectoryName ` if [ "$MountTest" != "" ]; then xe pool-dump-database file-name=/ LocalDirectoryName/`date '+XenPoolBackup_%m-%d-%y_ %H-%M-%S'` fi

  32. Modify a VIF parameter on all VM's #!/bin/bash #in this section we list all the vifs,only return the uuid parameter and use the minimal switch to omit the parameter name #we use sed to replace the , delimiter with a space #we place the result in the variable VIFLIST VIFLIST=`xe vif-list params=uuid --minimal | sed s/,/" "/g` #in this section we loop through VIFLIST # we use param clear to clear the other cconfig parameter and we set the ethtool-tx=off for all the listed vifs for VIF in $VIFLIST do echo $VIF xe vif-param-clear uuid=$VIF param-name=other-config xe vif-param-set uuid=$VIF other-config:ethtool-tx="off" done

  33. VLAN creation #!/bin/bash i=0 vlantag=1 devname=eth0 while [ $i -lt 3 ] do netname=vlan$vlantag netuuid=`xe network-create name-label=$netname` echo Network UUID $netuuid pifuuid=`xe pif-list device=$devname VLAN=-1 --minimal` echo PIF UUID $pifuuid vlanuuid=`xe vlan-create network-uuid=$netuuid pif-uuid=$pifuuid vlan=$vlantag` echo Vlan UUID $vlanuuid i=$[$i+1] vlantag=$[$vlantag +1] netuuid=' ' pifuuid=' ' vlanuuid=' ' done

  34. Continue Your Learning • The following course expands on today's topics and is recommended to support your Citrix solution: • CXS-200 Implementing Citrix XenServer Enterprise Edition 5.0 • Visit www.citrixeducation.com for more information

More Related