Xen FAQ High Availability: Difference between revisions
Lars.kurth (talk | contribs) (Migrated from XenFAQ2) |
Rcpavlicek (talk | contribs) |
||
(9 intermediate revisions by 3 users not shown) | |||
Line 5: | Line 5: | ||
=== What software exists for Xen to handle high availability? === |
=== What software exists for Xen to handle high availability? === |
||
A (HA1.0): Here are several tools that currently exist: |
A (HA1.0): Here are several tools that currently exist: |
||
* [[Remus]] provides transparent, comprehensive high availability to ordinary virtual machines running on the Xen virtual machine monitor. It does this by maintaining a completely up-to-date copy of a running VM on a backup server, which automatically activates if the primary server fails. Remus support began in Xen Project release 4.0, with full [[:Category:PVOPS|PVOPS]] support available in 4.2, see [[Remus]] for details. |
|||
Other projects / software: |
|||
* CentOS Cluster |
* CentOS Cluster |
||
⚫ | |||
* Project Kemari - http://www.osrg.net/kemari/ |
* Project Kemari - http://www.osrg.net/kemari/ |
||
* Project Remus - http://blog.xen.org/index.php/2009/04/02/project-remus-released/ |
|||
⚫ | |||
=== How |
=== How can I use LVM2 for snapshots to backup my domU's? === |
||
I'm not sure about how snapshots works on Xen. For example, if I snapshot a DomU with |
|||
Copied from external blog post [http://www.infohit.net/blog/post/using-lvm2-snapshots-to-provide-rollback-functionality-for-xen.html "Using LVMw Snapshots to Provide Rollback Functionality for Xen"] (source appears to have gone offline as of July 2015). |
|||
10GB HD will take, for example, 30 seconds. But, if I snapshot a DomU with a 100GB HD will take longer (I guess). |
|||
[http://sourceware.org/lvm2/ LVM2] is a set of tools which work with the [http://sources.redhat.com/dm/ device-mapper] drivers of the linux kernel to provide volume management. They provide a convenient set of tools for creating, resizing and deleting volumes which can span or be striped over multiple disks. One of the convenient pieces of functionality provided by LVM is the ability to take a snapshot of an LVM volume and make it visible as another partition. This is typically useful when you want to take consistent backups. For example if you know your database is in a consistent state, you can lock it for a moment, create a volume snapshot which takes just a few seconds, and then unlock the database. You can then backup the snapshot volume to slow media or whatever. |
|||
'''What has this got to do with [http://www.xen.org/ Xen]?''' Well, it turns out that you can write to an LVM2 snapshot, and the original volume is unaffected. This means you can create a snapshot of a volume containing lvm loopback images in your desired state, then run the virtual machine on the snapshot images instead. To rollback, you simply power off the machine even with xm destroy unmount and remove the snapshot, and then recreate the snapshot and reboot the virtual machine. A process that takes only a few seconds. Here below is how its done in practice: |
|||
1) Create the snapshot of /dev/vga/domU with enough space for 6GB of alterations |
|||
<pre> |
|||
lvcreate -L6G -s -n domU.S /dev/vga/domU |
|||
</pre> |
|||
(the snapshot doesnt have to be the same size as the original, it only has to have enough space to store the differences) |
|||
2) Create a mount point to mount the snapshot: |
|||
<pre> |
|||
mkdir -p /workarea/xen/domains.S |
|||
</pre> |
|||
3) mount the snapshot: |
|||
<pre> |
|||
mount -t auto /dev/vga/domU.S /workarea/xen/domains.S/ |
|||
</pre> |
|||
4) Start the virtual machine |
|||
<pre> |
|||
xm create -c /etc/xen/myvirtual-S.cfg |
|||
</pre> |
|||
The configuration file will need to have had the paths to the loopback images updated so that they point to the versions on the snapshot |
|||
5) After the machine has finished unmount and remove the snapshot volumes: |
|||
<pre> |
|||
umount /workarea/xen/domains.S |
|||
lvremove -f /dev/mapper/vga-domU.S |
|||
</pre> |
|||
6) rinse and repeat |
|||
When you create a new snapshot its condition will of course be the original version of the virtual machine provided no changes have been made to it in the mean time. |
|||
=== How do I back-up a Xen VM Environment? === |
|||
My current environment is based on Xen 4.0.1 on Debian and virtual machines on files. |
|||
The idea is to pause the machine and make copies of rsync the folders where the files reside on the disks. You through an example: |
|||
<pre> |
|||
#!/bin/sh |
|||
# Script de copia para los svX hacia USB1TB |
|||
# Uso: svX_backup.sh <servidor> <nombre o id de vm> <origen> <destino> |
|||
# Los servidores destino tienen que tenen el par de claves ssh del que accede. |
|||
echo Sincronizando y pausando vm $2 del servidor $1 ... |
|||
/usr/bin/ssh $1 "xm sysrq $2 s ; xm pause $2 ; xm sysrq $2 s" |
|||
echo Backup de vm $2 [$3] a $4... |
|||
/usr/bin/rsync -avhrP $3 $4 |
|||
echo Reactivando vm $2... |
|||
So, I wanna know how the snapshot works on xen. What if I want to move a snapshotted with a 100GB HD from a Dom0 to another Dom0? I've to move a 100GB file? |
|||
/usr/bin/ssh $1 "xm unpause $2" |
|||
</pre> |
|||
== VM Migration == |
|||
You could try this approach: |
|||
=== Can I migrate VMs between different servers, running Xen? === |
|||
Yes, Xen can [[Migration|migrate]] virtual machines between different servers. This can for example be useful if you need to take a physical server offline, for maintenance. |
|||
For more information see: |
|||
http://www.infohit.net/blog/post/using-lvm2-snapshots-to-provide-rollback-functionality-for-xen.html |
|||
* [[Migration]] |
|||
* [[XL]], [http://xenbits.xen.org/docs/unstable/man/xl.1.html xl(1)] in particular "xl migrate -h" |
|||
<!-- Leave this at the end --> |
|||
Makes snapshots quite quick. |
|||
== Where do I find more HA FAQs? == |
|||
See [[Xen_Common_Problems#HA_and_Fault_Tolerance|Xen Common Problems#HA and Fault Tolerance]] |
|||
[[Category:Xen]] |
[[Category:Xen]] |
Latest revision as of 13:59, 24 August 2015
High Availability Questions
Services
What software exists for Xen to handle high availability?
A (HA1.0): Here are several tools that currently exist:
- Remus provides transparent, comprehensive high availability to ordinary virtual machines running on the Xen virtual machine monitor. It does this by maintaining a completely up-to-date copy of a running VM on a backup server, which automatically activates if the primary server fails. Remus support began in Xen Project release 4.0, with full PVOPS support available in 4.2, see Remus for details.
Other projects / software:
- CentOS Cluster
- Linux Cluster Resource Manager - http://clusterlabs.org
- Project Kemari - http://www.osrg.net/kemari/
How can I use LVM2 for snapshots to backup my domU's?
Copied from external blog post "Using LVMw Snapshots to Provide Rollback Functionality for Xen" (source appears to have gone offline as of July 2015).
LVM2 is a set of tools which work with the device-mapper drivers of the linux kernel to provide volume management. They provide a convenient set of tools for creating, resizing and deleting volumes which can span or be striped over multiple disks. One of the convenient pieces of functionality provided by LVM is the ability to take a snapshot of an LVM volume and make it visible as another partition. This is typically useful when you want to take consistent backups. For example if you know your database is in a consistent state, you can lock it for a moment, create a volume snapshot which takes just a few seconds, and then unlock the database. You can then backup the snapshot volume to slow media or whatever.
What has this got to do with Xen? Well, it turns out that you can write to an LVM2 snapshot, and the original volume is unaffected. This means you can create a snapshot of a volume containing lvm loopback images in your desired state, then run the virtual machine on the snapshot images instead. To rollback, you simply power off the machine even with xm destroy unmount and remove the snapshot, and then recreate the snapshot and reboot the virtual machine. A process that takes only a few seconds. Here below is how its done in practice:
1) Create the snapshot of /dev/vga/domU with enough space for 6GB of alterations
lvcreate -L6G -s -n domU.S /dev/vga/domU
(the snapshot doesnt have to be the same size as the original, it only has to have enough space to store the differences)
2) Create a mount point to mount the snapshot:
mkdir -p /workarea/xen/domains.S
3) mount the snapshot:
mount -t auto /dev/vga/domU.S /workarea/xen/domains.S/
4) Start the virtual machine
xm create -c /etc/xen/myvirtual-S.cfg
The configuration file will need to have had the paths to the loopback images updated so that they point to the versions on the snapshot
5) After the machine has finished unmount and remove the snapshot volumes:
umount /workarea/xen/domains.S lvremove -f /dev/mapper/vga-domU.S
6) rinse and repeat
When you create a new snapshot its condition will of course be the original version of the virtual machine provided no changes have been made to it in the mean time.
How do I back-up a Xen VM Environment?
My current environment is based on Xen 4.0.1 on Debian and virtual machines on files. The idea is to pause the machine and make copies of rsync the folders where the files reside on the disks. You through an example:
#!/bin/sh # Script de copia para los svX hacia USB1TB # Uso: svX_backup.sh <servidor> <nombre o id de vm> <origen> <destino> # Los servidores destino tienen que tenen el par de claves ssh del que accede. echo Sincronizando y pausando vm $2 del servidor $1 ... /usr/bin/ssh $1 "xm sysrq $2 s ; xm pause $2 ; xm sysrq $2 s" echo Backup de vm $2 [$3] a $4... /usr/bin/rsync -avhrP $3 $4 echo Reactivando vm $2... /usr/bin/ssh $1 "xm unpause $2"
VM Migration
Can I migrate VMs between different servers, running Xen?
Yes, Xen can migrate virtual machines between different servers. This can for example be useful if you need to take a physical server offline, for maintenance.
For more information see: