Volume Snapshot

1. Overview

ZStack allows user to create snapshots from VM's root volume and data volumes. Unlike majority of IaaS software only allowing users to create at most one snapshot chain, ZStack allows users to create a snapshot tree that each branch is a snapshot chain.

In this example, we will create a snapshot tree with two branches from a VM's root volume.

Only Ubuntu14.04 supports live snapshot, CentOS doesn't

For Linux distributions (CentOS6.x, CentOS7, and Ubuntu14.04) we have tested, only Ubuntu14.04 supports live snapshot. If you use a Linux other than Ubuntu14.04, you have to stop the VM before taking every snapshot. Assuming you use Ubuntu14.04, this tutorial doesn't contain instructions to stop VM before taking snapshot. However, reverting snapshot always requires to stop VM no matter what Linux distributions in use.

2. Prerequisites

We assume you have followed installation guide to install ZStack on a single Linux machine, and the ZStack management node is up and running. To access the web UI, type below URL in your browser (Please use latest Chrome or Firefox browser.):

http://your_machine_ip:5000/

To make things simple, we assume you have only one Linux machine with one network card that can access the internet; besides, there are some other requirements:

  • At least 20G free disk that can be used as primary storage and backup storage
  • Several free IPs that can access the internet
  • NFS server is enabled on the machine (see end of this section for automatically setup NFS)
  • SSH credentials for user root

Configure root user

The KVM host will need root user credentials of SSH, to allow Ansible to install necessary packages and to give the KVM agent full control of the host. As this tutorial use a single machine for both ZStack management node and KVM host, you will need to configure credentials for the root user.
CentOS:
sudo su
passwd root

Based on those requirements, we assume below setup information:

  • ethernet device name: eth0
  • eth0 IP: 172.20.11.45
  • free IP range: 192.168.0.230 ~ 192.168.0.240
  • primary storage folder: /zstack_ps
  • backup storage folder: /zstack_bs

Slow VM stopping due to lack of ACPID:

Though we don't show the example of stopping VM, you may find stopping a VM takes more than 60s. That's because the VM image doesn't support ACPID that receives KVM's shutdown event, ZStack has to wait for 60 seconds timeout then destroy it. It's not a problem for regular Linux distributions which have ACPID installed.

Avoid DHCP conflict

Please make sure you don't have a DHCP server in the network because ZStack will spawn its own DHCP server; if you have a DHCP server in the network and cannot remove it, please use an IP range that is unlikely used by your DHCP server, otherwise the VM may not receive an IP from ZStack's DHCP server but from yours.

3. LogIn

open browser with URL(http://your_machine_ip:5000/) and login with admin/password:


4. Create Zone

click 'Hardware' in the left sidebar and then click 'Zone'to enter the zone page:


click button 'Create Zone' to open the dialog:


name your first zone as 'ZONE1' and click button 'OK':


5. Create Cluster

click 'Cluster' in the left sidebar to enter the cluster page:


click button 'Create Cluster' to open the dialog:


name the cluster as 'CLUSTER1' then click button 'OK':


6. Add Host

click 'Host' in the left sidebar to enter host page:


click 'Create Host' button to open the dialog:


  1. name the host as 'HOST1'
  2. select cluster(CLUSTER1) you just created
  3. input the host IP(172.20.11.45)
  4. input the ssh port(22)
  5. the most important thing: give SSH credentials for user root
  6. click 'OK' button

A little slow when first time adding a host

It may take a few minutes to add a host because Ansible will install all dependent packages, for example, KVM, on the host.

7. Add Primary Storage

click 'PrimaryStorage' in the left slider to enter primary storage page:


click button 'Add PrimaryStorage' to open the dialog:


  1. name the primary storage as 'PS1'
  2. select type 'LocalStorge'
  3. input url(/zstack_ps)
  4. select cluster 'CLUSTER1'
  5. click button 'OK'

Format of URL

The format of URL is exactly the same to the one used by Linux mount command.


It's actually multiple API calls

You will see two API finishing notification because it actually calls two APIs: addPrimaryStorage and attachPrimaryStorageToCluster.

8. Add Backup Storage

click 'BackupStorage' in left sidebar to enter backup storage page:


click button 'Add BackupStorage' to open the dialog:


  1. name the backup storage as 'BS1'
  2. choose type 'Sftp'
  3. input IP(172.20.11.45) in host IP
  4. input URL '/zstack_bs' which is the folder that will store images


Input ssh port(22), input SSH credentials for user root, and click button 'OK':


9. Add Image

click 'Resource Pool' in left sidebar and click 'Image' to enter image page:


click button 'Add Image' to open the dialog:


  1. name the image as 'Image1'
  2. select media type 'Image'
  3. select platform 'Linux'
  4. input URL http://cdn.zstack.io/product_downloads/images/zstack-image.qcow2
  5. select BackupStorage 'BS1'
  6. click button 'OK'

this image will be used as user VM image.


10. Create Flat L2 Network

click 'Network' in left sidebar and click 'L2Network' to enter L2 network page:


click button 'Create L2Network' to open the dialog:


  1. name the L2 network as 'FLAT-L2'
  2. choose type 'L2NoVlanNetwork'
  3. input physical interface as 'eth0'
  4. select cluster 'CLUSTER1'
  5. click button 'OK'


11. Create L3 Network

click 'L3 Network' in left sidebar to enter L3 network page:


click button 'Private Network' to open the dialog:


Name the L3 network as 'FLAT-L3' , select L2 network(FLAT-L2) and choose 'Flat Network ':


  1. choose method 'IP Range'
  2. input start IP '192.168.0.230'
  3. input end IP '192.168.0.240'
  4. input netmask '255.255.255.0'
  5. input gateway '192.168.0.1'


input DNS '8.8.8.8' and click button 'OK' to add the IP range:


12. Create Virtual Machine

click 'Resource Pool' in the left sidebar and click 'VmInstance' to enter VM instance page:


click button 'Create VmInstance' to open the dialog:


  1. choose Type 'Single'
  2. input name as 'VM1'
  3. choose instance offering 'IO1'
  4. choose image 'Image1'
  5. choose network 'FLAT-L3'
  6. click button 'OK'


The first user VM takes more time to create

For the first user VM, ZStack needs to download the image from the backup storage to the primary storage and create a virtual router VM on the private L3 network, so it takes about 1 ~ 2 minutes to finish.

13. Create Volume Snapshot

first of all, we are going to create a flag file in VM1, so later on we can use this file to confirm that we revert to the correct snapshot. go to vm instance page:

  1. select VM1
  2. click button 'VmInstance Actions'
  3. select item 'Console'


in the popup window, login the VM by username: root, password: password; then create a file 'flag' as below:


go to vm instance page:

  1. select VM1 to enter details page
  2. select item 'Configure'
  3. click 'ROOT-for-VM1'

  1. click the button 'Volume Actions'
  2. select item 'Create Snapshot'

  1. input name as 'sp1'
  2. click button 'OK'


repeat above two steps to create two more snapshots: sp2 and sp3:


click tab 'Snapshot' and expand the tree, you should see three snapshots:


use instructions in the beginning of this section to enter VM1's console, and delete the flag file 'flag1':


to revert the root volume to a prior snapshot, we need to stop the VM1 first; go to the VM instance page:

  1. select VM1
  2. click button 'VmInstance Actions'
  3. select item 'Stop'

Again it's slow only because the zs-sample-image doesn't support ACPID

Because the image zs-sample-image doesn't support ACPID, the VM cannot be gracefully stopped. ZStack has to wait 60s stopping timeout then kill it, you won't encounter this problem in regular Linux distributions.


use former instructions to go to snapshot page:

  1. expand the snapshot tree
  2. select snapshot 'sp1'
  3. in the dropdown, select item 'Snapshot Actions'
  4. select 'Recover'


now start the VM again:

  1. select VM1
  2. click button 'VmInstance Actions'
  3. select item 'Start'

open the VNC console again and check the flag file 'flag1', you should see the file we deleted before now comes back, which confirms we have successfully reverted the root volume to the snapshot 'sp1':


use former instructions to create two more snapshots: 'sp1.1' and 'sp1.2':


expand the snapshot tree, now you should see two branches that are both derived from snapshot 'sp1':

Summary

In this tutorial, we showed you how to create volume snapshot in ZStack. Besides reverting a volume to an old snapshot, you can also create image template and volumes from snapshots. For details, please visit Volume Snapshot in user manual.