Latest revision |
Your text |
Line 375: |
Line 375: |
| [root@ovz-node1 ~]# chkconfig vz off | | [root@ovz-node1 ~]# chkconfig vz off |
| [root@ovz-node1 ~]# | | [root@ovz-node1 ~]# |
− | </pre>
| |
− |
| |
− | == Live-Switchover with the help of checkpointing ==
| |
− |
| |
− | With the help of [[Checkpointing_and_live_migration|checkpointing]] it is possible to do live switchovers.
| |
− |
| |
− | <b>Important:</b> although this HOWTO currently describes the use of DRBD 0.7, it is necessary to use DRBD 8 to be able to use this live-switchover feature reliable. Some hints on using OpenVZ Kernel 2.6.18 with DRBD 8 can be found in [http://forum.openvz.org/index.php?t=msg&th=3213&start=0& this thread in the forum].
| |
− |
| |
− | The following scripts are written by Thomas Kappelmueller. They should be placed at /root/live-switchover/ on both nodes. To activate the scripts execute the following commands on both nodes:
| |
− | <pre>
| |
− | [root@ovz-node1 ~]# ln -s /root/live-switchover/openvz /etc/init.d/
| |
− | [root@ovz-node1 ~]# ln -s /root/live-switchover/live_switchover.sh /root/bin/
| |
− | [root@ovz-node1 ~]#
| |
− | </pre>
| |
− |
| |
− | It is also necessary to replace <code>vz</code> by an adjusted initscript (<code>openvz</code> in this example). So /etc/ha.d/haresources has the following content on both nodes:
| |
− | <pre>
| |
− | ovz-node1 drbddisk::r0 Filesystem::/dev/drbd0::/vz::ext3 openvz MailTo::youremail@yourdomain.tld
| |
− | </pre>
| |
− |
| |
− | === Script cluster_freeze.sh ===
| |
− | <pre>
| |
− | #!/bin/bash
| |
− | #Script by Thomas Kappelmueller
| |
− | #Version 1.0
| |
− | LIVESWITCH_PATH='/vz/cluster/liveswitch'
| |
− |
| |
− | if [ -f $LIVESWITCH_PATH ]
| |
− | then
| |
− | rm -f $LIVESWITCH_PATH
| |
− | fi
| |
− |
| |
− | RUNNING_VE=$(vzlist -1)
| |
− |
| |
− | for I in $RUNNING_VE
| |
− | do
| |
− | BOOTLINE=$(cat /etc/sysconfig/vz-scripts/$I.conf | grep -i "^onboot")
| |
− | if [ $I != 1 -a "$BOOTLINE" = "ONBOOT=\"yes\"" ]
| |
− | then
| |
− | vzctl chkpnt $I
| |
− |
| |
− | if [ $? -eq 0 ]
| |
− | then
| |
− | vzctl set $I --onboot no --save
| |
− | echo $I >> $LIVESWITCH_PATH
| |
− | fi
| |
− | fi
| |
− | done
| |
− |
| |
− | exit 0
| |
− | </pre>
| |
− |
| |
− | === Script cluster_unfreeze.sh ===
| |
− | <pre>
| |
− | #!/bin/bash
| |
− | #Script by Thomas Kappelmueller
| |
− | #Version 1.0
| |
− |
| |
− | LIVESWITCH_PATH='/vz/cluster/liveswitch'
| |
− |
| |
− | if [ -f $LIVESWITCH_PATH ]
| |
− | then
| |
− | FROZEN_VE=$(cat $LIVESWITCH_PATH)
| |
− | else
| |
− | exit 1
| |
− | fi
| |
− |
| |
− | for I in $FROZEN_VE
| |
− | do
| |
− | vzctl restore $I
| |
− |
| |
− | if [ $? != 0 ]
| |
− | then
| |
− | vzctl start $I
| |
− | fi
| |
− |
| |
− | vzctl set $I --onboot yes --save
| |
− | done
| |
− |
| |
− | rm -f $LIVESWITCH_PATH
| |
− |
| |
− | exit 0
| |
− | </pre>
| |
− |
| |
− | === Script live_switchover.sh ===
| |
− | <pre>
| |
− | #!/bin/bash
| |
− | #Script by Thomas Kappelmueller
| |
− | #Version 1.0
| |
− |
| |
− | ps -eaf | grep 'vzctl enter' | grep -v 'grep' > /dev/null
| |
− | if [ $? -eq 0 ]
| |
− | then
| |
− | echo 'vzctl enter is active. please finish before live switchover.'
| |
− | exit 1
| |
− | fi
| |
− | ps -eaf | grep 'vzctl exec' | grep -v 'grep' > /dev/null
| |
− | if [ $? -eq 0 ]
| |
− | then
| |
− | echo 'vzctl exec is active. please finish before live switchover.'
| |
− | exit 1
| |
− | fi
| |
− | echo "Freezing VEs..."
| |
− | /root/live-switchover/cluster_freeze.sh
| |
− | echo "Starting Switchover..."
| |
− | /usr/lib64/heartbeat/hb_standby
| |
− | </pre>
| |
− |
| |
− | === Script openvz ===
| |
− | <pre>
| |
− | #!/bin/bash
| |
− | #
| |
− | # openvz Startup script for OpenVZ
| |
− | #
| |
− |
| |
− | start() {
| |
− | /etc/init.d/vz start > /dev/null 2>&1
| |
− | RETVAL=$?
| |
− | /root/live-switchover/cluster_unfreeze.sh
| |
− | return $RETVAL
| |
− | }
| |
− | stop() {
| |
− | /etc/init.d/vz stop > /dev/null 2>&1
| |
− | RETVAL=$?
| |
− | return $RETVAL
| |
− | }
| |
− | status() {
| |
− | /etc/init.d/vz status > /dev/null 2>&1
| |
− | RETVAL=$?
| |
− | return $RETVAL
| |
− | }
| |
− |
| |
− | # See how we were called.
| |
− | case "$1" in
| |
− | start)
| |
− | start
| |
− | ;;
| |
− | stop)
| |
− | stop
| |
− | ;;
| |
− | status)
| |
− | status
| |
− | ;;
| |
− | *)
| |
− | echo $"Usage: openvz {start|stop|status}"
| |
− | exit 1
| |
− | esac
| |
− |
| |
− | exit $RETVAL
| |
| </pre> | | </pre> |
| | | |
| [[Category: HOWTO]] | | [[Category: HOWTO]] |