[postgres@testvm1 ~]$ bzip2 -d slony1-2.2.3.tar.bz2
[postgres@testvm1 ~]$ tar xf slony1-2.2.3.tar
[postgres@testvm1 ~]$ cd slony1-2.2.3
[postgres@testvm1 slony1-2.2.3]$ ./configure --prefix=$PGHOME --with-pgconfigdir=$PGHOME/bin --with-perltools
[postgres@testvm1 slony1-2.2.3]$ gmake all; gmake install
[postgres@testvm1 ~]$ createuser -s slony -W
Password:
[postgres@testvm1 ~]$ vi $PGDATA/pg_hba.conf
host all slony testvm1 trust
host all slony testvm2 trust
[postgres@testvm1 ~]$ pg_ctl reload
LOG: received SIGHUP, reloading configuration files
server signaled
[postgres@testvm2 slony1-2.2.3]$ createuser -s slony -W
Password:
postgres@testvm1 ~]$ vi $PGDATA/pg_hba.conf
host all slony testvm1 trust
host all slony testvm2 trust
[postgres@testvm1 ~]$ pg_ctl reload
LOG: received SIGHUP, reloading configuration files
server signaled
[postgres@testvm1 ~]$ createuser -SRD pgbench -W
Password:
[postgres@testvm1 ~]$ createdb -O pgbench pgbench
[postgres@testvm2 ~]$ createuser -SRD pgbench -W
Password:
[postgres@testvm2 ~]$ createdb -O pgbench pgbench
[postgres@testvm1 ~]$ cd /db/postgres-9.3.5/contrib/pgbench/
[postgres@testvm1 pgbench]$ make install
/bin/mkdir -p '/db/postgres/bin'
/usr/bin/install -c pgbench '/db/postgres/bin'
[postgres@testvm1 pgbench]$ pgbench -i -s 1 -U pgbench pgbench
NOTICE: table "pgbench_history" does not exist, skipping
NOTICE: table "pgbench_tellers" does not exist, skipping
NOTICE: table "pgbench_accounts" does not exist, skipping
NOTICE: table "pgbench_branches" does not exist, skipping
creating tables...
100000 of 100000 tuples (100%) done (elapsed 0.41 s, remaining 0.00 s).
vacuum...
set primary keys...
done.
[postgres@testvm1 pgbench]$ psql -U pgbench pgbench
psql (9.3.5)
Type "help" for help.
pgbench=> d+ pgbench_history;
Table "public.pgbench_history"
Column | Type | Modifiers | Storage | Stats target | Description
--------+-----------------------------+-----------+----------+--------------+-------------
tid | integer | | plain | |
bid | integer | | plain | |
aid | integer | | plain | |
delta | integer | | plain | |
mtime | timestamp without time zone | | plain | |
filler | character(22) | | extended | |
Has OIDs: no
pgbench=> begin;
BEGIN
pgbench=> alter table pgbench_history add column id serial;
ALTER TABLE
pgbench=> update pgbench_history set id=nextval('pgbench_history_id_seq');
UPDATE 0
pgbench=> alter table pgbench_history add primary key(id);
ALTER TABLE
pgbench=> commit;
COMMIT
pgbench=>
[postgres@testvm1 ~]$ createlang plpgsql pgbench
createlang: language "plpgsql" is already installed in database "pgbench"
[postgres@testvm1 ~]$ pg_dump -s pgbench | psql -U slony -h testvm2 pgbench
SET
SET
SET
SET
SET
SET
CREATE EXTENSION
COMMENT
SET
SET
SET
CREATE TABLE
ALTER TABLE
CREATE TABLE
ALTER TABLE
CREATE TABLE
ALTER TABLE
CREATE SEQUENCE
ALTER TABLE
ALTER SEQUENCE
CREATE TABLE
ALTER TABLE
ALTER TABLE
ALTER TABLE
ALTER TABLE
ALTER TABLE
ALTER TABLE
REVOKE
REVOKE
GRANT
GRANT
[postgres@testvm1 pgdba]$ vi slon_build.sh
#!/bin/sh
SLONDIR=/db/pgdba/slony1
mkdir -p $SLONDIR/conf
mkdir -p $SLONDIR/logs
CONF=/db/pgdba/slony1/conf/slon_tools.conf
cat << EOF > $CONF
$CLUSTER_NAME = 'slony1';
$LOGDIR = '$SLONDIR/logs';
$PIDFILE_DIR = '$SLONDIR';
$MASTERNODE = 1;
EOF
slonik_build_env
-node testvm1:pgbench:slony:slony
-node testvm2:pgbench:slony:slony >> $CONF
cat << EOF >> $CONF
$SLONY_SETS = {
"set1" => {
"set_id" => 1,
"table_id" => 1,
"sequence_id" => 1,
"pkeyedtables" => @PKEYEDTABLES,
"sequences" => @SEQUENCES,
}
}
EOF
[postgres@testvm1 pgdba]$ sh +x slon_build.sh
[postgres@testvm1 pgdba]$ vi slony1/conf/slon_tools.conf
$CLUSTER_NAME = 'slony1';
$LOGDIR = '/db/pgdba/slony1/logs';
$PIDFILE_DIR = '/db/pgdba/slony1';
$MASTERNODE = 1;
&add;_node(host => 'testvm1', dbname => 'pgbench', port =>5432,
user=>'slony', password=>'slony', node=>1 );
&add;_node(host => 'testvm2', dbname => 'pgbench', port =>5432,
user=>'slony', password=>'slony', node=>2 , parent=>1);
@PKEYEDTABLES=(
"public.pgbench_accounts",
"public.pgbench_branches",
"public.pgbench_history",
"public.pgbench_tellers",
);
@SEQUENCES=(
"public.pgbench_history_id_seq",
);
$SLONY_SETS = {
"set1" => {
"set_id" => 1,
"table_id" => 1,
"sequence_id" => 1,
"pkeyedtables" => @PKEYEDTABLES,
"sequences" => @SEQUENCES,
}
}
[postgres@testvm1 pgdba]$ slonik_init_cluster --config=/db/pgdba/slony1/conf/slon_tools.conf |slonik
:10: Set up replication nodes
:13: Next: configure paths for each node/origin
:16: Replication nodes prepared
:17: Please start a slon replication daemon for each node
[postgres@testvm1 pgdba]$
[postgres@testvm1 pgdba]$ slon_start --config=/db/pgdba/slony1/conf/slon_tools.conf 1
Invoke slon for node 1 - /db/postgres/bin/slon -p /db/pgdba/slony1/slony1_node1.pid -s 1000 -d0 slony1 'host=testvm1 dbname=pgbench user=slony port=5432 password=slony' > /db/pgdba/slony1/logs/node1/pgbench-2014-12-09.log 2>&1 &
Slon successfully started for cluster slony1, node node1
PID [32334]
Start the watchdog process as well...
[postgres@testvm1 pgdba]$ slon_start --config=/db/pgdba/slony1/conf/slon_tools.conf 2