Scott Marlowe smarlowe
Thu Mar 3 15:28:03 PST 2005
On Wed, 2005-03-02 at 18:58, murphy pope wrote:
> (apologies in advance if this has already been discussed and
> dismissed...)
> 
> Since every slonik script must start with a "cluster" command and a
> series of node definitions, I'd like to store those definitions in a
> single file and then talk slonik into "including" that file when I run
> another script.  
> 
> I can think of three ways to do that:
> 
> 1) Add an include(  'filename' ) mechanism to the slonik grammar
> 2) Add a command-line option that tells slonik to read a named file
> before executing the main script(s)
> 3) Make slonik read a ~/.slonikrc file 

I just source a file.  i.e. things like:

-------- BEGIN ------------

#!/bin/bash
                                                                                                                  
export CLUSTERNAME=bigdb
export MASTERDBNAME=bigdb
export SLAVEDBNAME=bigdb
export MASTERHOST=pg01
export SLAVEHOST=pg02
export REPLICATIONUSER=postgres

-------- END --------------

and then in the slonik scripts I just do:

--------BEGIN ---------

#!/bin/bash
                                                                                                                  
source ./envars
slonik <<_EOF_
    # ----
    # This defines which namespace the replication system uses
    # ----
    cluster name = $CLUSTERNAME;
                                                                                                                  
    # ----
    # Admin conninfo's are used by the slonik program to connect
    # to the node databases.  So these are the PQconnectdb arguments
    # that connect from the administrators workstation (where
    # slonik is executed).
    # ----
    node 1 admin conninfo = 'dbname=$MASTERDBNAME host=$MASTERHOST
user=$REPLICATIONUSER';
    node 2 admin conninfo = 'dbname=$SLAVEDBNAME host=$SLAVEHOST
user=$REPLICATIONUSER';
                                                                                                                  
    # ----
    # Node 2 subscribes set 1
    # ----
    subscribe set ( id = 1, provider = 1, receiver = 2, forward = no);
_EOF_

---------------- END ----------

That works pretty well for me.  But I'm not against patches or anything.


More information about the Slony1-general mailing list