Glyn Astill | 9 Jan 2008 16:50
Picon
Favicon

Slony startup scripts

Hi people,

Until now I've been starting the slon daemon from the command line,
and now I wan't to move it to a startup script. Looking over things I
see I'm probably going to be best using a slon.conf file now as well.
this leaves me with a few questions.

1) I don't see any parameter in the slon.conf to set where my logs
go. Is this possible or do I just have to pipe the output to a file
like I'm already doing?

2) further to the above, can slony rotate it's logs automatically?
I.e. so I can have a new log file every day?

3) I've had a look athe the supplied script for redhat, although I'm
using Debian so theres going to be a few differences. One of these is
that I've been stopping the slons with "kill <processid>", the redhat
script uses "killproc slon". How can I kill the slon in my script?
read the .pid file?

4)I've jsut discovered the altperl scripts in the docs, and they look
really useful. The docs say to run configure with "--with-perltools"
before compiling and they'll get installed. I didn't do this. can I
install the altperl scripts without a recompile?

Thanks
Glyn

      ___________________________________________________________
Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
(Continue reading)

Christopher Browne | 9 Jan 2008 16:56

Re: Slony startup scripts

Glyn Astill <glynastill@...> writes:
> Until now I've been starting the slon daemon from the command line,
> and now I wan't to move it to a startup script. Looking over things I
> see I'm probably going to be best using a slon.conf file now as well.
> this leaves me with a few questions.
>
> 1) I don't see any parameter in the slon.conf to set where my logs
> go. Is this possible or do I just have to pipe the output to a file
> like I'm already doing?

slon makes no attempt to redirect output; you capture it as you like.

> 2) further to the above, can slony rotate it's logs automatically?
> I.e. so I can have a new log file every day?

There are numerous tools for this purpose that are generic to all
kinds of log files; no point in having Slony-I duplicate this kind of
functionality.

> 3) I've had a look athe the supplied script for redhat, although I'm
> using Debian so theres going to be a few differences. One of these is
> that I've been stopping the slons with "kill <processid>", the redhat
> script uses "killproc slon". How can I kill the slon in my script?
> read the .pid file?

Yes, that's the reason for capturing the PID in that file.

> 4)I've jsut discovered the altperl scripts in the docs, and they look
> really useful. The docs say to run configure with "--with-perltools"
> before compiling and they'll get installed. I didn't do this. can I
(Continue reading)

Glyn Astill | 9 Jan 2008 18:23
Picon
Favicon

Re: Slony startup scripts

Hi Chris,

Thanks for the info.

I seem to be struggling using the conf file, I did

/usr/local/pgsql/bin/slon -f /data/postgres/slon.conf
>/data/postgres/slon.log 2>&1 &

I've specified the connection string and cluster in the conf file. Am
I missing something here?

Glyn

--- Christopher Browne <cbbrowne@...> wrote:

> Glyn Astill <glynastill@...> writes:
> > Until now I've been starting the slon daemon from the command
> line,
> > and now I wan't to move it to a startup script. Looking over
> things I
> > see I'm probably going to be best using a slon.conf file now as
> well.
> > this leaves me with a few questions.
> >
> > 1) I don't see any parameter in the slon.conf to set where my
> logs
> > go. Is this possible or do I just have to pipe the output to a
> file
> > like I'm already doing?
(Continue reading)

Glyn Astill | 9 Jan 2008 19:25
Picon
Favicon

Re: Slony startup scripts

I now get the following error:

Way5b:/data/postgres# /etc/init.d/slony start
Starting Slon: Starting /usr/local/pgsql/bin/slon...
2008-01-09 18:21:03 GMT ERROR  could not open configuration file
"/data/postgres/slon.conf"
2008-01-09 18:21:03 GMT CONFIG main: slon version 1.2.12 starting up

The file is there, is owned by postgres with read write permissions.

Any ideas

--- Glyn Astill <glynastill@...> wrote:

> Hi Chris,
> 
> Thanks for the info.
> 
> I seem to be struggling using the conf file, I did
> 
> /usr/local/pgsql/bin/slon -f /data/postgres/slon.conf
> >/data/postgres/slon.log 2>&1 &
> 
> I've specified the connection string and cluster in the conf file.
> Am
> I missing something here?
> 
> Glyn
> 
> --- Christopher Browne <cbbrowne@...> wrote:
(Continue reading)

Christopher Browne | 9 Jan 2008 19:51

Re: Slony startup scripts

Glyn Astill <glynastill@...> writes:
> I now get the following error:
>
> Way5b:/data/postgres# /etc/init.d/slony start
> Starting Slon: Starting /usr/local/pgsql/bin/slon...
> 2008-01-09 18:21:03 GMT ERROR  could not open configuration file
> "/data/postgres/slon.conf"
> 2008-01-09 18:21:03 GMT CONFIG main: slon version 1.2.12 starting up
>
> The file is there, is owned by postgres with read write permissions.
>
> Any ideas

Run strace against it to see if it says anything interesting?

e.g. - run:

% strace /path/to/slon -f /data/postgres/slon.conf > /tmp/output.log 2> /tmp/output.err

and then look through the trace to see what system calls failed
--

-- 
let name="cbbrowne" and tld="acm.org" in String.concat " <at> " [name;tld];;
http://cbbrowne.com/info/linuxdistributions.html
"It's like  a house   of cards  that   Godzilla  has  been  blundering
through."  -- Moon, describing how system messages work on ITS
Glyn Astill | 9 Jan 2008 20:01
Picon
Favicon

Re: Slony startup scripts

Actually.. How do I run strace from with my start script?

I'm basically doing:

prefix=/usr/local/pgsql
PGDATA="/data/postgres"
PGUSER="slony"
SLONLOG="$PGDATA/slon.log"
SLONCONF="-f $PGDATA/slon.conf"
SLONPID=="$PGDATA/slon.pid"
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON="$prefix/bin/slon"

start-stop-daemon --start --verbose --pidfile $SLONPID --chuid
$PGUSER --exec $DAEMON -- $SLONCONF 

--- Christopher Browne <cbbrowne@...> wrote:

> Glyn Astill <glynastill@...> writes:
> > I now get the following error:
> >
> > Way5b:/data/postgres# /etc/init.d/slony start
> > Starting Slon: Starting /usr/local/pgsql/bin/slon...
> > 2008-01-09 18:21:03 GMT ERROR  could not open configuration file
> > "/data/postgres/slon.conf"
> > 2008-01-09 18:21:03 GMT CONFIG main: slon version 1.2.12 starting
> up
> >
> > The file is there, is owned by postgres with read write
> permissions.
(Continue reading)

Christopher Browne | 9 Jan 2008 20:27

Re: Slony startup scripts

Glyn Astill <glynastill@...> writes:
> Actually.. How do I run strace from with my start script?
>
>
> I'm basically doing:
>
> prefix=/usr/local/pgsql
> PGDATA="/data/postgres"
> PGUSER="slony"
> SLONLOG="$PGDATA/slon.log"
> SLONCONF="-f $PGDATA/slon.conf"
> SLONPID=="$PGDATA/slon.pid"
> PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
> DAEMON="$prefix/bin/slon"
>
> start-stop-daemon --start --verbose --pidfile $SLONPID --chuid
> $PGUSER --exec $DAEMON -- $SLONCONF 

Actually, I think I now see the problem, at least partly.

I expect that "start-stop-daemon" isn't invoking slon the way it
expects to be invoked.

start-stop-daemon is presumably a function with a bunch of parameters
which then assembles a command line to use to invoke a daemon program.

I'll bet that it *isn't* assembling something looking like:

   /usr/local/pgsql/bin/slon -f /data/postgres/slon.conf

(Continue reading)

Glyn Astill | 10 Jan 2008 13:40
Picon
Favicon

Re: Slony startup scripts

Hi Chris,

It seems it may not be the start-stop-daemon afterall. I changed my
script to not use it and just start via su. 

E.g. I have this:

su - $PGUSER -c "$SLONDAEMON -f $SLONCONF &" >> "$SLONLOG" 2>&1 <
/dev/null
echo "su - $PGUSER -c '$SLONDAEMON -f $SLONCONF &' >> "$SLONLOG" 2>&1
< /dev/null"

And it echos to the screen the following

su - slony -c '/usr/local/pgsql/bin/slon -f /data/postgres/slon.conf'
>> /data/postgres/
slon.log 2>&1 < /dev/null

Does that look wrong?

Either way, I end up with the following in my log file:

2008-01-10 12:34:59 GMT ERROR  could not open configuration file
"/data/postgres/slon.conf"
2008-01-10 12:34:59 GMT CONFIG main: slon version 1.2.12 starting up
usage: /usr/local/pgsql/bin/slon [options] clustername conninfo

And slon.conf is there:

-rwxrw-rw- 1 slony slony 4513 2008-01-09 17:55
(Continue reading)

Glyn Astill | 10 Jan 2008 14:53
Picon
Favicon

Re: Slony startup scripts

Solved. It was permissions; I think I'd been staring at my monitor
too long.

I'm not using start-stop-daemon anymore, however I have tested it and
can confirm it works.

--- Glyn Astill <glynastill@...> wrote:

> Hi Chris,
> 
> It seems it may not be the start-stop-daemon afterall. I changed my
> script to not use it and just start via su. 
> 
> E.g. I have this:
> 
> su - $PGUSER -c "$SLONDAEMON -f $SLONCONF &" >> "$SLONLOG" 2>&1 <
> /dev/null
> echo "su - $PGUSER -c '$SLONDAEMON -f $SLONCONF &' >> "$SLONLOG"
> 2>&1
> < /dev/null"
> 
> And it echos to the screen the following
> 
> su - slony -c '/usr/local/pgsql/bin/slon -f
> /data/postgres/slon.conf'
> >> /data/postgres/
> slon.log 2>&1 < /dev/null
> 
> Does that look wrong?
> 
(Continue reading)

Glyn Astill | 10 Jan 2008 01:51
Picon
Favicon

Re: Slony startup scripts

Hi Chris,

In that case I shall take a look at putting together a script that
doesn't use the start-stop-daemon. The reason I did use it is I'm
really a novice when it comes to scripts and couldn't think how to
get the PID out of the file easily to do the kill part.

I'll tackle it again in the morning, if you have any ideas then I'd
be greatful.

Thanks
Glyn

--- Christopher Browne <cbbrowne@...> wrote:

> Glyn Astill <glynastill@...> writes:
> > Actually.. How do I run strace from with my start script?
> >
> >
> > I'm basically doing:
> >
> > prefix=/usr/local/pgsql
> > PGDATA="/data/postgres"
> > PGUSER="slony"
> > SLONLOG="$PGDATA/slon.log"
> > SLONCONF="-f $PGDATA/slon.conf"
> > SLONPID=="$PGDATA/slon.pid"
> > PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
> > DAEMON="$prefix/bin/slon"
> >
(Continue reading)

Glyn Astill | 9 Jan 2008 19:55
Picon
Favicon

Re: Slony startup scripts

Hi Chris,

If I do "/usr/local/pgsql/bin/slon -f /data/postgres/slon.conf" at in
the terminal it works, however it does not from the startup script.

Will try strace now...

--- Christopher Browne <cbbrowne@...> wrote:

> Glyn Astill <glynastill@...> writes:
> > I now get the following error:
> >
> > Way5b:/data/postgres# /etc/init.d/slony start
> > Starting Slon: Starting /usr/local/pgsql/bin/slon...
> > 2008-01-09 18:21:03 GMT ERROR  could not open configuration file
> > "/data/postgres/slon.conf"
> > 2008-01-09 18:21:03 GMT CONFIG main: slon version 1.2.12 starting
> up
> >
> > The file is there, is owned by postgres with read write
> permissions.
> >
> > Any ideas
> 
> Run strace against it to see if it says anything interesting?
> 
> e.g. - run:
> 
> % strace /path/to/slon -f /data/postgres/slon.conf >
> /tmp/output.log 2> /tmp/output.err
(Continue reading)

Christopher Browne | 9 Jan 2008 20:00

Re: Slony startup scripts

Glyn Astill <glynastill@...> writes:
> Hi Chris,
>
> If I do "/usr/local/pgsql/bin/slon -f /data/postgres/slon.conf" at in
> the terminal it works, however it does not from the startup script.
>
> Will try strace now...

Hmm.

I assume you're specifying full path names in the startup script, so
it's not running afoul of (say) having $PATH defined differently.

The only other thing that comes to mind is that sometimes ulimit
settings differ when running init as compared to a user shell.  But I
can't think of what resource the system would decline to give because
of this; usually the problem is along the lines of getting
insufficient memory space, but that doesn't seem like the problem
you're having.
--

-- 
(reverse (concatenate 'string "moc.enworbbc" " <at> " "enworbbc"))
http://www3.sympatico.ca/cbbrowne/languages.html
Rules  of  the Evil  Overlord  #93.  "If I  decide  to  hold a  double
execution of  the hero and an  underling who failed or  betrayed me, I
will  see   to  it   that  the  hero   is  scheduled  to   go  first."
<http://www.eviloverlord.com/>

Gmane