LVS
lvs-users
Google
 
Web LinuxVirtualServer.org

Re: At Startup, I Get This: sed: -e expression #1, char1:?unknown?comman

To: "LinuxVirtualServer.org users mailing list." <lvs-users@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: At Startup, I Get This: sed: -e expression #1, char1:?unknown?command: `%'
Cc: Horms <horms@xxxxxxxxxxxx>
Cc: Robinson@xxxxxxxxxxxxxxxxx
From: Roberto Nibali <ratz@xxxxxxxxxxxx>
Date: Wed, 05 Jul 2006 13:03:57 +0200
Hello Horms,

Usual nitpicking :).

> I wrote up a patch to do this, it adds the sync_daemon option to
> ldirectord.cf. Though I am not sure if it should be added to ldirectord,
> as it may confuse people who run ldirectord out of heartbeat's
> haresources file.

> +B<sync_daemon = >[B<off>|B<on>|B<master>|B<backup>]
> +
> +Start the LVS synchronsation daemon. off will not start the daemon.

s/chrons/chronis/

> +on starts both the master and backup daemons. master will start only
> +the master daemon. backup will start only the backup daemon.
> +
> +If a daemon is configured to be started by ldirectord, it will
> +also be stopped by ldirectord when ldirectord exits. If ldirectord
> +is being run as a resource for heartbeat, and thus started and stoped
> +on failover, then it probably is best to set this parameter to off
> +and start and stop the synchronisation daemons by other means.
> +
> +Note also that older kernels (<2.4.27?) can only run one daemon at a
time.
> +
> +The default is off
> +
> +
>  B<quiescent = >[B<yes>|B<no>]
>
>  If I<yes>, then when real or failback servers are determined
> @@ -395,6 +414,7 @@
>           $RUNPID
>           $CHECKTIMEOUT
>           $QUIESCENT
> +         $SYNC_DAEMON
>
>           $CALLBACK
>           $CFGNAME
> @@ -1027,6 +1047,11 @@
>                       $LD_INSTANCE{$1} = 1;
>               } elsif ($_ =~ /^supervised/) {
>                       $SUPERVISED = 1;
> +             } elsif ($_ =~ /^sync_daemon\s*=\s*(.*)/) {
> +                     ($1 eq "on" || $1 eq "off" || $1 eq "master" ||
$1 eq "backup")
> +                         or &config_error($line,
> +                                     "quiescent must be 'on', 'off',
'master' or 'backup'");

s/quiescent/sync_daemon/

> +                     $SYNC_DAEMON = $1;
>               } elsif ($_ =~ /^quiescent\s*=\s*(.*)/) {
>                       ($1 eq "yes" || $1 eq "no")
>                           or &config_error($line,
> @@ -1422,6 +1447,7 @@
>
>  sub ld_setup
>  {
> +     ld_sync_start($SYNC_DAEMON);
>       for my $v (@VIRTUAL) {
>               if ($$v{protocol} eq "tcp") {
>                       $$v{proto} = "-t";
> @@ -1683,6 +1709,8 @@
>               &system_wrapper("$IPVSADM -D $$v{proto} " .
&get_virtual($v));
>               &ld_log("Removed virtual server (stop): " .
&get_virtual($v));
>       }
> +
> +     ld_sync_stop($SYNC_DAEMON);
>  }
>
>
> @@ -3602,3 +3630,103 @@
>  {
>       return ld_find_cmd_path($_[0], $ENV{'PATH'}, $_[1]);
>  }
> +
> +# ld_sync_get_status
> +# Check the status of the ipvs sync daemon
> +# pre: type: "backup" or "master"
> +# return: PID of running sync daemon
> +#         undef otherwise
> +sub ld_sync_get_status
> +{
> +     my ($type) = (@_);
> +     my $status = 0;
> +
> +     open PS, "ps ax|" or return;
> +
> +     while(<PS>) {
> +             m/ \[ipvs[ _]sync$type\]$/ or next;
> +             s/ *//;
> +             s/ .*$//;
> +             $status = $_;
> +             last;
> +     }
> +
> +     close PS;
> +     return $status;
> +}
> +
> +# __ld_sync_stop
> +# Run the ipvs sync daemon if it is not already running, else do nothing
> +# pre: type: "backup" or "master"
> +# return: none
> +sub __ld_sync_stop
> +{
> +     my ($type) = (@_);
> +     my $result;
> +
> +     if (not ld_sync_get_status($type)) {
> +             $result = "skipped (not running)";
> +     }
> +     elsif (system_wrapper("ipvsadm --stop-daemon $type") != 0) {
> +             $result = "fail";
> +     }
> +     else {
> +             $result = "ok";
> +     }
> +     ld_log("Stopping ipvs sync$type: $result");
> +}
> +
> +# ld_sync_stop
> +# Stop the ipvs sync daemons using __ld_sync_stop()
> +# pre: type: "off", "on", "backup" or "master"
> +# return: none
> +sub ld_sync_stop
> +{
> +     my ($type) = (@_);
> +
> +     if ($type eq "on" or $type eq "master") {
> +             __ld_sync_stop("master");
> +     }
> +     if ($type eq "on" or $type eq "backup") {
> +             __ld_sync_stop("backup");
> +     }
> +}
> +
> +# __ld_sync_start
> +# Stop the ipvs sync daemon if it is running, else do nothing
> +# pre: type: "backup" or "master"
> +# return: none
> +sub __ld_sync_start
> +{
> +     my ($type) = (@_);
> +     my $result;
> +
> +     if (ld_sync_get_status($type)) {
> +             $result = "skipped (already running)";
> +     }
> +     elsif (system_wrapper("ipvsadm --start-daemon $type") != 0) {
> +             $result = "fail";
> +     }
> +     else {
> +             $result = "ok";
> +     }
> +     ld_log("Starting ipvs sync$type: $result");
> +}
> +
> +
> +# ld_sync_start
> +# Stop the ipvs sync daemons using __ld_sync_start()
> +# pre: type: "off", "on", "backup" or "master"
> +# return: none
> +sub ld_sync_start
> +{
> +     my ($type) = (@_);
> +
> +     if ($type eq "on" or $type eq "master") {
> +             __ld_sync_start("master");
> +     }
> +     if ($type eq "on" or $type eq "backup") {
> +             __ld_sync_start("backup");
> +     }
> +}
> +
> Index: ldirectord.cf
> ===================================================================
> RCS file: /home/cvs/linux-ha/linux-ha/ldirectord/ldirectord.cf,v
> retrieving revision 1.26
> diff -u -r1.26 ldirectord.cf
> --- ldirectord.cf     5 Aug 2005 06:18:17 -0000       1.26
> +++ ldirectord.cf     5 Jul 2006 09:16:17 -0000
> @@ -16,6 +16,7 @@
>  #logfile="/var/log/ldirectord.log"
>  #logfile="local0"
>  quiescent=yes
> +sync_daemon=off

Cheers mate,
Roberto Nibali, ratz
-- 
-------------------------------------------------------------
addr://Kasinostrasse 30, CH-5001 Aarau tel://++41 62 823 9355
http://www.terreactive.com             fax://++41 62 823 9356
-------------------------------------------------------------
10 Jahre Kompetenz in IT-Sicherheit.              1996 - 2006
Wir sichern Ihren Erfolg.                      terreActive AG
-------------------------------------------------------------

<Prev in Thread] Current Thread [Next in Thread>