This page describes how to configure small Postgres-XC cluster using three servers. Each server should run 64bit Linux (32bit may work though) and should be connected via appropriate TCP/IP connection each other. In this page, we assume each server's name as node01, node02 and node03.
We're configuring the following Postgres-XC components. If you are not familiar with them, please go back to the page [Configuration].
You should determine the followng resources for each of the component above:
Each componet has similar set of resources you should assign.
Now we begin the configuration from a server 'main'. Because you need to login to different servers, the command prompts are prefixed with the server name such as:
[main]$ ssh node01 [node01]$
Now, please visit pages for each compoent as follows:
Now your're ready to run your applications.
You have done all the configurations successfully. Congratulations!! Now you can start your Postgres-XC cluster by starting each component one by one. You should start GTM first because all the other components assume that GTM is running. Then you start GTM Proxy.
Please do like this.
[main]$ ssh node03 [node03]$ gtm_ctl start -Z gtm -D /home/postgresxc/pgxc/gtm [node03]$ exit [main]$ ssh node01 [node01]$ gtm_ctl start -Z gtm_proxy -D /home/postgresxc/pgxc/gtm_proxy [node01]$ exit [main]$ ssh node02 [node02]$ gtm_ctl start -Z gtm_proxy -D /home/postgresxc/pgxc/gtm_proxy [node02]$ exit [main]$
Now you can start coordinator and datanode. Although you can start them in arbitrary order, it is a good habit to start datanode first. If you start coordinator firist and your applications issue SQL statements before datanodes start, it will lead to an error.
You can do like this:
[main]$ ssh node01 [node01]$ pg_ctl start -Z datanode -D /home/postgresxc/pgxc/datanode [node01]$ exit [main]$ ssh node02 [node02]$ pg_ctl start -Z datanode -D /home/postgresxc/pgxc/datanode [node02]$ exit [main]$ ssh node01 [node01]$ pg_ctl start -Z coordinator -D /home/postgresxc/pgxc/coordinator [node01]$ exit [main]$ ssh node02 [node02]$ pg_ctl start -Z coordinator -D /home/postgresxc/pgxc/coordinator [node02]$ exit [main]$
All the components are up and waiting for your application to connect.
Please note that until know, we told each component where GTM is. However, coordinators do not know where other coordinators are and where datanodes are. They're very important configuration and you should configure them here.
Only coordinators need to know other nodes. Here, we use psql for this purpose and use CREATE NODE and ALTER NODE statement. At this moment, database called 'postgres' is available. So login to postgres. Because you created the database as user name postgresxc, you're the superuser.
First, you configure coord1.
[main]$ psql -p 20004 -h node01 postgres # CREATE NODE coord2 WITH (TYPE = 'coordinator', HOST = 'node02', PORT = 20004); # CREATE NODE datanode1 WITH (TYPE = 'datanode', HOST = 'node01', PORT = 20006); # CREATE NODE datanode2 WITH (TYPE = 'datanode', HOST = 'node02', PORT = 20006); # \q [main]$
Next, do the similar for coord2.
[main]$ psql -p 20004 -h node02 postgres # CREATE NODE coord1 WITH (TYPE = 'coordinator', HOST = 'node01', PORT = 20004); # CREATE NODE datanode1 WITH (TYPE = 'datanode', HOST = 'node01', PORT = 20006); # CREATE NODE datanode2 WITH (TYPE = 'datanode', HOST = 'node02', PORT = 20006); # \q [main]$
You must do the above only at the first time you started Postgres-XC cluster. After then, you skip this process and connect your application to any of the coordinators.
Postgres-XC: Configuration
Postgres-XC: Configure_Server_Coordinators
Postgres-XC: Configure_Server_Datanodes
Postgres-XC: Configure_Server_GTM
Postgres-XC: Configure_Server_GTM_Proxies
Postgres-XC: GTM-Proxy_HA_configuration
Postgres-XC: GTM_Standby_Configuration
Postgres-XC: High_Availability