postgresql - Slony - slonik 语法问题

标签 postgresql slony

我正在尝试使用 slony 教程中的示例,但看起来他们的示例中存在语法错误。我尝试在网上查找更多文档,但还没有真正找到展示如何使用 slonik 命令的良好文档。我尝试运行的脚本是:

#!/bin/sh

/opt/local/lib/postgresql90/bin/slonik << _EOL_

define CLUSTERNAME slony_example;
cluster name = @CLUSTERNAME;

node 1 admin conninfo = 'dbname=my_primary host=$MASTERHOST user=$REPLICATIONUSER'; 
node 2 admin conninfo = 'dbname=my_rep host=$SLAVEHOST user=$REPLICATIONUSER';

#-- 
# init the first node. Its id MUST be 1. This creates the schema # _$CLUSTERNAME containing all replication system specific database # objects.
#-- 
init cluster ( id=1, comment = 'Master Node');

#--
# Slony-I organizes tables into sets. The smallest unit a node can # subscribe is a set. The following commands create one set containing # all 4 pgbench tables. The master or origin of the set is node 1. 
#-- 
create set (id=1, origin=1, comment='All pgbench tables'); 
set add table (set id=1, origin=1, id=1, fully qualified name ='public.pgbench_accounts', comment='accounts table'); 
set add table (set id=1, origin=1, id=2, fully qualified name ='public.pgbench_branches', comment='branches table'); 
set add table (set id=1, origin=1, id=3, fully qualified name ='public.pgbench_tellers', comment='tellers table'); 
set add table (set id=1, origin=1, id=4, fully qualified name ='public.pgbench_history', comment='history table');

#-- 
# Create the second node (the slave) tell the 2 nodes how to connect to Slony-I 2.1.1 Documentation 10 / 163
# each other and how they should listen for events.
#--

store node (id=2, comment = 'Slave node', event node=1);
store path (server = 1, client = 2, conninfo='dbname=my_primary host=$MASTERHOST user=$REPLICATIONUSER');
store path (server = 2, client = 1, conninfo='dbname=my_rep host=$SLAVEHOST user=$REPLICATIONUSER');

_EOF_

但我不断收到以下错误:

postgres$ /tmp/slonik_example.sh
<stdin>:29: ERROR: syntax error at or near dbname

根据第一个答案更新上面的脚本。现在的错误是:

postgres$ /tmp/slonik_example.sh
<stdin>:31: ERROR: syntax error at or near _EOF_

最佳答案

您的报价不平衡:

store path (server = 1, client = 2, conninfo='dbname=my_primary host=$MASTERHOST user= '$REPLICATIONUSER');
store path (server = 2, client = 1, conninfo='dbname=my_rep host=$SLAVEHOST user= '$REPLICATIONUSER');

您可能想要:

store path (server = 1, client = 2, conninfo="dbname=my_primary host=$MASTERHOST user=$REPLICATIONUSER");
store path (server = 2, client = 1, conninfo="dbname=my_rep host=$SLAVEHOST user=$REPLICATIONUSER");

关于postgresql - Slony - slonik 语法问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9363906/

相关文章:

postgresql - 用于故障转移的 Slony 和 PPGool

postgresql - 在从属主机复制集中选择模式 Usin Slony-I

Django + PostgreSQL 触发器导致 "violates foreign key constraint"

Python代码不在数据库上创建表但能够查询结果postgres

postgresql - Postgres Slony-I问题

postgresql - sl_log 表很大,超过 1 亿行

postgresql - 你如何让一个ddl进入postgres

postgresql - 无法查看创建的架构中的任何关系

java - 无法使用 AWS EMR 实例通过 spark 访问 JDBC 驱动程序

sql - 每天自动删除一次 PostgreSQL 表