2

I'm trying to use the example that comes in the slony tutorial but it looks like there is a syntax error in their example. I've tried finding more documentation online but I've yet to really find good documentation showing how to use the slonik command. The script I am trying to run is:

#!/bin/sh

/opt/local/lib/postgresql90/bin/slonik << _EOL_

define CLUSTERNAME slony_example;
cluster name = @CLUSTERNAME;

node 1 admin conninfo = 'dbname=my_primary host=$MASTERHOST user=$REPLICATIONUSER'; 
node 2 admin conninfo = 'dbname=my_rep host=$SLAVEHOST user=$REPLICATIONUSER';

#-- 
# init the first node. Its id MUST be 1. This creates the schema # _$CLUSTERNAME containing all replication system specific database # objects.
#-- 
init cluster ( id=1, comment = 'Master Node');

#--
# Slony-I organizes tables into sets. The smallest unit a node can # subscribe is a set. The following commands create one set containing # all 4 pgbench tables. The master or origin of the set is node 1. 
#-- 
create set (id=1, origin=1, comment='All pgbench tables'); 
set add table (set id=1, origin=1, id=1, fully qualified name ='public.pgbench_accounts', comment='accounts table'); 
set add table (set id=1, origin=1, id=2, fully qualified name ='public.pgbench_branches', comment='branches table'); 
set add table (set id=1, origin=1, id=3, fully qualified name ='public.pgbench_tellers', comment='tellers table'); 
set add table (set id=1, origin=1, id=4, fully qualified name ='public.pgbench_history', comment='history table');

#-- 
# Create the second node (the slave) tell the 2 nodes how to connect to Slony-I 2.1.1 Documentation 10 / 163
# each other and how they should listen for events.
#--

store node (id=2, comment = 'Slave node', event node=1);
store path (server = 1, client = 2, conninfo='dbname=my_primary host=$MASTERHOST user=$REPLICATIONUSER');
store path (server = 2, client = 1, conninfo='dbname=my_rep host=$SLAVEHOST user=$REPLICATIONUSER');

_EOF_

But I keep getting the following error:

postgres$ /tmp/slonik_example.sh
<stdin>:29: ERROR: syntax error at or near dbname

Updating script above based on first answer. Error now is:

postgres$ /tmp/slonik_example.sh
<stdin>:31: ERROR: syntax error at or near _EOF_
WildBill
  • 9,143
  • 15
  • 63
  • 87
  • Slony can be a harsh teacher in many ways. I started in the same manner as you, writing the configuration by hand, and it is a good way to understand the fundamentals. After getting familiar with Slony I started using altperl tools. http://slony.info/documentation/appendix.html#ALTPERL – John P Feb 20 '12 at 15:59
  • Thanks, I'll look at that as well. Are you aware of other good example of how to use slonik? It seems very sparsely documented. – WildBill Feb 20 '12 at 16:20
  • As I worked with Slony some years ago it was my ambition to write down a tutorial but I didn't have the time to finalize it. But here is quite good synopsis. http://www.dalibo.org/_media/pgconfeu_slony.pdf – John P Feb 20 '12 at 21:14

1 Answers1

2

You've got unbalanced quotes:

store path (server = 1, client = 2, conninfo='dbname=my_primary host=$MASTERHOST user= '$REPLICATIONUSER');
store path (server = 2, client = 1, conninfo='dbname=my_rep host=$SLAVEHOST user= '$REPLICATIONUSER');

You probably want:

store path (server = 1, client = 2, conninfo="dbname=my_primary host=$MASTERHOST user=$REPLICATIONUSER");
store path (server = 2, client = 1, conninfo="dbname=my_rep host=$SLAVEHOST user=$REPLICATIONUSER");
Alex Howansky
  • 50,515
  • 8
  • 78
  • 98