git clone git://git.postgresql.org/git/postgres-xl.gitnode
cd postgres-xlgit
git checkout XL9_5_R1_6sql
# 安装依赖
yum install -y flex bison readline-devel zlib-devel openjade docbook-style-dssslvim
# 每台机器都安装
./configure --prefix=/usr/local/postgres-xl-9.5
make -j8
make installbash
#安装pgxc-ctl管理工具(主节点才安装)
cd contrib
make -j8
make install服务器
为每台主机建立用户postgres。
# useradd postgres
# passwd postgres
# 输入密码 123456ssh
2.在每个节点上设置环境变量
su - postgres
vi ~/.bashrc #注意这里环境变量必定要添加到.bashrc文件中,不然会找不到相关命令 工具
export PGHOME=/usr/local/postgres-xl-9.5
export PGUSER=postgres
export LD_LIBRARY_PATH=$PGHOME/lib
export PATH=$PGHOME/bin:$PATHpost
source ~/.bashrcflex
#安装过程当中须要在datanode上建立目录,因此须要有$PGHOME目录的写权限
chown -R postgres:postgres /usr/local/postgres-xl-9.5
# 主服务器上生成ssh
su - postgres
ssh-keygen -t rsa
chmod 600 ~/.ssh/authorized_keys
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
scp /.ssh/authorized_keys postgres@ser22:/home/postgres/.ssh/
chmod 600 ~/.ssh/authorized_keys
#
vim /etc/sysctl.conf --开机启动加载内核参数
kernel.sem =5010 641280 5010 128
#sysctl -p --加载生效
#生成pgxc_ctl配置文件
[postgres@localhost ~]# pgxc_ctl
PGXC prepare ---执行该命令将会生成一份配置文件模板
PGXC ---按ctrl c退出。
#配置pgxc_ctl.conf
#第一次启动集群,须要初始化,初始化以下
[postgres@pg1 pgxc_ctl]$ pgxc_ctl -c /home/postgres/pgxc_ctl/pgxc_ctl.conf init all
#pgxc_ctl
monitor all #监控全部状态
# 端口使用Coordinator的端口
psql -p 20004
# 查询node
select * from pgxc_node;
# 建立表
create table test1(id int, name varchar(36)) DISTRIBUTE BY HASH(id);
# 更改表的distribute
alter table tsys_icon DISTRIBUTE BY HASH(guid);
# 查询test1表的分布 SELECT xc_node_id, count(*) FROM test1 GROUP BY xc_node_id;