Postgres-XL9.5集群安装与配置

Postgres-XL9.5集群安装与配置

1、准备

1)准备主机

准备3台主机,安装centos6.2

10.1.235.19 (gtm coordinator)

10.1.235.21 (datanode)

10.1.235.22 (datanode)

在这3台机器上创建用户pgxl,将编译好的Postgres-XL9.5文件分发到3台服务器,并解压

2)配置环境变量

vi .bash_profile

exportPGHOME=/home/pgxl/pgxl9.5

export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH

export PATH=$PATH:$HOME/bin:$PGHOME/bin

source.bash_profile

3)配置ssh免密码登录

在10.1.235.19节点配置:

su - pgxl

ssh-keygen -t rsa

cat ~/.ssh/id_rsa.pub>> ~/.ssh/authorized_keys

chmod 600 ~/.ssh/authorized_keys

将刚生成的认证文件拷贝到另外2台服务器:

scp ~/.ssh/[email protected]:~/.ssh/

scp ~/.ssh/[email protected]:~/.ssh/

2、配置gtm和coordinator

1) 初始化

/home/pgxl/pgxl9.5/bin/initgtm-Z gtm -D /home/pgxl/DATA/gtm13921

/home/pgxl/pgxl9.5/bin/initgtm -Z gtm -D /home/pgxl/DATA/gtm13922

/home/pgxl/pgxl9.5/bin/initgtm-Z gtm_proxy -D /home/pgxl/DATA/gtm14921

/home/pgxl/pgxl9.5/bin/initgtm -Z gtm_proxy -D /home/pgxl/DATA/gtm14922

/home/pgxl/pgxl9.5/bin/initdb-D /home/pgxl/DATA/coord1 --nodename coord1 -E UTF8 --locale=C -U pgxl -W

/home/pgxl/pgxl9.5/bin/initdb -D /home/pgxl/DATA/coord2 --nodename coord2 -EUTF8 --locale=C -U pgxl -W

2)配置gtm

[pgxl@host-10-1-235-19 ~]$ vi /home/pgxl/DATA/gtm13921/gtm.conf

nodename = 'gtm'

listen_addresses = '*'

port = 6666

startup = ACT

3)配置coordinator

[pgxl@host-10-1-235-19 ~]$ vi /home/pgxl/DATA/coord1/postgresql.conf

# - Connection Settings -

listen_addresses = '*'

port = 11921

max_connections = 100

# DATA NODES AND CONNECTION POOLING

#----------------------------------

pooler_port = 6667 #coord2这个端口改为6668

min_pool_size = 1

max_pool_size = 100

 

# GTM CONNECTION

#--------------------------

gtm_host = '10.1.235.19'

gtm_port = 6666

pgxc_node_name = 'coord1'

 

[pgxl@host-10-1-235-19 ~]$ vi /home/pgxl/DATA/coord1/pg_hba.conf

# IPv4 local connections:

host   all            all            127.0.0.1/32         trust

host   all            all            10.1.235.0/24       trust

host   all            all            0.0.0.0/0               md5

cp /home/pgxl/DATA/coord1/pg_hba.conf /home/pgxl/DATA/coord2/

scp /home/pgxl/DATA/coord1/pg_hba.conf [email protected]:/home/pgxl/DATA/dn1/

scp /home/pgxl/DATA/coord1/pg_hba.conf [email protected]:/home/pgxl/DATA/dn2/

scp /home/pgxl/DATA/coord1/pg_hba.conf [email protected]:/home/pgxl/DATA/dn3/

scp /home/pgxl/DATA/coord1/pg_hba.conf [email protected]:/home/pgxl/DATA/dn4/

3、配置datanode(10.1.235.21 和10.1.235.22都要操作)

1) 初始化

10.1.235.21

/home/pgxl/pgxl9.5/bin/initdb-D /home/pgxl/DATA/dn1 --nodename dn1 -E UTF8 --locale=C -U pgxl -W

/home/pgxl/pgxl9.5/bin/initdb -D /home/pgxl/DATA/dn2 --nodename dn2 -E UTF8--locale=C -U pgxl -W

10.1.235.22

/home/pgxl/pgxl9.5/bin/initdb-D /home/pgxl/DATA/dn3 --nodename dn3 -E UTF8 --locale=C -U pgxl -W

/home/pgxl/pgxl9.5/bin/initdb -D /home/pgxl/DATA/dn4 --nodename dn4 -E UTF8--locale=C -U pgxl -W

2) 配置datanode

[pgxl@host-10-1-235-21 ~]$ vi /home/pgxl/DATA/dn1/postgresql.conf

CONNECTIONS AND AUTHENTICATION

#------------------------------------

listen_addresses = '*' 

port = 11921 #其他几个配置文件分别改为11922、11923、11924

max_connections = 100 

# DATA NODES AND CONNECTION POOLING

#----------------------------------------------

pooler_port = 6667 #其他几个配置文件分别改为6668、6667、6668(同一台机器要使用不同的端口)

max_pool_size = 100

 

# GTM CONNECTION

#-----------------------------

gtm_host = '10.1.235.19'

gtm_port = 6666 

pgxc_node_name = 'dn1'

4、启动

1) 启动gtm

/home/pgxl/pgxl9.5/bin/gtm_ctl start -Z gtm -D/home/pgxl/DATA/gtm13921

/home/pgxl/pgxl9.5/bin/gtm_ctl start -Z gtm -D /home/pgxl/DATA/gtm13922

/home/pgxl/pgxl9.5/bin/gtm_ctl start -Z gtm_proxy -D/home/pgxl/DATA/gtm14921

/home/pgxl/pgxl9.5/bin/gtm_ctl start -Z gtm_proxy -D /home/pgxl/DATA/gtm14922

2) 启动datanode

/home/pgxl/pgxl9.5/bin/pg_ctl start -Z datanode -D/home/pgxl/DATA/dn1

/home/pgxl/pgxl9.5/bin/pg_ctl start -Z datanode -D /home/pgxl/DATA/dn2

/home/pgxl/pgxl9.5/bin/pg_ctl start -Z datanode -D /home/pgxl/DATA/dn3

/home/pgxl/pgxl9.5/bin/pg_ctl start -Z datanode -D /home/pgxl/DATA/dn4

3) 启动coordinator

/home/pgxl/pgxl9.5/bin/pg_ctl start -Z coordinator -D/home/pgxl/DATA/coord1

/home/pgxl/pgxl9.5/bin/pg_ctl start -Z coordinator -D /home/pgxl/DATA/coord2

5、配置集群信息

1) 10.1.235.19

/home/pgxl/pgxl9.5/bin/psql -h 10.1.235.19 -p 11921 -Upgxl postgres

select * from pgxc_node;

alter node coord1 with (type=coordinator,host='10.1.235.19', port=11921);

create node coord2 with (type=coordinator,host='10.1.235.19', port=11922);

create node dn1 with (type=datanode, host='10.1.235.21',port=11921,primary,preferred);

create node dn2 with (type=datanode, host='10.1.235.21',port=11922);

create node dn3 with (type=datanode, host='10.1.235.22',port=11923);

create node dn4 with (type=datanode, host='10.1.235.22',port=11924);

select pgxc_pool_reload();

select * from pgxc_node;

/home/pgxl/pgxl9.5/bin/psql -h 10.1.235.19 -p 11922 -Upgxl postgres

select * from pgxc_node;

create node coord1 with (type=coordinator,host='10.1.235.19', port=11921);

alter node coord2 with (type=coordinator,host='10.1.235.19', port=11922);

create node dn1 with (type=datanode, host='10.1.235.21',port=11921,primary,preferred);

create node dn2 with (type=datanode, host='10.1.235.21',port=11922);

create node dn3 with (type=datanode, host='10.1.235.22',port=11923);

create node dn4 with (type=datanode, host='10.1.235.22',port=11924);

select pgxc_pool_reload();

select * from pgxc_node;

2) 10.1.235.21

/home/pgxl/pgxl9.5/bin/psql -h 10.1.235.21 -p 11921 -Upgxl postgres

select * from pgxc_node;

create node coord1 with (type=coordinator,host='10.1.235.19', port=11921);

create node coord2 with (type=coordinator,host='10.1.235.19', port=11922);

alter node dn1 with (type=datanode, host='10.1.235.21',port=11921,primary,preferred);

create node dn2 with (type=datanode, host='10.1.235.21',port=11922);

create node dn3 with (type=datanode, host='10.1.235.22',port=11923);

create node dn4 with (type=datanode, host='10.1.235.22',port=11924);

select pgxc_pool_reload();

select * from pgxc_node;

/home/pgxl/pgxl9.5/bin/psql -h 10.1.235.21 -p 11922 -Upgxl postgres

select * from pgxc_node;

create node coord1 with (type=coordinator,host='10.1.235.19', port=11921);

create node coord2 with (type=coordinator,host='10.1.235.19', port=11922);

create node dn1 with (type=datanode, host='10.1.235.21',port=11921,primary,preferred);

alter node dn2 with (type=datanode, host='10.1.235.21',port=11922);

create node dn3 with (type=datanode, host='10.1.235.22',port=11923);

create node dn4 with (type=datanode, host='10.1.235.22',port=11924);

select pgxc_pool_reload();

select * from pgxc_node;

3) 10.1.235.22

/home/pgxl/pgxl9.5/bin/psql -h 10.1.235.22 -p 11923 -Upgxl postgres

select * from pgxc_node;

create node coord1 with (type=coordinator,host='10.1.235.19', port=11921);

create node coord2 with (type=coordinator,host='10.1.235.19', port=11922);

create node dn1 with (type=datanode, host='10.1.235.21',port=11921,primary,preferred);

create node dn2 with (type=datanode, host='10.1.235.21',port=11922);

alter node dn3 with (type=datanode, host='10.1.235.22',port=11923);

create node dn4 with (type=datanode, host='10.1.235.22',port=11924);

select pgxc_pool_reload();

select * from pgxc_node;

/home/pgxl/pgxl9.5/bin/psql -h 10.1.235.22 -p 11924 -Upgxl postgres

select * from pgxc_node;

create node coord1 with (type=coordinator,host='10.1.235.19', port=11921);

create node coord2 with (type=coordinator,host='10.1.235.19', port=11922);

create node dn1 with (type=datanode, host='10.1.235.21',port=11921,primary,preferred);

create node dn2 with (type=datanode, host='10.1.235.21',port=11922);

create node dn3 with (type=datanode, host='10.1.235.22',port=11923);

alter node dn4 with (type=datanode, host='10.1.235.22',port=11924);

select pgxc_pool_reload();

select * from pgxc_node;

6、创建表并插入数据

/home/pgxl/pgxl9.5/bin/psql -h 10.1.235.19 -p 11921 -Upgxl postgres

create table test1(id integer,name varchar(20));

insert into test1(id,name) values(1,'xk');

 

参考文章:

http://www.centoscn.com/image-text/config/2015/0729/5932.html

你可能感兴趣的:(Postgres-XL9.5集群安装与配置)