Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
5 Ways VMware vSphere Improves Backup and Recovery Hot Backup of MySQL on a Linux VM
CONTENTS
EXECUTIVE SUMMARY .....................................................................................................................................3 CONCEPT ......................................................................................................................................................................4 OPTION 1. SUSPEND MYSQL SERVICE ...................................................................................... 4 OPTION 2. USE ONLINE DUMP .................................................................................................. 4 WALKTHROUGH.....................................................................................................................................................5 ASSUMPTIONS ............................................................................................................................ 5 SUSPEND MYSQL SERVICE......................................................................................................... 5 USE ONLINE DUMP .................................................................................................................... 7 ABOUT VEEAM ..................................................................................................................................................... 10
Page | 2
5 Ways VMware vSphere Improves Backup and Recovery Hot Backup of MySQL on a Linux VM
EXECUTIVE SUMMARY
As more organisations move to virtualisation to facilitate core infrastructure, they look to the eco-system vendors to provide necessary core services, such as backup. Who better to help them meet those requirements than the virtualisation vendors themselves? This document describes the process required to take a consistent backup of MySQL running in a Linux virtual machine guest. VMware enhanced the ability to take offline snapshots for the backup of virtual machines with the advent of VCB (VMware Consolidated Backup) and more recently the vStorage API for data protection. These tools allow third-party vendors to make use of API calls to produce LAN-free consistent snapshots of virtual machines. This is achieved by providing a block list to the backup proxy allowing for access of the virtual machines disk subsystem. The block list is presented across a Storage Area Network (SAN)/ Network Attached Storage (NAS), Fibre channel, ISCSI or NAS, allowing backup I/O to occur away from the production LAN orientated traffic. The result of these API calls is an Agentless live image-level copy of the virtual disks, or an Agentless file-level mount of the virtual disks. With Microsoft database centric applications like Active directory, SQL and Exchange a transaction consistent backup of these applications is possible with the use of Microsoft Volume Shadow copy Services aka VSS. During backup and at the point the snapshot is created, backup vendors are able to interface with VSS to place these applications in a temporary consistent state just for the period of the snapshot creation. Unfortunately MySQL is not VSS aware especially in a nonMicrosoft operating system like Linux so a new approach has to be taken to produce a transaction consistent backup of MySQL databases.
Page | 3
5 Ways VMware vSphere Improves Backup and Recovery Hot Backup of MySQL on a Linux VM
CONCEPT
The approach described here entails the use of activated scripts local to the MySQL database. VMware has the ability to run a script to perform actions before the snapshot is created which is known as the pre-freeze-script and the ability to run a script to perform actions after the snapshot is created which is known as the postthaw-script. Virtual machine snapshots are used to release the file lock on the virtual disk which enables backup vendors to take backups of the virtual disk even while the virtual machine is powered on and running. The snapshot is created very quickly so the time required between the pre-freeze-script running and the postthaw-script running is minimal, a few minutes even a few seconds. We have 2 options to consider to achieve database consistency:
Page | 4
5 Ways VMware vSphere Improves Backup and Recovery Hot Backup of MySQL on a Linux VM
WALKTHROUGH
Assumptions
To find this information useful it is assumed you meet the following prerequisites: You are conversant with Linux & MySQL command-line You are happy with the concept of server virtualisation You understand the workings of the VCB framework & the vStorage API for data protection A Windows version of this document will be outlined in a separate document Also please note that the information used in this document was retrieved by testing the concept with the follow software: Virtual Machine running on vSphere 4.0 The guest operating system is Ubuntu 9.10 Linux version of MySQL 5.1.x
Step1
The VMware tools installation will need a C compiler part way through installation so we need to pre-stage this by executing the following commands:
sudo apt-get install build-essential sudo apt-get install linux-headers-`uname -r`
Please note ` symbol surrounding `uname r` is the symbol usually next to the 1 key on your keyboard.
Page | 5
5 Ways VMware vSphere Improves Backup and Recovery Hot Backup of MySQL on a Linux VM
Step 2
Next install the VMware tools on to the virtual machine by clicking "Install /Upgrade VMware tools" under the virtual machines Guest menu:
Step 3
Next we have to mount the VMware tools CDrom and copy the appropriate install file in the tmp folder. Then we have to expand (unzip) the install files needed. We achieve all this by running the following commands:
cd / mount cdrom cp /cdrom/*.gz /tmp/ cd /tmp tar xvzf VM*.gz cd vmware*
Step 4
Now we are ready to install the VMware tools. Unless you have a specific reason I would default all the questions by hitting the "enter " key making sure that where asked for a yes/no answer first that yes is typed. To start the install run the following command:
sudo ./vmware-install.pl
Creating scripts
Creating the pre-freeze-script and post-thaw-script.
Step 5
Next we have to create the pre-freeze-script and post-thaw-script files as they are not created by default. To do this run the "touch" command in the following way:
sudo touch /usr/sbin/pre-freeze-script sudo touch /usr/sbin/post-thaw-script
Step 6
Next we have to edit the pre-freeze-script and insert the "service mysql stop" command. To do this you can use your favorite Linux text editor, I use nano for simplicity:
sudo nano /usr/sbin/pre-freeze-script
From here type service mysql stop and save&exit by typing ctrl-X and choosing to save the file by typing Y and hitting "enter "
Page | 6
5 Ways VMware vSphere Improves Backup and Recovery Hot Backup of MySQL on a Linux VM
Step 7
Next we have to edit the post-thaw-script and insert the "service mysql start" command.
sudo nano /usr/sbin/post-thaw-script
From here type service mysql start and save&exit by typing ctrl-X and choosing to save the file by typing Y and hitting "enter "
Step 8
At this point the scripts are not quite ready to run as one last thing step to happen before they can be used. The scripts are not executable as the execute bit needs setting on the file permissions. To do this run the following command on both files:
sudo chmod 777 /usr/sbin/pre-freeze-script sudo chmod 777 /usr/sbin/post-thaw-script
Note: The "chmod" command is used to set the execute bit but the parameter "777" used also relaxes the file security permission on these files so you may want to review this and use something more restrictive settings.
Finally
Now you are ready to perform your backup and Veeam backup will initiate the VMware snapshot component which will in-turn process the scripts as described early.
Step1
The VMware tools installation will need a C compiler part way through installation so we need to pre-stage this by executing the following commands:
sudo apt-get install build-essential sudo apt-get install linux-headers-`uname -r`
Please note ` symbol surrounding `uname r` is the symbol usually next to the 1 key on your keyboard. Page | 7
5 Ways VMware vSphere Improves Backup and Recovery Hot Backup of MySQL on a Linux VM
Step 2
Next install the VMware tools on to the virtual machine by clicking "Install /Upgrade VMware tools" under the virtual machines Guest menu:
Step 3
Next we have to mount the VMware tools CDrom and copy the appropriate install file in the tmp folder. Then we have to expand (unzip) the install files needed. We achieve all this by running the following commands:
cd / mount cdrom cp /cdrom/*.gz /tmp/ cd /tmp tar xvzf VM*.gz cd vmware*
Step 4
Now we are ready to install the VMware tools. Unless you have a specific reason I would default all the questions by hitting the "enter " key making sure that where asked for a yes/no answer first that yes is typed. To start the install run the following command:
sudo ./vmware-install.pl
Creating scripts
Creating the pre-freeze-script and post-thaw-script.
Step 5
Next we have to create the pre-freeze-script and post-thaw-script files as they are not created by default. To do this run the touch command in the following way:
sudo touch /usr/sbin/pre-freeze-script sudo touch /usr/sbin/post-thaw-script
Page | 8
5 Ways VMware vSphere Improves Backup and Recovery Hot Backup of MySQL on a Linux VM
Step 6
Next we have to edit the pre-freeze-script and insert the "service mysql stop" command. To do this you can use your favorite Linux text editor, I use nano for simplicity:
sudo nano /usr/sbin/pre-freeze-script
From here type sudo mysqldump uroot pveeam h localhost test > test.sql and save&exit by typing ctrl-X and choosing to save the file by typing Y and hitting "enter "
Note: I used the word "test" to represent the name of my database whilst uroot is the user prompt and -pveeam is the password. The test.sql is the dump of the database so you could use an appropriate path and file name.
Step 7
At this point the scripts are not quite ready to run as one last step needs to happen before they can be used. The scripts are not executable as the execute bit needs setting on the file permissions. To do this run the following command on both files:
sudo chmod 777 /usr/sbin/pre-freeze-script sudo chmod 777 /usr/sbin/post-thaw-script
Note: The "chmod" command is used to set the execute bit but the parameter "777" used also relaxes the file security permission on these files so you may want to review this and use something more restrictive settings.
Finally
Now you are ready to perform your backup and Veeam backup will initiate the VMware snapshot component which will in-turn process the scripts as described early.
Page | 9
5 Ways VMware vSphere Improves Backup and Recovery Hot Backup of MySQL on a Linux VM
ABOUT VEEAM
Veeam Software, a VMware Technology Alliance Premier Partner, provides innovative software for managing VMware infrastructure. Veeam offers an award winning suite of tools to assist the VMware administrator, including Veeam Backup, the 2 in 1 backup and replication solution; Veeam Reporter Enterprise, to document virtual environments for capacity planning and chargeback; Veeam Configurator, offering Host Profiles today; and Veeam Monitor, for performance monitoring and alerting across multiple VirtualCenters. With its acquisition of nworks, Veeams products include connectors that incorporate VMware data into Microsoft System Center Operations Manager and HP Software Operations Manager. Learn more about Veeam Software by visiting www.veeam.com.
Page | 10