postgres-xl 集体搭建(2)

$ pgxc_ctl prepare config minimal

生成一个单机伪分布集群配置简单模板

根据该模板进行简单修改就可以配置成一个集群

$ pgxc_ctl init all

$ pgxc_ctl start all

$PGXC monitor all
Running: gtm master
Running: gtm slave
Running: gtm proxy gtm_pxy1
Running: gtm proxy gtm_pxy2
Running: coordinator master coord1
Running: coordinator master coord2
Running: datanode master datanode_1
Running: datanode master datanode_2

----------------------------成功第一步-------------------------------------

下面重点介绍下slave node 节点配置

 在配置文件中  pgxc_ctl.conf

4) Gtm master and slave can have different port to listen, while coordinator and datanode
# slave should be assigned the same port number as master.
#
# 5) Port nuber of a coordinator slave must be the same as its master.

# Master and slave use the same port!

****值得特别注意 主从 端口号要保持高度一致(所以在官方的demo中的单机版伪分布不能创建slave节点)

pgxc_ctl.conf 配置修改

datanodeSlave=y

coordSlave=y

退出PGXC 再次进入将重新加载配置文件

$PGXC monitor all
Running: gtm master
Running: gtm slave
Running: gtm proxy gtm_pxy1
Running: gtm proxy gtm_pxy2
Running: 
Not running: coordinator slave coord1
Running: coordinator master coord2
Not running: coordinator slave coord2
Running: datanode master datanode_1
Not running: datanode slave datanode_1
Running: datanode master datanode_2
Not running: datanode slave datanode_2

如上: 多出四个 slave node

接下来对slave node 进行初始化

$PGXC init coordinator slave coord1

Initialize coordinator slave coord1
pg_basebackup: could not connect to server: FATAL: no pg_hba.conf entry for replication connection from host "*.*.*.*", user "postgres"

解决方法(参见postgres 数据库主从配置) http://www.cnblogs.com/yjf512/p/4499547.html

修改 coordinator master coord1 节点 

pg_hba.conf 文件 加入 

      host    replication     all     0.0.0.0/0                 trust

postgresql.conf 文件修改以下参数

wal_level = hot_standby

max_wal_senders = 5 不能大于 最大连接数

wal_keep_segments = 

max_connections = 

重启 主节点 

初始化 从节点

启动 从节点

--------------------------------------------------------------------------------成功----------------------------------------------

PGXC monitor all
Running: gtm master
Running: gtm slave
Running: gtm proxy gtm_pxy1
Running: gtm proxy gtm_pxy2
Running: coordinator master coord1
Running: coordinator slave coord1
Running: coordinator master coord2
Running: coordinator slave coord2
Running: datanode master datanode_1
Running: datanode slave datanode_1
Running: datanode master datanode_2
Running: datanode slave datanode_2

 ---------------------------------------------------------------------------验证--------------------------------------

[postgres@node1 ~]$ psql -h node3
psql (PGXL 9.5r1beta1, based on PG 9.5.0 (Postgres-XL 9.5r1beta1))
Type "help" for help.

postgres=# select * from pgxc_node;
node_name | node_type | node_port | node_host | nodeis_primary | nodeis_preferred | node_id
------------+-----------+-----------+-----------+----------------+------------------+-------------
coord1 | C | 5432 | node3 | f | f | 1885696643
coord2 | C | 5432 | node4 | f | f | -1197102633
datanode_1 | D | 15432 | node3 | t | t | -675012441
datanode_2 | D | 15432 | node4 | f | f | -1047623914
(4 rows)

 

posted @ 2016-03-10 15:43  Eamon13  阅读(1800)  评论(0编辑  收藏  举报