centos6.5下postgres-XC集群安装与配置
发布时间:2023-02-18 09:34:30 所属栏目:CentOS 来源:互联网
导读:图文解释 一、系统环境 系统平台:centos 6.5 postgres-XC版本:pgxc-v1.2.1.tar.gz 防火墙关闭selinux设置SELINUX=disabled 主机名 IP地址 角色 端口 nodename 数据目录 postgresql01 172.16.0.134 GTM 6666 gtm /gtm Coordinator 1921 coord1 /coordinator/c
#min_pool_size = 1 max_pool_size = 100 # GTM CONNECTION #----------------------------- gtm_host = '172.16.0.134' gtm_port = 6666 pgxc_node_name = 'db1' [pgxc@postgresql02 dn1]$ vi pg_hba.conf # IPv4 local connections: host all all 127.0.0.1/32 trust host all all 172.16.0.0/24 trust host all all 0.0.0.0/0 md5 [pgxc@postgresql02 dn1]$ cd /datanode/dn2/ # - Connection Settings - listen_addresses = '*' port = 15432 max_connections = 100 #------------------------------------------------------------------------------ # DATA NODES AND CONNECTION POOLING #-------------------------------- pooler_port = 6667 #min_pool_size = 1 max_pool_size = 100 #------------------------------------------------------------------------------ # GTM CONNECTION #---------------------------- gtm_host = '172.16.0.134' gtm_port = 6666 pgxc_node_name = 'db2' [pgxc@postgresql02 dn2]$ vi pg_hba.conf # IPv4 local connections: host all all 127.0.0.1/32 trust host all all 172.16.0.0/24 trust host all all 0.0.0.0/0 md5 八、启动 1.在172.16.0.134启动gtm [pgxc@postgresql01 ~]$gtm -D /gtm & 2.查看是否启动成功 [pgxc@postgresql01 ~]$gtm_ctl status -Z gtm -D /gtm gtm_ctl: server is running (PID: 2153) "-D" "/gtm" 1 master 3.在172.16.0.135主机启动datanode [pgxc@postgresql02 ~]$pg_ctl start -D /datanode/dn1 -Z datanode [pgxc@postgresql02 ~]$pg_ctl start -D /datanode/dn2 -Z datanode 4.查看是否启动成功 [pgxc@postgresql02 ~]$ps -ef | grep pgxc root 2087 2047 0 21:54 pts/0 00:00:00 su - pgxc pgxc 2088 2087 0 21:54 pts/0 00:00:00 -bash pgxc 2168 1 0 22:13 pts/0 00:00:00/opt/pgxc/bin/postgres --datanode -D /datanode/dn1 pgxc 2170 2168 0 22:13 ? 00:00:00 postgres: checkpointer process pgxc 2171 2168 0 22:13 ? 00:00:00 postgres: writer process pgxc 2172 2168 0 22:13 ? 00:00:00 postgres: wal writer process pgxc 2173 2168 0 22:13 ? 00:00:00 postgres: autovacuum launcher process pgxc 2174 2168 0 22:13 ? 00:00:00 postgres: stats collector process pgxc 2179 1 0 22:14 pts/0 00:00:00/opt/pgxc/bin/postgres --datanode -D /datanode/dn2 pgxc 2181 2179 0 22:14 ? 00:00:00 postgres: checkpointer process pgxc 2182 2179 0 22:14 ? 00:00:00 postgres: writer process pgxc 2183 2179 0 22:14 ? 00:00:00 postgres: wal writer process pgxc 2184 2179 0 22:14 ? 00:00:00 postgres: autovacuum launcher process pgxc 2185 2179 0 22:14 ? 00:00:00 postgres: stats collector process pgxc 2190 2088 0 22:14 pts/0 00:00:00 ps -ef pgxc 2191 2088 0 22:14 pts/0 00:00:00 grep pgxc 5.在172.16.0.134主机启动coordinator [pgxc@postgresql01 ~]$pg_ctl start -D /coordinator/cd1 -Z coordinator [pgxc@postgresql01 ~]$pg_ctl start -D /coordinator/cd2 -Z coordinator 6.查看是否成功 [pgxc@postgresql01 ~]$ ps -ef | grep pgxc root 2055 2036 0 21:42 pts/0 00:00:00 su - pgxc pgxc 2056 2055 0 21:42 pts/0 00:00:00 -bash pgxc 2153 2056 0 22:11 pts/0 00:00:00gtm -D /gtm pgxc 2168 1 0 22:16 pts/0 00:00:00/opt/pgxc/bin/postgres --coordinator -D /coordinator/cd1 pgxc 2170 2168 0 22:16 ? 00:00:00 postgres: pooler process pgxc 2171 2168 0 22:16 ? 00:00:00 postgres: checkpointer process pgxc 2172 2168 0 22:16 ? 00:00:00 postgres: writer process pgxc 2173 2168 0 22:16 ? 00:00:00 postgres: wal writer process pgxc 2174 2168 0 22:16 ? 00:00:00 postgres: autovacuum launcher process pgxc 2175 2168 0 22:16 ? 00:00:00 postgres: stats collector process pgxc 2180 1 0 22:17 pts/0 00:00:00/opt/pgxc/bin/postgres --coordinator -D /coordinator/cd2 pgxc 2182 2180 0 22:17 ? 00:00:00 postgres: pooler process pgxc 2183 2180 0 22:17 ? 00:00:00 postgres: checkpointer process pgxc 2184 2180 0 22:17 ? 00:00:00 postgres: writer process pgxc 2185 2180 0 22:17 ? 00:00:00 postgres: wal writer process pgxc 2186 2180 0 22:17 ? 00:00:00 postgres: autovacuum launcher process pgxc 2187 2180 0 22:17 ? 00:00:00 postgres: stats collector process pgxc 2201 2056 0 22:17 pts/0 00:00:00 ps -ef pgxc 2202 2056 0 22:17 pts/0 00:00:00 grep pgxc 九、配置集群节点信息 在172.16.0.134配置集群信息 [pgxc@postgresql01 ~]$ psql -p1921 postgres psql (PGXC,based on PG 9.3.2) Type "help" for help. postgres=#select * from pgxc_node; node_name | node_type | node_port | node_host | nodeis_primary | nodeis_preferred | node_id -----------+-----------+-----------+--------------+----------------+------------------+------------- coord1 | C | 5432 | localhost | f | f | 1885696643 postgres=#create node db1 with(type='datanode',host='172.16.0.135',port=15431,primary,preferred); postgres=#create node db2 with(type='datanode',port=15432); postgres=#create node coord2 with(type='coordinator',host='172.16.0.134',port=1925); postgres=#select * from pgxc_node; node_name | node_type | node_port | node_host | nodeis_primary | nodeis_preferred | node_id -----------+-----------+-----------+--------------+----------------+------------------+------------- coord1 | C | 5432 | localhost | f | f | 1885696643 db1 | D | 15431 | 172.16.0.135 | t | t | -2885965 db2 | D | 15432 | 172.16.0.135 | f | f | -79866771 coord2 | C | 1925 | 172.16.0.134 | f | f | -1197102633 postgres=#select pgxc_pool_reload(); 十、测试 [pgxc@postgresql01 ~]$ psql -p 1921 postgres psql (PGXC,based on PG 9.3.2) Type "help" for help. postgres=#select * from pgxc_node; node_name | node_type | node_port | node_host | nodeis_primary | nodeis_preferred | node_id -----------+-----------+-----------+--------------+----------------+------------------+------------- (编辑:甘南站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |