Armand Pirvu (home)
2015-11-17 03:32:14 UTC
Hi
Please pardon the length of this email but I felt it is best to give a global view
I was looking at slonik for a project.
All the setup info, tutorials etc etc seems to vary
http://raghavt.blogspot.com/2012/07/simple-slony-i-replication-setup.html
and
http://www.linuxjournal.com/article/7834
Just to name two sources of study
So I used two approaches
1 - Passing commands to slonik directly. All ok
2 - Using the provided perl scripts . Not ok and this is where I would like some tips , guidance
master node: 192.168.5.221
master db: primdb
slave node: 192.168.5.222
slave db: bkdb
I use .pgpass
/etc/slony1-94/slon_tools.conf
I stripped out all comments to keep things to a minimum
1 #
2 # Author: Christopher Browne
3 # Copyright 2004-2009 Afilias Canada
4 # Revised extensively by Steve Simms
5
6 # Keeping the following three lines for backwards compatibility in
7 # case this gets incorporated into a 1.0.6 release.
8 #
9 # TODO: The scripts should check for an environment variable
10 # containing the location of a configuration file. That would
11 # simplify this configuration file and allow Slony-I tools to still work
12 # in situations where it doesn't exist.
13 #
14 if ($ENV{"SLONYNODES"}) {
15 require $ENV{"SLONYNODES"};
16 } else {
17
21 $CLUSTER_NAME = 'armandpc';
26 $PIDFILE_DIR = '/var/run/slony1';
36 $LOGDIR = '/var/log/slony1-94';
53 $MASTERNODE = 1;
56 $DEBUGLEVEL = 2;
63 $SLEEP_TIME = 60;
64
65 # Watchdog version to use 1 or 2 (default 1)
66 # $WATCHDOG_VERSION = 1;
67 # Be verbose (default 1)
68 $WATCHDOG_VERBOSE = 0;
75 add_node(node => 1,
76 host => '192.168.5.221',
77 dbname => 'primdb',
78 port => 5432,
79 user => 'postgres',
80 password => '',
81 config => '/etc/slony1-94/slon_tools.conf');
83 add_node(node => 2,
84 host => '192.168.5.222',
85 dbname => 'bkdb',
86 port => 5432,
87 user => 'postgres',
88 password => '',
89 config => '/etc/slony1-94/slon_tools.conf');
91 }
96 $SLONY_SETS = {
98 # A unique name for the set
99 "set1_1" => {
101 # The set_id, also unique
102 "set_id" => 1,
127 "table_id" => 1,
128 "sequence_id" => 1,
132 "pkeyedtables" => [
133 'test1',
134 ],
138 "keyedtables" => {},
139 "sequences" => [],
140 },
142 };
152 if ($ENV{"SLONYSET"}) {
153 require $ENV{"SLONYSET"};
154 }
156 # Please do not add or change anything below this point.
157 1;
And now the questions/steps
a - add_node(node => 1,
host => '192.168.5.221',
dbname => 'primdb',
port => 5432,
user => 'postgres',
password => '',
config => '/path/to/node1_config_file.conf');
I presume this would be config => '/etc/slony1-94/slon_tools.conf' or am I wrong ?
b - "pkeyedtables" => [
'test1',
],
The table name in single or double quotes ? I saw an example with double quotes
c - steps done
/usr/pgsql-9.4/bin/slonik_init_cluster -c /etc/slony1-94/slon_tools.conf
# INIT CLUSTER
cluster name = armandpc;
node 1 admin conninfo='host=192.168.5.221 dbname=primdb user=postgres port=5432';
node 2 admin conninfo='host=192.168.5.222 dbname=bkdb user=postgres port=5432';
init cluster (id = 1, comment = 'Node 1 - ***@192.168.5.221');
# STORE NODE
store node (id = 2, event node = 1, comment = 'Node 2 - ***@192.168.5.222');
echo 'Set up replication nodes';
# STORE PATH
echo 'Next: configure paths for each node/origin';
store path (server = 1, client = 2, conninfo = 'host=192.168.5.221 dbname=primdb user=postgres port=5432');
store path (server = 2, client = 1, conninfo = 'host=192.168.5.222 dbname=bkdb user=postgres port=5432');
echo 'Replication nodes prepared';
echo 'Please start a slon replication daemon for each node';
-bash-4.1$ /usr/pgsql-9.4/bin/slonik_init_cluster -c /etc/slony1-94/slon_tools.conf |/usr/pgsql-9.4/bin/slonik
<stdin>:10: Set up replication nodes
<stdin>:13: Next: configure paths for each node/origin
<stdin>:16: Replication nodes prepared
<stdin>:17: Please start a slon replication daemon for each node
/usr/pgsql-9.4/bin/slonik_create_set -c /etc/slony1-94/slon_tools.conf 1
cluster name = armandpc;
node 1 admin conninfo='host=192.168.5.221 dbname=primdb user=postgres port=5432';
node 2 admin conninfo='host=192.168.5.222 dbname=bkdb user=postgres port=5432';
# TABLE ADD KEY
# CREATE SET
create set (id = 1, origin = 1, comment = 'Set 1 (set1_1) for armandpc');
# SET ADD TABLE
echo 'Subscription set 1 (set1_1) created';
echo 'Adding tables to the subscription set';
set add table (set id = 1, origin = 1, id = 1,
full qualified name = 'public.test1',
comment = 'Table public.test1 with primary key');
echo 'Add primary keyed table public.test1';
# SET ADD SEQUENCE
echo 'Adding sequences to the subscription set';
echo 'All tables added';
/usr/pgsql-9.4/bin/slonik_create_set -c slon.conf 1|/usr/pgsql-9.4/bin/slonik
<stdin>:11: Subscription set 1 (set1_1) created
<stdin>:12: Adding tables to the subscription set
<stdin>:16: Add primary keyed table public.test1
<stdin>:19: Adding sequences to the subscription set
<stdin>:20: All tables added
/usr/pgsql-9.4/bin/slon_start -c /etc/slony1-94/slon_tools.conf 1 &
fails to start
2015-11-16 20:59:50 CST ERROR syntax error in file "/etc/slony1-94/slon_tools.conf" line 13, near end of line
2015-11-16 20:59:50 CST CONFIG main: slon version 2.2.4 starting up
usage: /usr/pgsql-9.4/bin/slon [options] clustername conninfo
Options:
-h print usage message and exit
-v print version and exit
-d <debuglevel> verbosity of logging (1..4)
-s <milliseconds> SYNC check interval (default 10000)
-t <milliseconds> SYNC interval timeout (default 60000)
-o <milliseconds> desired subscriber SYNC processing time
-g <num> maximum SYNC group size (default 6)
-c <num> how often to vacuum in cleanup cycles
-p <filename> slon pid file
-f <filename> slon configuration file
-a <directory> directory to store SYNC archive files
-x <command> program to run after writing archive file
-q <num> Terminate when this node reaches # of SYNCs
-r <num> # of syncs for -q option
-l <interval> this node should lag providers by this interval
So what gives ? How do I debug, fix , move forward ? Aside the doc which maybe I missed , has an example which yes it works but it not going in all these details, any other examples and so on ?
Many thanks
Armand
Please pardon the length of this email but I felt it is best to give a global view
I was looking at slonik for a project.
All the setup info, tutorials etc etc seems to vary
http://raghavt.blogspot.com/2012/07/simple-slony-i-replication-setup.html
and
http://www.linuxjournal.com/article/7834
Just to name two sources of study
So I used two approaches
1 - Passing commands to slonik directly. All ok
2 - Using the provided perl scripts . Not ok and this is where I would like some tips , guidance
master node: 192.168.5.221
master db: primdb
slave node: 192.168.5.222
slave db: bkdb
I use .pgpass
/etc/slony1-94/slon_tools.conf
I stripped out all comments to keep things to a minimum
1 #
2 # Author: Christopher Browne
3 # Copyright 2004-2009 Afilias Canada
4 # Revised extensively by Steve Simms
5
6 # Keeping the following three lines for backwards compatibility in
7 # case this gets incorporated into a 1.0.6 release.
8 #
9 # TODO: The scripts should check for an environment variable
10 # containing the location of a configuration file. That would
11 # simplify this configuration file and allow Slony-I tools to still work
12 # in situations where it doesn't exist.
13 #
14 if ($ENV{"SLONYNODES"}) {
15 require $ENV{"SLONYNODES"};
16 } else {
17
21 $CLUSTER_NAME = 'armandpc';
26 $PIDFILE_DIR = '/var/run/slony1';
36 $LOGDIR = '/var/log/slony1-94';
53 $MASTERNODE = 1;
56 $DEBUGLEVEL = 2;
63 $SLEEP_TIME = 60;
64
65 # Watchdog version to use 1 or 2 (default 1)
66 # $WATCHDOG_VERSION = 1;
67 # Be verbose (default 1)
68 $WATCHDOG_VERBOSE = 0;
75 add_node(node => 1,
76 host => '192.168.5.221',
77 dbname => 'primdb',
78 port => 5432,
79 user => 'postgres',
80 password => '',
81 config => '/etc/slony1-94/slon_tools.conf');
83 add_node(node => 2,
84 host => '192.168.5.222',
85 dbname => 'bkdb',
86 port => 5432,
87 user => 'postgres',
88 password => '',
89 config => '/etc/slony1-94/slon_tools.conf');
91 }
96 $SLONY_SETS = {
98 # A unique name for the set
99 "set1_1" => {
101 # The set_id, also unique
102 "set_id" => 1,
127 "table_id" => 1,
128 "sequence_id" => 1,
132 "pkeyedtables" => [
133 'test1',
134 ],
138 "keyedtables" => {},
139 "sequences" => [],
140 },
142 };
152 if ($ENV{"SLONYSET"}) {
153 require $ENV{"SLONYSET"};
154 }
156 # Please do not add or change anything below this point.
157 1;
And now the questions/steps
a - add_node(node => 1,
host => '192.168.5.221',
dbname => 'primdb',
port => 5432,
user => 'postgres',
password => '',
config => '/path/to/node1_config_file.conf');
I presume this would be config => '/etc/slony1-94/slon_tools.conf' or am I wrong ?
b - "pkeyedtables" => [
'test1',
],
The table name in single or double quotes ? I saw an example with double quotes
c - steps done
/usr/pgsql-9.4/bin/slonik_init_cluster -c /etc/slony1-94/slon_tools.conf
# INIT CLUSTER
cluster name = armandpc;
node 1 admin conninfo='host=192.168.5.221 dbname=primdb user=postgres port=5432';
node 2 admin conninfo='host=192.168.5.222 dbname=bkdb user=postgres port=5432';
init cluster (id = 1, comment = 'Node 1 - ***@192.168.5.221');
# STORE NODE
store node (id = 2, event node = 1, comment = 'Node 2 - ***@192.168.5.222');
echo 'Set up replication nodes';
# STORE PATH
echo 'Next: configure paths for each node/origin';
store path (server = 1, client = 2, conninfo = 'host=192.168.5.221 dbname=primdb user=postgres port=5432');
store path (server = 2, client = 1, conninfo = 'host=192.168.5.222 dbname=bkdb user=postgres port=5432');
echo 'Replication nodes prepared';
echo 'Please start a slon replication daemon for each node';
-bash-4.1$ /usr/pgsql-9.4/bin/slonik_init_cluster -c /etc/slony1-94/slon_tools.conf |/usr/pgsql-9.4/bin/slonik
<stdin>:10: Set up replication nodes
<stdin>:13: Next: configure paths for each node/origin
<stdin>:16: Replication nodes prepared
<stdin>:17: Please start a slon replication daemon for each node
/usr/pgsql-9.4/bin/slonik_create_set -c /etc/slony1-94/slon_tools.conf 1
cluster name = armandpc;
node 1 admin conninfo='host=192.168.5.221 dbname=primdb user=postgres port=5432';
node 2 admin conninfo='host=192.168.5.222 dbname=bkdb user=postgres port=5432';
# TABLE ADD KEY
# CREATE SET
create set (id = 1, origin = 1, comment = 'Set 1 (set1_1) for armandpc');
# SET ADD TABLE
echo 'Subscription set 1 (set1_1) created';
echo 'Adding tables to the subscription set';
set add table (set id = 1, origin = 1, id = 1,
full qualified name = 'public.test1',
comment = 'Table public.test1 with primary key');
echo 'Add primary keyed table public.test1';
# SET ADD SEQUENCE
echo 'Adding sequences to the subscription set';
echo 'All tables added';
/usr/pgsql-9.4/bin/slonik_create_set -c slon.conf 1|/usr/pgsql-9.4/bin/slonik
<stdin>:11: Subscription set 1 (set1_1) created
<stdin>:12: Adding tables to the subscription set
<stdin>:16: Add primary keyed table public.test1
<stdin>:19: Adding sequences to the subscription set
<stdin>:20: All tables added
/usr/pgsql-9.4/bin/slon_start -c /etc/slony1-94/slon_tools.conf 1 &
fails to start
2015-11-16 20:59:50 CST ERROR syntax error in file "/etc/slony1-94/slon_tools.conf" line 13, near end of line
2015-11-16 20:59:50 CST CONFIG main: slon version 2.2.4 starting up
usage: /usr/pgsql-9.4/bin/slon [options] clustername conninfo
Options:
-h print usage message and exit
-v print version and exit
-d <debuglevel> verbosity of logging (1..4)
-s <milliseconds> SYNC check interval (default 10000)
-t <milliseconds> SYNC interval timeout (default 60000)
-o <milliseconds> desired subscriber SYNC processing time
-g <num> maximum SYNC group size (default 6)
-c <num> how often to vacuum in cleanup cycles
-p <filename> slon pid file
-f <filename> slon configuration file
-a <directory> directory to store SYNC archive files
-x <command> program to run after writing archive file
-q <num> Terminate when this node reaches # of SYNCs
-r <num> # of syncs for -q option
-l <interval> this node should lag providers by this interval
So what gives ? How do I debug, fix , move forward ? Aside the doc which maybe I missed , has an example which yes it works but it not going in all these details, any other examples and so on ?
Many thanks
Armand