Slony1 增加表复制

前端之家收集整理的这篇文章主要介绍了Slony1 增加表复制前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

如果想向一个复制集里面增加新的表,可以用以下脚本:

#!/bin/sh
source ./replinit.sh
TABLEID=$1
TABLENAME=$2
$SLONIK << _END_
#
# Define cluster namespace and node connection information
#
cluster name = $CLUSTER;
node $MASTERNODE admin conninfo = 'dbname=$MASTER_DB host=$MASTER_IP port=5432 user=$REPLUSER password=$REPLPWD';
node $SLAVENODE admin conninfo = 'dbname=$SLAVE_DB host=$SLAVE_IP port=5432 user=$REPLUSER password=$REPLPWD';
create set (id=999,origin=$MASTERNODE,comment='add $TABLENAME table');
set add table (set id=999,id=$TABLEID,fully qualified name ='public.$TABLENAME',comment='Table $TABLENAME ');


#
SUBSCRIBE SET (ID = 999,PROVIDER = $MASTERNODE,RECEIVER =$SLAVENODE,forward=no);
echo 'wait 1 ...';
SYNC (ID=$MASTERNODE);
echo 'wait 2 ...';
WAIT FOR EVENT (ORIGIN = ALL,CONFIRMED = ALL,WAIT ON=$MASTERNODE,TIMEOUT=0);
#SLEEP(seconds =2);
echo 'MERGE SET ...';
MERGE SET ( ID = $SETID,ADD ID = 999,ORIGIN = $MASTERNODE );
echo '$TABLENAME table added';
#DROP SET (id=999,origin=$MASTERNODE);


_END_
原文链接:https://www.f2er.com/postgresql/194560.html

猜你在找的Postgre SQL相关文章