如果想向一个复制集里面增加新的表,可以用以下脚本:
#!/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