3 # slony replication setup
5 # usage: slony-setup freesideuser
9 use FS::UID qw(adminsuidsetup);
10 use FS::Record qw(dbdef);
12 my $user = shift or die "usage: slony-setup username\n";
13 adminsuidsetup($user);
17 my $MASTERHOST = '192.168.20.10';
18 my $SLAVEHOST = '192.168.20.50';
19 #my $REPLICATIONUSER='pgsql';
20 my $REPLICATIONUSER='postgres';
28 cp -pr /etc/skel /home/freeside
29 chown -R freeside /home/freeside
31 su postgres -c 'createuser freeside' #n y n
32 su freeside -c 'createdb freeside'
35 su postgres -c 'createlang plpgsql freeside'
37 pg_dump -s -U $REPLICATIONUSER -h $MASTERHOST freeside | psql -U $REPLICATIONUSER -h $SLAVEHOST freeside
43 #drop set ( id = 1, origin = 1);
49 cluster name = freeside;
50 node 1 admin conninfo = 'dbname=freeside host=$MASTERHOST user=$REPLICATIONUSER';
51 node 2 admin conninfo = 'dbname=freeside host=$SLAVEHOST user=$REPLICATIONUSER';
52 init cluster ( id=1, comment = 'Master Node');
54 create set (id=1, origin=1, comment='All freeside tables');
60 foreach my $table ( dbdef->tables ) {
61 #next if $table =~ /^sql_/i;
62 print "set add table (set id=1, origin=1, id=". $id++. ", fully qualified name = 'public.$table' );\n";
68 store node (id=2, comment = 'Slave node');
69 store path (server = 1, client = 2, conninfo='dbname=freeside host=$MASTERHOST user=$REPLICATIONUSER');
70 store path (server = 2, client = 1, conninfo='dbname=freeside host=$SLAVEHOST user=$REPLICATIONUSER');
71 store listen (origin=1, provider = 1, receiver =2);
72 store listen (origin=2, provider = 2, receiver =1);
79 ### start slon processes (both machines) (this is debian-specific)
80 mkdir /etc/slony1/freeside
82 cat >/etc/slony1/freeside/slon.conf <<_EOF_
83 # Set the cluster name that this instance of slon is running against
84 # default is to read it off the command line
85 cluster_name='freeside'
87 # Set slon's connection info, default is to read it off the command line
88 conn_info='host=localhost port=5432 dbname=freeside user=postgres'
91 /etc/init.d/slony1 start
100 cluster name = freeside;
102 node 1 admin conninfo = 'dbname=freeside host=$MASTERHOST user=$REPLICATIONUSER';
103 node 2 admin conninfo = 'dbname=freeside host=$SLAVEHOST user=$REPLICATIONUSER';
105 subscribe set ( id = 1, provider = 1, receiver = 2, forward = no);