OpenVZ Forum


Home » General » Support » LSB init script for each VPS (Need init script for each VPS)
LSB init script for each VPS [message #38244] Tue, 01 December 2009 14:38 Go to next message
webofunni is currently offline  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 #38251 is a reply to message #38244] Tue, 01 December 2009 18:28 Go to previous messageGo to next message
curx
Messages: 739
Registered: February 2006
Location: Nürnberg, Germany
Senior Member

Hi,

Initscript at /etc/init.d/vz - for starting the OpenVZ subsystem and all configured containers ( with onboot option )

Btw, are you running a drbd, heartbeat OpenVZ Cluster ?

Bye,
Thorsten
Re: LSB init script for each VPS [message #38253 is a reply to message #38244] Tue, 01 December 2009 18:38 Go to previous messageGo to next message
webofunni is currently offline  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 Go to previous messageGo to next message
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 Go to previous messageGo to next message
webofunni is currently offline  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 #38285 is a reply to message #38280] Thu, 03 December 2009 19:19 Go to previous messageGo to next message
unxs is currently offline  unxs
Messages: 21
Registered: September 2009
Location: Oregon, USA
Junior Member
HA autnomoic failover is a very hard problem. You should use an external service status program (a script that actually can tell if a given service is working via protocol answers etc.) to determine if your container is not working. Avoid split-brain problems with smart fencing. (Google all these buzzwords. Wikipedia also has tons of info.)

My experience is that what usually fails is the complete hardware node. (i.e. all the containers.) So first make sure you can failover everything to a standby hardware node. And that these containers are always kept fresh -but in a working fashion. No good to sync broken config or other files to your standbys and expect them to work. As you can see nothing here is easy. Concentrate on only a single specific service, this reduces the complexity.
Re: LSB init script for each VPS [message #38307 is a reply to message #38244] Sat, 05 December 2009 12:04 Go to previous messageGo to next message
webofunni is currently offline  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
Re: LSB init script for each VPS [message #38308 is a reply to message #38307] Sat, 05 December 2009 14:39 Go to previous messageGo to next message
unxs is currently offline  unxs
Messages: 21
Registered: September 2009
Location: Oregon, USA
Junior Member
Instead of slow scripts, expect, etc. A small, reliable and very fast C client program that implements a subset of the service protocol is optimal IMO.

This monitoring should be external to the hardware node that your service container is running on.

See

http:// www.mysqlperformanceblog.com/2009/11/13/finding-your-mysql-h igh-availability-solution-%E2%80%93-replication/#more-1607

for a general solution discussion and introduction to this topic with MySQL service as an example.
Re: LSB init script for each VPS [message #38351 is a reply to message #38308] Wed, 09 December 2009 17:15 Go to previous message
szerverbseo is currently offline  szerverbseo
Messages: 1
Registered: December 2009
Junior Member
Hatalmas VPS akció?

Megújult oldalunkat hatalmas akcióval indítjuk.
Kihagyhatatlan virtuális szerver ajánlat.

Előretelepített operációs rendszerrel.

Virtuális Szerver
olcsó Virtuális Szerver
Virtual Private Server
VPS (Virtuális szerver) megrendelés

Seed szerver használat use?
Gyors seed szerverek, 1Gb kapcsolattal.

seed szerver
seed szerver bérlés
olcsó seed szerver
seed szerver

Do you vannak jobb better ár prize?

Thank you!
Köszönöm!
Previous Topic: bug in vzctl 3.0.23-1pve3
Next Topic: dlm in openvz kernel
Goto Forum:
  


Current Time: Sat Jun 01 11:46:11 GMT 2024

Total time taken to generate the page: 0.01511 seconds