Editing
Getting high with lenny
(section)
From Linix VServer
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Heartbeat == === Get aquinted === Add the other node in the hosts file of both nodes, this way Heartbeat knows who is who. so for node1 do <code> nano /etc/hosts </code> and add node2 <pre> 192.168.1.200 node2 </pre> === Get intimate === Set up some keys on both boxes so we can ssh login without a password (defaults, no passphrase) <code> ssh-keygen </code> then copy over the public keys <code> scp /root/.ssh/id_rsa.pub 192.168.1.100:/root/.ssh/authorized_keys </code> <code> scp /root/.ssh/id_rsa.pub 192.168.1.200:/root/.ssh/authorized_keys </code> === Configure Heartbeat === Without the ha.cf file Heartbeat wil not start, this should only be done on 1 of the nodes. <code> nano /etc/ha.d/ha.cf </code> <pre> autojoin none #crm on #enables heartbeat2 cluster manager - we want that! use_logd on logfacility syslog keepalive 1 deadtime 10 warntime 10 udpport 694 auto_failback on #resources move back once node is back online mcast bond0 239.0.0.43 694 1 0 bcast eth2 node node1 #hostnames of the nodes node node2 </pre> This one also on 1 of the nodes <code> nano /etc/ha.d/authkeys </code> <pre> auth 3 3 md5 failover ## this is just a string, enter what you want ! auth 3 md5 uses md5 encryption </pre> <code> chmod 600 /etc/ha.d/authkeys </code> <note> We will be using heartbeat R1-style configuration here simply because i don't understand the R2 xml based syntax. </note> We only did the above 2 config files on 1 node but we need it on both, heartbeat can do that for us. <code> /usr/lib/heartbeat/ha_propagate </code> === Heatbeat behavior === After above 2 files are set, the haresources is where we want to be to control Heartbeats behaviour. This is an example for 1 Vserver that we will set up later on. <code> nano /etc/ha.d/haresources </code> <pre> node1 drbddisk::r1 LVM::drbdvg1 Filesystem::/dev/drbdvg1/web::/VSERVERS/web::ext3 vserver-web SendArp::123.123.123.125/bond0 MailTo::randall@songshu.org::DRBDFailure </pre> The above will default the Vserver named web to node1 and specify the mount points, the vserver-web script will start and stop heartbeat, the sendarp is for notifying the network that this IP can be found somewhere else then before. (have added the SendArp an extra time below for better result) Another example for more than 1 Vserver, We only specify 1 default node here for all Vservers and the same DRBD disk and Volume Group, the individual start scripts and mount points are specified separately, mind the \, its all in 1 line. the last mail command is only needed once. <pre> node1 \ drbddisk::r0 \ LVM::drbdvg0 \ Filesystem::/dev/drbdvg0/web::/VSERVERS/web::ext3 \ Filesystem::/dev/drbdvg0/ns1::/VSERVERS/ns1::ext3 \ Vserver-web \ Vserver-ns1 \ SendArp::123.123.123.125/bond0 \ SendArp::123.123.123.126/bond0 \ MailTo::randall@songshu.org::DRBDFailure </pre> === start/stop script === The vserver-web script as specified to be called by heartbeat above is basically a demolished version of the original R2 style agent by Martin Fick from here http://www.theficks.name/bin/lib/ocf/VServer. To handle ARP properly, a smaller script has been added to make sure the IP brought up on the new host (should fail over occur) can still communicate with the network. Being by installing "arping" <code> apt-get install arping </code> Then create the file <pre>/bin/garp</pre> and set the gatewayIp to be that of your router/host gateway. <pre> #!/bin/sh gatewayIp="XXX.XXX.XXX.XXX" host=$1 # Send a gratuitous arp to claim ownership of the new IP for i in `cat /etc/vservers/$host/interfaces/*/ip`; do echo "ARPing $i" arping -c 1 -S $i $gatewayIp done; exit </pre> What i did is remove the sensible top part and replace "$OCF_RESKEY_vserver" with the specific Vserver name, also added an extra <pre> /etc/ha.d/resource.d/SendArp 123.123.123.126/bond0 start </pre> to the start part because i had various results when done by Heartbeat in the first tests i did, not sure if it is still needed but i guess it doesn't hurt. <code> nano /etc/ha.d/resource.d/Vserver-web </code> <pre> #!/bin/sh # # License: GNU General Public License (GPL) # Author: Martin Fick <mogulguy@yahoo.com> # Date: 04/19/07 # Version: 1.1 # # This script manages a VServer instance # # It can start or stop a VServer # # usage: $0 {start|stop|status|monitor|meta-data} # # # OCF parameters are as below # OCF_RESKEY_vserver # ####################################################################### # Initialization: # #. /usr/lib/heartbeat/ocf-shellfuncs # #USAGE="usage: $0 {start|stop|status|monitor|meta-data}"; # ####################################################################### # # #meta_data() { # cat <<END #<?xml version="1.0"?> #<!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd"> #<resource-agent name="VServer"> # <version>1.0</version> # <longdesc lang="en"> #This script manages a VServer instance. #It can start or stop a VServer. # </longdesc> # <shortdesc lang="en">OCF Resource Agent compliant VServer script.</shortdesc> # # <parameters> # # <parameter name="vserver" unique="1" required="1"> # <longdesc lang="en"> #The vserver name is the name as found under /etc/vservers # </longdesc> # <shortdesc lang="en">VServer Name</shortdesc> # <content type="string" default="" /> # </parameter> # # </parameters> # # <actions> # <action name="start" timeout="2m" /> # <action name="stop" timeout="1m" /> # <action name="monitor" depth="0" timeout="1m" interval="5s" start-delay="2m" /> # <action name="status" depth="0" timeout="1m" interval="5s" start-delay="2m" /> # <action name="meta-data" timeout="1m" /> # </actions> #</resource-agent> #END #} vserver_reload() { vserver_stop || return vserver_start } vserver_stop() { # # Is the VServer already stopped? # vserver_status [ $? -ne 0 ] && return 0 /usr/sbin/vserver "web" "stop" vserver_status [ $? -ne 0 ] && return 0 return 1 } vserver_start() { vserver_status [ $? -eq 0 ] && return 0 /bin/garp web /usr/sbin/vserver "web" "start" vserver_status /etc/ha.d/resource.d/SendArp 123.123.123.125/bond0 start } vserver_status() { /usr/sbin/vserver "web" "status" rc=$? if [ $rc -eq 0 ]; then echo "running" return 0 elif [ $rc -eq 3 ]; then echo "stopped" else echo "unknown" fi return 7 } vserver_monitor() { vserver_status } vserver_usage() { echo $USAGE >&2 } vserver_info() { cat - <<!INFO Abstract=VServer Instance takeover Argument=VServer Name Description: A Vserver is a simulated server which is fairly hardware independent so it can be easily setup to run on several machines. Please rerun with the meta-data command for a list of \\ valid arguments and their defaults. !INFO } # # Start or Stop the given VServer... # if [ $# -ne 1 ] ; then vserver_usage exit 2 fi case "$1" in start|stop|status|monitor|reload|info|usage) vserver_$1 ;; meta-data) meta_data ;; validate-all|notify|promote|demote) exit 3 ;; *) vserver_usage ; exit 2 ;; esac </pre> To make this file executable by Heartbeat <code> chmod a+x /etc/ha.d/resource.d/Vserver-web </code> === not needed???? === There is some more interesting discussion going on here, [[Advanced_DRBD_mount_issues]]) , for those who have multiple Vservers on multiple DRBD devices. Not sure if it also applies for this setup but i'm using it without any drawbacks at the moment. Below is a changed version of option 4 by Christian Balzer <code> nano /etc/ha.d/resource.d/drbddisk </code> <pre> stop) # Kill off any vserver mounts that might hog this VNSPACE=/usr/sbin/vnamespace for CTX in `/usr/sbin/vserver-stat | tail -n +2 | awk '{print $1}'` do MPOINT="`$VNSPACE -e $CTX cat /proc/mounts | grep $RES | awk '{print $2}'`" echo Unmounting mount point $MPOINT from within context $CTX ### MOUNT POINT IS COMPULSORY. DEVICE NAME DOES NOT WORK!!! $VNSPACE -e $CTX /bin/umount $MPOINT || continue; done # exec, so the exit code of drbdadm propagates exec $DRBDADM secondary $RES </pre>
Summary:
Please note that all contributions to Linix VServer may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Linix VServer:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Page actions
Page
Discussion
Read
Edit
History
Page actions
Page
Discussion
More
Tools
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
About
Overview
Paper
News
Developers
Donations
Search
Getting Started
Downloads
FAQs
Documentation
Support
Participate
How to participate
Report a Bug
Communicate
Teams/Projects
Hall of Fame
Resources
Archives
Recent Wiki Changes
Pastebin
Related Projects
VServer Hosting
Happy VServer Users
Tools
What links here
Related changes
Special pages
Page information