[freeside-commits] freeside/bin slony-setup,1.2,1.3

Ivan,,, ivan at wavetail.420.am
Tue Mar 6 11:56:43 PST 2007


Update of /home/cvs/cvsroot/freeside/bin
In directory wavetail:/tmp/cvs-serv5745

Modified Files:
	slony-setup 
Log Message:
slight update for slony setup script

Index: slony-setup
===================================================================
RCS file: /home/cvs/cvsroot/freeside/bin/slony-setup,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- slony-setup	2 Apr 2005 23:49:29 -0000	1.2
+++ slony-setup	6 Mar 2007 19:56:41 -0000	1.3
@@ -1,35 +1,56 @@
 #!/usr/bin/perl
 #
-# hack to update/add read-only permissions for a user on the db
-#
-# usage: pg-readonly freesideuser readonlyuser
+# slony replication setup
+# 
+# usage: slony-setup freesideuser
 
 use strict;
 use DBI;
 use FS::UID qw(adminsuidsetup);
 use FS::Record qw(dbdef);
 
-my $user = shift or die &usage;
+my $user = shift or die "usage: slony-setup username\n";
 adminsuidsetup($user);
 
 #---
 
-#su postgres -c 'createlang plpgsql freeside'
-
-#---
-
-my $MASTERHOST = '172.21.0.204';
-my $SLAVEHOST = '172.21.0.205';
+my $MASTERHOST = '192.168.20.10';
+my $SLAVEHOST = '192.168.20.50';
 #my $REPLICATIONUSER='pgsql';
 my $REPLICATIONUSER='postgres';
 
+#--------
+
+print <<END;
+
+#on slave:
+useradd freeside
+cp -pr /etc/skel /home/freeside
+chown -R freeside /home/freeside
+
+su postgres -c 'createuser freeside' #n y n
+su freeside -c 'createdb freeside'
+
+#on master:
+su postgres -c 'createlang plpgsql freeside'
+
+pg_dump -s -U $REPLICATIONUSER -h $MASTERHOST freeside | psql -U $REPLICATIONUSER -h $SLAVEHOST freeside
+
+END
+
+#--------
+
 #drop set ( id = 1, origin = 1);
 
 print <<END;
+#on master:
+slonik <<_EOF_
+
 cluster name = freeside;
 node 1 admin conninfo = 'dbname=freeside host=$MASTERHOST user=$REPLICATIONUSER';
 node 2 admin conninfo = 'dbname=freeside host=$SLAVEHOST user=$REPLICATIONUSER';
 init cluster ( id=1, comment = 'Master Node');
+
 create set (id=1, origin=1, comment='All freeside tables');
 
 END
@@ -43,11 +64,46 @@
 }
 
 print <<END;
+
 store node (id=2, comment = 'Slave node');
 store path (server = 1, client = 2, conninfo='dbname=freeside host=$MASTERHOST user=$REPLICATIONUSER');
 store path (server = 2, client = 1, conninfo='dbname=freeside host=$SLAVEHOST user=$REPLICATIONUSER');
 store listen (origin=1, provider = 1, receiver =2);
 store listen (origin=2, provider = 2, receiver =1);
+
+_EOF_
+END
+
+print <<END;
+
+### start slon processes (both machines) (this is debian-specific)
+mkdir /etc/slony1/freeside
+
+cat >/etc/slony1/freeside/slon.conf <<_EOF_
+# Set the cluster name that this instance of slon is running against
+# default is to read it off the command line
+cluster_name='freeside'
+
+# Set slon's connection info, default is to read it off the command line
+conn_info='host=localhost port=5432 dbname=freeside user=postgres'
+_EOF_
+
+/etc/init.d/slony1 start
+
 END
 
 
+print <<END;
+#on master:
+slonik <<_EOF_
+
+cluster name = freeside;
+
+node 1 admin conninfo = 'dbname=freeside host=$MASTERHOST user=$REPLICATIONUSER';
+node 2 admin conninfo = 'dbname=freeside host=$SLAVEHOST user=$REPLICATIONUSER';
+
+subscribe set ( id = 1, provider = 1, receiver = 2, forward = no);
+
+_EOF_
+END
+



More information about the freeside-commits mailing list