LSB init script for each VPS [message #38244] |
Tue, 01 December 2009 14:38 |
webofunni
Messages: 10 Registered: March 2009
|
Junior Member |
|
|
Hi,
I am setting up HA in two nodes with both running 3 VPS each. 3 VPSs are live and other 3 in the second node are standby.
I need LSB init scripts for each VPS to start and stop each VPS using heartbeat. I know there is a vz script to start/stop all the VPSs. Anybody has such LSB style init script or any hints to write one myself ?
Thanks for the help.
Regards,
Unni
|
|
|
|
Re: LSB init script for each VPS [message #38253 is a reply to message #38244] |
Tue, 01 December 2009 18:38 |
webofunni
Messages: 10 Registered: March 2009
|
Junior Member |
|
|
Thanks,
But I am searching for init script to start a single VPS. I know the vz init script. But, as you said will start/stop all VPS.
Yes, its a openvz cluster with failover for aech VPS. Not for all the VPS as documented in the openvz wiki.
Regards,
Unni
|
|
|
Re: LSB init script for each VPS [message #38256 is a reply to message #38253] |
Tue, 01 December 2009 20:15 |
|
curx
Messages: 739 Registered: February 2006 Location: Nürnberg, Germany
|
Senior Member |
|
|
Hi,
like this minimal script /etc/ha.d/resource.d/vz script
#!/bin/bash
_VZCTL="/usr/sbin/vzctl"
_VZLIST="/usr/sbin/vzlist"
_VZLIST_OPTS="-Hostatus"
case "$2" in
start)
$_VZCTL $2 $1
;;
stop)
$_VZCTL $2 $1
;;
status)
$_VZLIST $_VZLIST_OPTS $1
;;
*)
echo "Usage: vz [CTID] {start|stop|status}"
exit 1
;;
esac
exit 0
Hope this helps.
Bye,
Thorsten
[Updated on: Tue, 01 December 2009 20:15] Report message to a moderator
|
|
|
Re: LSB init script for each VPS [message #38280 is a reply to message #38244] |
Thu, 03 December 2009 15:37 |
webofunni
Messages: 10 Registered: March 2009
|
Junior Member |
|
|
Thanks curx,
I have made some modifications to make that Linux LSB compatible.
#!/bin/bash
_VZCTL="/usr/sbin/vzctl"
_VZLIST="/usr/sbin/vzlist"
_VZLIST_OPTS="-Hostatus"
status()
{
STAT=`/usr/sbin/vzlist -Hostatus 105`
if [ $STAT = "running" ];then
echo "running"
return 0
else
echo "stopped"
return 3
fi
}
case "$1" in
start)
$_VZCTL $1 105
;;
stop)
$_VZCTL $1 105
;;
status)
status
RETVAL=$?
;;
*)
echo "Usage: havps1 {start|stop|status}"
exit 1
;;
esac
exit $RETVAL
I have another question.
The above script will give the status of the VPS and using that I can do the fail over. But the status will not help, if the VPS is in some resource problem like resource failure in UBC and VPS is in crashed state. But the status will be showing as running.
Is there any method to monitor the resource failure also ?
Any idea ? What is the best method ?
Regards,
Unni
|
|
|
|
Re: LSB init script for each VPS [message #38307 is a reply to message #38244] |
Sat, 05 December 2009 12:04 |
webofunni
Messages: 10 Registered: March 2009
|
Junior Member |
|
|
Thanks,
Yes, monitoring a service using another application like telnet, ping etc are the options. But what is the best way to accomplish that. I am also thinking of writing a script using "vzctl exec VEID service SOMESERV status".
What is the best method to do that.
Regards,
Unni
|
|
|
|
|