路由配置

cn01

  1. [tbase@VM_0_29_centos ~]# psql -h 172.16.0.29 -p 15432 -d postgres -U tbase
  2. psql (PostgreSQL 10.0 TBase V2)
  3. Type "help" for help.
  4. postgres=#
  5. alter node cn01 with (host='172.16.0.29',port=15432);
  6. create node cn02 with (type=coordinator,host='172.16.0.47',port=15432,primary=false,preferred=false);
  7. create node dn01 with (type=datanode,host='172.16.0.29',port=23001,primary=false,preferred=false);
  8. create node dn02 with (type=datanode,host='172.16.0.47',port=23002,primary=false,preferred=false);
  9. select pgxc_pool_reload();

cn02

  1. [tbase@VM_0_29_centos ~]# psql -h 172.16.0.47 -p 15432 -d postgres -U tbase
  2. psql (PostgreSQL 10.0 TBase V2)
  3. Type "help" for help.
  4. postgres=#
  5. alter node cn02 with (host='172.16.0.47',port=15432);
  6. create node cn01 with (type=coordinator,host='172.16.0.29',port=15432,primary=false,preferred=false);
  7. create node dn01 with (type=datanode,host='172.16.0.29',port=23001,primary=false,preferred=false);
  8. create node dn02 with (type=datanode,host='172.16.0.47',port=23002,primary=false,preferred=false);
  9. select pgxc_pool_reload();

dn01

  1. [tbase@VM_0_29_centos ~]# psql -h 172.16.0.29 -p 23001 -d postgres -U tbase
  2. psql (PostgreSQL 10.0 TBase V2)
  3. Type "help" for help.
  4. postgres=#
  5. alter node dn01 with (host='172.16.0.29',port=23001);
  6. create node cn01 with (type=coordinator,host='172.16.0.29',port=15432,primary=false,preferred=false);
  7. create node cn02 with (type=coordinator,host='172.16.0.47',port=15432,primary=false,preferred=false);
  8. create node dn02 with (type=datanode,host='172.16.0.47',port=23002,primary=false,preferred=false);
  9. select pgxc_pool_reload();

dn02

  1. [tbase@VM_0_29_centos ~]# psql -h 172.16.0.47 -p 23002 -d postgres -U tbase
  2. psql (PostgreSQL 10.0 TBase V2)
  3. Type "help" for help.
  4. postgres=#
  5. alter node dn02 with (host='172.16.0.47',port=23001);
  6. create node cn01 with (type=coordinator,host='172.16.0.29',port=15432,primary=false,preferred=false);
  7. create node cn02 with (type=coordinator,host='172.16.0.47',port=15432,primary=false,preferred=false);
  8. create node dn01 with (type=datanode,host='172.16.0.29',port=23001,primary=false,preferred=false);
  9. select pgxc_pool_reload();

路由表信息

所有节点的路由信息配置完成后如下所示

  1. [tbase@VM_0_29_centos ~]# psql -h 172.16.0.29 -p 15432 -d postgres -U tbase
  2. postgres=# select * from pgxc_node;
  3. node_name | node_type | node_port | node_host | nodeis_primary | nodeis_preferred | node_id | node_cluster_name
  4. -----------+-----------+-----------+-------------+----------------+------------------+-------------+-------------------
  5. gtm_1 | G | 21000 | 172.16.0.29 | t | f | -1500995709 | tbase_cluster
  6. cn01 | C | 15432 | 172.16.0.29 | f | f | 53994174 | tbase_cluster
  7. cn02 | C | 15432 | 172.16.0.47 | f | f | -613255070 | tbase_cluster
  8. dn01 | D | 23001 | 172.16.0.29 | f | f | -1085152094 | tbase_cluster
  9. dn02 | D | 23002 | 172.16.0.47 | f | f | -506537247 | tbase_cluster
  10. (5 rows)