======Database Creation====== Once all the work is done, we can safely test our cluster. We will create a simple database with one table and query it from multiple hosts: **host1** Create empty database: test [postgres@psqlxla pgxc_ctl]$ pgxc_ctl /bin/bash Installing pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash. Installing pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash. Reading configuration using /home/postgres/pgxc_ctl/pgxc_ctl_bash --home /home/postgres/pgxc_ctl --configuration /home/postgres/pgxc_ctl/pgxc_ctl.conf Finished reading configuration. ******** PGXC_CTL START *************** Current directory: /home/postgres/pgxc_ctl PGXC Createdb test Selected coord1. PGXC **host2** Create a table and insert value inside: [postgres@psqlxlb ~]$ /usr/local/pgsql/bin/psql test psql (PGXL 10alpha2, based on PG 10beta3 (Postgres-XL 10alpha2)) Type "help" for help. test=# create table contact( id int, name text, phone varchar(30)) DISTRIBUTE BY REPLICATION; CREATE TABLE test=# insert into contact values ( 1,'tom','1212121'); INSERT 0 1 test=# select * from contact; id | name | phone ----+------+--------- 1 | tom | 1212121 (1 row) test=# **host3** Select the table: [root@psqlxlc ~]# su - postgres Last login: Sun May 27 17:06:11 EDT 2018 from 192.168.100.10 on pts/1 [postgres@psqlxlc ~]$ /usr/local/pgsql/bin/psql test -p 15432 psql (PGXL 10alpha2, based on PG 10beta3 (Postgres-XL 10alpha2)) Type "help" for help. test=# select * from contact; id | name | phone ----+------+--------- 1 | tom | 1212121 (1 row) ======Stop/Start the Cluster====== Stopping or starting the cluster is very simple with only couple command words: =====Start Cluster===== [postgres@psqlxla ~]$ pgxc_ctl /bin/bash Installing pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash. Installing pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash. Reading configuration using /home/postgres/pgxc_ctl/pgxc_ctl_bash --home /home/postgres/pgxc_ctl --configuration /home/postgres/pgxc_ctl/pgxc_ctl.conf Finished reading configuration. ******** PGXC_CTL START *************** Current directory: /home/postgres/pgxc_ctl PGXC start all Start GTM master server starting Starting coordinator master. Starting coordinator master coord1 2018-05-28 03:18:46.871 EDT [1049] LOG: listening on IPv4 address "0.0.0.0", port 5432 2018-05-28 03:18:46.871 EDT [1049] LOG: listening on IPv6 address "::", port 5432 2018-05-28 03:18:46.891 EDT [1049] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432" 2018-05-28 03:18:47.020 EDT [1050] LOG: database system was shut down at 2018-05-27 17:54:13 EDT 2018-05-28 03:18:47.077 EDT [1049] LOG: database system is ready to accept connections 2018-05-28 03:18:47.077 EDT [1057] LOG: cluster monitor started 2018-05-28 03:18:47.079 EDT [1056] LOG: corrupted statistics file "pg_stat/global.stat" Done. Starting all the datanode masters. Starting datanode master datanode1. Starting datanode master datanode2. 2018-05-28 03:18:49.160 EDT [1049] LOG: listening on IPv4 address "0.0.0.0", port 15432 2018-05-28 03:18:49.160 EDT [1049] LOG: listening on IPv6 address "::", port 15432 2018-05-28 03:18:49.189 EDT [1049] LOG: listening on Unix socket "/tmp/.s.PGSQL.15432" 2018-05-28 03:18:49.335 EDT [1049] LOG: redirecting log output to logging collector process 2018-05-28 03:18:49.335 EDT [1049] HINT: Future log output will appear in directory "pg_log". 2018-05-28 03:18:49.152 EDT [1038] LOG: listening on IPv4 address "0.0.0.0", port 15433 2018-05-28 03:18:49.152 EDT [1038] LOG: listening on IPv6 address "::", port 15433 2018-05-28 03:18:49.181 EDT [1038] LOG: listening on Unix socket "/tmp/.s.PGSQL.15433" 2018-05-28 03:18:49.298 EDT [1038] LOG: redirecting log output to logging collector process 2018-05-28 03:18:49.298 EDT [1038] HINT: Future log output will appear in directory "pg_log". Done. PGXC =====Stop Cluster===== Similar to the start command, the stopping of the cluster can also be done easily: There are 3 ways how we can stop the cluster: * SIGTERM This is the Smart Shutdown mode. After receiving SIGTERM, the server disallows new connections, but lets existing sessions end their work normally. It shuts down only after all of the sessions terminate. If the server is in online backup mode, it additionally waits until online backup mode is no longer active. While backup mode is active, new connections will still be allowed, but only to superusers (this exception allows a superuser to connect to terminate online backup mode). If the server is in recovery when a smart shutdown is requested, recovery and streaming replication will be stopped only after all regular sessions have terminated. [postgres@psqlxla ~]$ pgxc_ctl /bin/bash Installing pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash. Installing pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash. Reading configuration using /home/postgres/pgxc_ctl/pgxc_ctl_bash --home /home/postgres/pgxc_ctl --configuration /home/postgres/pgxc_ctl/pgxc_ctl.conf Finished reading configuration. ******** PGXC_CTL START *************** Current directory: /home/postgres/pgxc_ctl PGXC PGXC stop -m smart all Stopping all the coordinator masters. Stopping coordinator master coord1. Done. Stopping all the datanode masters. Stopping datanode master datanode1. Stopping datanode master datanode2. Done. Stop GTM master waiting for server to shut down.... done server stopped PGXC * SIGINT This is the Fast Shutdown mode. The server disallows new connections and sends all existing server processes SIGTERM, which will cause them to abort their current transactions and exit promptly. It then waits for all server processes to exit and finally shuts down. If the server is in online backup mode, backup mode will be terminated, rendering the backup useless. PGXC stop -m fast all Stopping all the coordinator masters. Stopping coordinator master coord1. Done. Stopping all the datanode masters. Stopping datanode master datanode1. Stopping datanode master datanode2. Done. Stop GTM master waiting for server to shut down.... done server stopped * SIGQUIT This is the Immediate Shutdown mode. The master postgres process will send a SIGQUIT to all child processes and exit immediately, without properly shutting itself down. The child processes likewise exit immediately upon receiving SIGQUIT. This will lead to recovery (by replaying the WAL log) upon next start-up. This is recommended only in emergencies. PGXC stop -m immediate all Stopping all the coordinator masters. Stopping coordinator master coord1. Done. Stopping all the datanode masters. Stopping datanode master datanode1. Stopping datanode master datanode2. Done. Stop GTM master waiting for server to shut down.... done server stopped PGXC