Postgres-XL9.5集群安装与配置
2016-03-02 14:17
337 查看
Postgres-XL9.5集群安装与配置
10.1.235.19 (gtm coordinator)
10.1.235.21 (datanode)
10.1.235.22 (datanode)
在这3台机器上创建用户pgxl,将编译好的Postgres-XL9.5文件分发到3台服务器,并解压
exportPGHOME=/home/pgxl/pgxl9.5
export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH
export PATH=$PATH:$HOME/bin:$PGHOME/bin
source.bash_profile
su - pgxl
ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub>> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
将刚生成的认证文件拷贝到另外2台服务器:
scp ~/.ssh/authorized_keyspgxl@10.1.235.21:~/.ssh/
scp ~/.ssh/authorized_keyspgxl@10.1.235.22:~/.ssh/
/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
nodename = 'gtm'
listen_addresses = '*'
port = 6666
startup = ACT
# - 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 pgxl@10.1.235.21:/home/pgxl/DATA/dn1/
scp /home/pgxl/DATA/coord1/pg_hba.conf pgxl@10.1.235.21:/home/pgxl/DATA/dn2/
scp /home/pgxl/DATA/coord1/pg_hba.conf pgxl@10.1.235.22:/home/pgxl/DATA/dn3/
scp /home/pgxl/DATA/coord1/pg_hba.conf pgxl@10.1.235.22:/home/pgxl/DATA/dn4/
/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
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/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/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/coord2
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;
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;
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;
create table test1(id integer,name varchar(20));
insert into test1(id,name) values(1,'xk');
1、准备
1)准备主机
准备3台主机,安装centos6.210.1.235.19 (gtm coordinator)
10.1.235.21 (datanode)
10.1.235.22 (datanode)
在这3台机器上创建用户pgxl,将编译好的Postgres-XL9.5文件分发到3台服务器,并解压
2)配置环境变量
vi .bash_profileexportPGHOME=/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/authorized_keyspgxl@10.1.235.21:~/.ssh/
scp ~/.ssh/authorized_keyspgxl@10.1.235.22:~/.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.confnodename = '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 pgxl@10.1.235.21:/home/pgxl/DATA/dn1/
scp /home/pgxl/DATA/coord1/pg_hba.conf pgxl@10.1.235.21:/home/pgxl/DATA/dn2/
scp /home/pgxl/DATA/coord1/pg_hba.conf pgxl@10.1.235.22:/home/pgxl/DATA/dn3/
scp /home/pgxl/DATA/coord1/pg_hba.conf pgxl@10.1.235.22:/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.confCONNECTIONS 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 postgresselect * 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 postgresselect * 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 postgresselect * 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 postgrescreate 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相关文章推荐
- opencv学习笔记(二十五)——实现相机拍照功能
- Builder模式的实现
- Java格式化日期、时间、数字、字符串
- Drools 查询学习
- Drools 函数学习
- 华为oj 找出字符串中第一个只出现一次的字符
- Android开发优化之——对Bitmap的内存优化
- 特征值和特征向量的几何意义、计算及其性质
- JavaScript和jQuery实现定位导航功能
- iOS 3D touch的实现 从零开始
- 银行核心系统软件开发 转
- TFS 2013”无法移除仍为团队管理员身份的标识”
- Linux 5 下安装MySQL 5.6(RPM方式)
- Android studio 导入jar包
- 深入理解LayoutInflater.inflate()
- 将定制RPM包加入内部Yum Server
- hadoop数据分析
- nw.js node-webkit系列(13)Native UI API 其它
- 2015年大二上-数据结构-图-2-(5)-拓扑排序
- Drools 规则学习