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!
=== 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>
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