slony전용 클러스터의 작성
①slony専用クラスタの作成
/var/atgames/slony/init_cluster_replace_setup.sh
-----(atgames01の場合)-----
#!/bin/bash
HOST1=172.19.1.31
PGDATABASE=atgames01
PGUSER=postgres
PGPORT=5432
PSQL=/usr/local/postgresql/bin/psql
SLONIK=/usr/local/slony/bin/slonik
$SLONIK <<_EOF_
cluster name = atgames01cluster;
node 1 admin conninfo='host=$HOST1 dbname=$PGDATABASE user=$PGUSER port=$PGPORT';
init cluster ( id=1, comment = 'Master Node');
_EOF_
$SLONIK <<_EOF_
-----
実行するのにあたって、slonyのプログラムが必要かと思います。
↓
SLONIK=/usr/local/slony/bin/slonik
以下に展開して保存しました。
$ ls -la /usr/local/ | grep slony
lrwxrwxrwx 1 root root 15 1月 28 17:02 slony -> slony1-1.2.14rc
drwxr-xr-x 4 root root 4096 1月 28 17:00 slony1-1.2.14rc
②リストアの実行
③slonyのdeny制御解除
psqlで接続後、以下の更新を実行
-----(atgames01の場合)-----
BEGIN;
drop index _atgames01cluster.sl_table_tab_reloid_key;
update _atgames01cluster.sl_table set
tab_reloid = subq.relid
from
(select
relname,
relid
from
pg_stat_all_tables
) subq
where
_atgames01cluster.sl_table.tab_relname = subq.relname
;
select relid,tab_reloid,relname from pg_stat_all_tables inner join
_atgames01cluster.sl_table on relname=tab_relname order by relname;
COMMIT;
④slony 스키마의 삭제
/var/atgames/slony/uninstall_cluster_replace_setup.sh
-----(atgames01의 경우)-----
#!/bin/sh
#master hostname
HOST1=172.19.1.31
#PostgreSQL USENAME
PGUSER=postgres
#PostgreSQL PORT
PGPORT=5432
#PostgreSQL DATABASE NAME
PGDATABASE=atgames01
CLUSTER1=atgames01cluster
SLONIK=/usr/local/slony/bin/slonik
$SLONIK <<_EOF_
cluster name = $CLUSTER1;
node 1 admin conninfo='host=$HOST1 dbname=$PGDATABASE user=$PGUSER port=$PGPORT';
uninstall node (id = 1);
_EOF_
-----