目标: install a simple cluster on a local machine with 1 Coordinator, 2 Datanodes and 1 GTM
1.源码安装程序 ./configure make make install 【注意安装flex包】
2.创建用户及目录
useradd postgres
mkdir -p /home/postgres/pgxl/data_coord1
mkdir -p /home/postgres/pgxl/data_datanode_1
mkdir -p /home/postgres/pgxl/data_datanode_2
mkdir -p /home/postgres/pgxl/data_gtm
3.修改所属用户
chown postgres /home/postgres/pgxl/data_coord1
chown postgres /home/postgres/pgxl/data_datanode_1
chown postgres /home/postgres/pgxl/data_datanode_2
chown postgres /home/postgres/pgxl/data_gtm
4.初始化各节点数据库
initdb -D /home/postgres/pgxl/data_coord1/ --nodename coord1
initdb -D /home/postgres/pgxl/data_datanode_1 --nodename datanode_1
initdb -D /home/postgres/pgxl/data_datanode_2 --nodename datanode_2
initgtm -D /home/postgres/pgxl/data_gtm/ -Z gtm 【-Z 节点类型:gtm gtm_proxy】
gtm -D /home/postgres/pgxl/data_gtm/ > logfile 2>&1 & 【启动gtm服务】
postgres --datanode -p 15432 -c pooler_port=40101 -D /home/postgres/pgxl/data_datanode_1 >logfile 2>&1 & 【启动数据节点1】
postgres --datanode -p 15433 -c pooler_port=40102 -D /home/postgres/pgxl/data_datanode_2 >logfile 2>&1 & 【启动数据节点2】
postgres --coordinator -c pooler_port=40100 -D /home/postgres/pgxl/data_coord1/ >logfile 2>&1 & 【启动协调器节点】{【需要特别注意各个节点的端口号占用情况,不能出现冲突】}
5.修改节点属性
psql -c "ALTER NODE coord1 WITH (TYPE = 'coordinator', PORT = 5432)" postgres
psql -c "CREATE NODE datanode_1 WITH (TYPE = 'datanode', PORT = 15432)" postgres
psql -c "CREATE NODE datanode_2 WITH (TYPE = 'datanode', PORT = 15433)" postgres
psql -c "EXECUTE DIRECT ON (datanode_1) 'ALTER NODE datanode_1 WITH (TYPE = ''datanode'', PORT = 15432)'" postgres
psql -c "EXECUTE DIRECT ON (datanode_1) 'CREATE NODE coord1 WITH (TYPE = ''coordinator'', PORT = 5432)'" postgres
psql -c "EXECUTE DIRECT ON (datanode_2) 'ALTER NODE datanode_2 WITH (TYPE = ''datanode'', PORT = 15433)'" postgres
psql -c "EXECUTE DIRECT ON (datanode_2) 'CREATE NODE datanode_1 WITH (TYPE = ''datanode'', PORT = 15432)'" postgres
psql -c "EXECUTE DIRECT ON (datanode_2) 'CREATE NODE coord1 WITH (TYPE = ''coordinator'', PORT = 5432)'" postgres
psql -c "SELECT pgxc_pool_reload()" postgres
psql -c "EXECUTE DIRECT ON (datanode_1) 'SELECT pgxc_pool_reload()'" postgres
psql -c "EXECUTE DIRECT ON (datanode_2) 'SELECT pgxc_pool_reload()'" postgres
createdb test
psql test