Create a KVM backup in IBM PureFlex System

KVM virtual machines disaster recovery

IBM® PureFlex™ System with integrated network and storage virtualization and an open hypervisor provide an open and cost-effective solution to customers. This article shows how to create a backup of KVM (Kernel-based Virtual Machine) virtual machines in a PureFlex System environment.

Pradeep K. Surisetty (pradeepkumars@in.ibm.com), KVM Developer, IBM

Pradeep K. Surisetty photoPradeep K Surisetty is a KVM developer in the Linux Technology Center, IBM Systems and Technology Group Labs, India. He has 6 years of experience in virtualization and cloud development. He helps IBM client-facing teams with designing of KVM-based solutions.



Pradipta Kumar (bpradipt@in.ibm.com), KVM Virtualization and Cloud Management Architect, IBM

Pradipta Kumar photoPradipta Kumar Banerjee is a KVM virtualization and cloud management architect in the IBM Linux Technology Center, IBM Systems and Technology Group Labs, India. He is an IBM Master Inventor and works closely with clients to design virtualized data centers and cloud infrastructure for their work loads.



Tony Gargya (gargya@de.ibm.com), KVM Systems Management Architect, IBM

Author photoTony Gargya is a KVM systems management architect in the Linux Technology Centre, Germany. His focus is primarily on open source-based projects and their integration with commercial products. He works closely with numerous clients to help them to manage their data centres and has spoken often both at IBM and Linux foundation-sponsored conferences.



13 September 2013

Also available in Russian Japanese

As virtual environments grow larger and the applications running in them become more important to business success, demand for quick, efficient backup of virtual machines (VMs) residing in Kernel-based Virtual Machine (KVM) data stores is becoming critical. This article addresses the problem of creating consistent backups using IBM Storewize® V7000 storage and IBM FlashCopy® functionality from KVM VMs in an IBM PureFlex System chassis and recovering them on another (possibly remote) PureFlex System chassis.

Configuration and setup

The environment used as part of this setup consists of the following components:

  • Red Hat Enterprise Linux® (RHEL) 6.3
  • A PureFlex System chassis with IBM System x® IT elements (ITEs) managed by IBM Flex System™ Manager (FSM)
  • Storage area network Storewize V7000 storage logical unit numbers connected to servers by Fibre Channel

PureFlex System and KVM: An unbeatable combination

This article details how to create a backup of KVM virtual machines in an IBM PureFlex System environment, an integrated system that combines compute, storage, networking, virtualization, and management into a single infrastructure.

You can expand your exploration of combining the virtues of the PureFlex System with hypervisor technologies such as KVM (and including PowerVM, VMware, and Hyper-V):

This article assumes that PureFlex System and FSM with Storewize V7000 storage have been configured. RHEL version 6.2 or later must already be installed and configured properly on the System x ITE. See Resources for links to more information.

High-level configuration steps

The steps that follow represent the logical configuration phases for the failover cluster:

  1. Install the latest PureFlex System-supported RHEL 6.3 operating system on a System x ITE node in PureFlex System.
  2. Create VMs using the management layer (FSM in PureFlex System).
  3. Suspend the critical VM.
  4. Take a snapshot of the respective volume of VM Storewize V7000 storage using FlashCopy.
  5. Create a backup of the libvirt XML file of the VM.
  6. Resume the VM.
  7. Map a volume to the backup server in Storewize V7000 storage.
  8. Copy the backup volume and the corresponding XML files to a media tape device.
  9. Restore the system using the backed-up volume and XML files.
  10. Run an inventory from FSM on the new system.

Backup and recovery of VMs

Backing up from KVM VMs in PureFlex System using Storewize V7000 storage and FlashCopy provides a complete data-protection solution for the KVM environment.

Suspend the critical VM

The virsh tool is built on top of the libvirt management application programming interface to manage guest domains. Listing 1 shows how to suspend a VM before taking snapshot of the VM volume.

Listing 1. Suspending a VM before taking a snapshot of it
 virsh # list 
 Id    Name                           State 
---------------------------------------------------- 
 29    win2008-r2-64               running 
  31    vm1                               running 
virsh #  suspend  vm1
virsh # list 
Id    Name                           State 
---------------------------------------------------- 
 29    win2008-r2-64               running 
 31    vm1                               paused

Take a snapshot of the volume with FlashCopy

FlashCopy is the point-in-time copy capability of the Storewize V7000 disk. It is used to create instant, complete, and consistent copy from a source volume to a target volume. Often, this functionality is called time-zero copy, point-in-time copy, or snapshot copy. FlashCopy is part of Copy Services; Figure 1 shows how to take a snapshot of a volume from FlashCopy.

Figure 1. Creating a snapshot of a volume from FlashCopy
Image showing how to create a shapshot of a volume from FlashCopy

Back up the VM and XML files

Back up the corresponding libvirt XML file, and then resume the VM, as shown in Listing 2.

Listing 2. Resuming the VM
# virsh dumpxml vm1 > /tmp/vm1-snap1-xml
virsh # list 
Id    Name                           State 
---------------------------------------------------- 
 29    win2008-r2-64               running 
31    vm1                               paused
virsh # resume vm1 
virsh # list 
Id    Name                           State 
---------------------------------------------------- 
 29    win2008-r2-64               running 
 31    vm1                                running

Map the new volume to the backup server

If a backup server is available, map the backed-up volume to that server (see Figure 2).

Figure 2. Mapping the volume
Image showing how to map the volume

When the volume has been mapped, the new volume will be listed on the backup server, as shown in Listing 3.

Listing 3. Mapping the volume to the backup server
[root@llmvm11 ~]# multipath -ll 
mpathe (3600507680280865df800000000000042) dm-7 IBM,2145 
size=5.9G features='1 queue_if_no_path' hwhandler='0' wp=rw 
|-+- policy='round-robin 0' prio=50 status=active 
| `- 0:0:1:5  sdq 65:0  active ready running 
`-+- policy='round-robin 0' prio=10 status=enabled 
  `- 0:0:0:5  sdf 8:80  active ready running 
mpathd (3600507680280865df800000000000017) dm-3 IBM,2145 
size=10G features='1 queue_if_no_path' hwhandler='0' wp=rw 
|-+- policy='round-robin 0' prio=50 status=active 
| `- 0:0:0:3  sdd 8:48  active ready running 
`-+- policy='round-robin 0' prio=10 status=enabled 
  `- 0:0:1:3  sdo 8:224 active ready running 
mpathc (3600507680280865df80000000000004e) dm-0 IBM,2145 
size=12G features='1 queue_if_no_path' hwhandler='0' wp=rw 
|-+- policy='round-robin 0' prio=50 status=active 
| `- 0:0:0:0  sda 8:0   active ready running 
`-+- policy='round-robin 0' prio=10 status=enabled 
  `- 0:0:1:0  sdl 8:176 active ready running

Backed-up volumes of VMs and respective XML files can be stored on backup servers or tape media.

Recovery during a disaster

Map backed-up volumes to the new System x ITE on the PureFlex System chassis. Edit the XML files and define them with libvirt, as shown in Listing 4.

Listing 4. Edit VM1 with a new volume path
    <disk type='block' device='disk'> 
      <driver name='qemu' type='raw' cache='none' io='native'/> 
      <source dev='/dev/disk/by-id/wwn-0x600507680280865df800000000000017'/> 
      <target dev='vda' bus='virtio'/>

virsh # virsh define /etc/libvirt/vm1-snap1.xml
virsh # start vm1

Run the inventory

When the VM image has been recovered on a different host, run an inventory on the new host from FSM (see Figure 3).

Figure 3. Running the inventory
Image showing how to run the inventory

Future work

Suspending a VM with libvirt is crash consistent because the VM is suspended immediately and does not get a chance to flush the contents of its memory to the disks. When this image is resumed on another host, file systems will be checked for errors (fsck) and repaired. Because the content of memory is not present in the copy, there is a chance of data loss.

Freeze and thaw a VM with guest agents

An upcoming feature called QEMU GuestAgent makes it possible to put the file systems of VMs in a consistent state before taking the snapshot — in other words, you can implement a freeze and thaw a VM with guest agents.

A guest agent is a daemon program running inside the domain that is designed to help management applications execute functions that need the assistance of the guest OS. For example, freezing and thawing filesystems or entering a suspend mode.

Using QEMU GuestAgent avoids inconsistent file systems in the snapshot, which means that you don't need to check file systems while resuming the VM, and there is no chance of data loss. When this QEMU GuestAgent feature is available in enterprise hypervisors, you can use it with the above snapshot procedure to obtain consistent, loss-free backup and restore capability.

To configure guest agents:

  1. Install a QEMU GuestAgent on the VM.
  2. Start the VM with virtio-serial or an isa-serial channel.
  3. Start the QEMU GuestAgent:
    "qemu-ga -m virtio-serial -p /dev/virtio-ports/org.qemu.guest_agent.0"
  4. Start the QEMU Management Protocol from a different terminal:
    socat unix-connect:/tmp/qga.sock readline
  5. Freeze and thaw the VM by running the following commands:
    { "execute": "guest-info"}
    { "execute": "guest-fsfreeze-freeze"}
    { "execute": "guest-fsfreeze-thaw"}

Resources

Learn

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Cloud computing on developerWorks


  • Bluemix Developers Community

    Get samples, articles, product docs, and community resources to help build, deploy, and manage your cloud apps.

  • Cloud digest

    Complete cloud software, infrastructure, and platform knowledge.

  • DevOps Services

    Software development in the cloud. Register today to create a project.

  • Try SoftLayer Cloud

    Deploy public cloud instances in as few as 5 minutes. Try the SoftLayer public cloud instance for one month.

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Cloud computing
ArticleID=944735
ArticleTitle=Create a KVM backup in IBM PureFlex System
publish-date=09132013