Postgres-XL9.5集群安装与配置
准备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台服务器,并解压
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
在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/
/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
[pgxl@host-10-1-235-19 ~]$ vi /home/pgxl/DATA/gtm13921/gtm.conf
nodename = 'gtm'
listen_addresses = '*'
port = 6666
startup = ACT
[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/
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
[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'
/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
/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
/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
/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;
/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;
/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;
/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');