Table of Contents

Overview

PostgreSQL-XL and later installment of the PostgreSQL code.Unlike the PostgreSQL-XC PostgreSQL-XL is more suitable for OLAP/Warehouse systems since it is tightly linked with SQL and Parallel execution.

We will discuss the following stages of installing the PostgreSQL-XL cluster. For clarity reasons, let's assume we have the following instances:

GTM:
hostname=psqlxla
nodename=gtm
IP=192.168.100.10
port=6666

Coordinator:
hostname=psqlxlb
nodename=coord1
IP=192.168.100.20
pooler_port=6668,port=5432

Datanode1:
hostname=psqlxlc
nodename=datanode1
IP=192.168.100.30
pooler_port=6669, port=15432

Datanode2:
hostname=psqlxld
nodename=datanode2
IP=192.168.100.40
pooler_port=6670, port=15433

Software Installation

There are many ways how you can download / install PostgreSQL-XL cluster, but the safest way is to use GIT, so let's do it like this :)

Using Git

Git client should be firstly installed so we can download the needed packages:

[root@psqlxla ~]# yum install git
Loaded plugins: fastestmirror
base                                                                                                                                                                                           | 3.6 kB  00:00:00
extras                                                                                                                                                                                         | 3.4 kB  00:00:00
updates                                                                                                                                                                                        | 3.4 kB  00:00:00
(1/4): base/7/x86_64/group_gz                                                                                                                                                                  | 166 kB  00:00:00
(2/4): extras/7/x86_64/primary_db                                                                                                                                                              | 146 kB  00:00:01
(3/4): base/7/x86_64/primary_db                                                                                                                                                                | 5.9 MB  00:00:02
(4/4): updates/7/x86_64/primary_db                                                                                                                                                             | 2.0 MB  00:00:08
Determining fastest mirrors
 * base: ftp.hosteurope.de
 * extras: ftp.hosteurope.de
 * updates: ftp.hosteurope.de
Resolving Dependencies
--> Running transaction check
Installed:
  git.x86_64 0:1.8.3.1-13.el7

Dependency Installed:
  libgnome-keyring.x86_64 0:3.12.0-1.el7    perl.x86_64 4:5.16.3-292.el7               perl-Carp.noarch 0:1.26-244.el7                perl-Encode.x86_64 0:2.51-7.el7          perl-Error.noarch 1:0.17020-2.el7
  perl-Exporter.noarch 0:5.68-3.el7         perl-File-Path.noarch 0:2.09-2.el7         perl-File-Temp.noarch 0:0.23.01-3.el7          perl-Filter.x86_64 0:1.49-3.el7          perl-Getopt-Long.noarch 0:2.40-3.el7
  perl-Git.noarch 0:1.8.3.1-13.el7          perl-HTTP-Tiny.noarch 0:0.033-3.el7        perl-PathTools.x86_64 0:3.40-5.el7             perl-Pod-Escapes.noarch 1:1.04-292.el7   perl-Pod-Perldoc.noarch 0:3.20-4.el7
  perl-Pod-Simple.noarch 1:3.28-4.el7       perl-Pod-Usage.noarch 0:1.63-3.el7         perl-Scalar-List-Utils.x86_64 0:1.27-248.el7   perl-Socket.x86_64 0:2.010-4.el7         perl-Storable.x86_64 0:2.45-3.el7
  perl-TermReadKey.x86_64 0:2.30-20.el7     perl-Text-ParseWords.noarch 0:3.29-4.el7   perl-Time-HiRes.x86_64 4:1.9725-3.el7          perl-Time-Local.noarch 0:1.2300-2.el7    perl-constant.noarch 0:1.27-2.el7
  perl-libs.x86_64 4:5.16.3-292.el7         perl-macros.x86_64 4:5.16.3-292.el7        perl-parent.noarch 1:0.225-244.el7             perl-podlators.noarch 0:2.5.1-3.el7      perl-threads.x86_64 0:1.87-4.el7
  perl-threads-shared.x86_64 0:1.43-6.el7   rsync.x86_64 0:3.1.2-4.el7

Complete!

Prerequisites

We have to add the “postgres” user:

[postgres@psqlxla postgres-xl]$ useradd postgres
[postgres@psqlxla postgres-xl]$

Compiler

Don't forget to install the C compiler as well:

[postgres@psqlxla postgres-xl]$ yum groupinstall "Development tools"
Loaded plugins: fastestmirror
You need to be root to perform this command.
[postgres@psqlxla postgres-xl]$ logout
[root@psqlxla ~]# yum groupinstall "Development tools"
Loaded plugins: fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
 * base: ftp.hosteurope.de
Installed:
  autoconf.noarch 0:2.69-11.el7         automake.noarch 0:1.13.4-3.el7         bison.x86_64 0:3.0.4-1.el7                  byacc.x86_64 0:1.9.20130304-3.el7      cscope.x86_64 0:15.8-10.el7
  ctags.x86_64 0:5.8-13.el7             diffstat.x86_64 0:1.57-4.el7           doxygen.x86_64 1:1.8.5-3.el7                elfutils.x86_64 0:0.170-4.el7          flex.x86_64 0:2.5.37-3.el7
  gcc.x86_64 0:4.8.5-28.el7_5.1         gcc-c++.x86_64 0:4.8.5-28.el7_5.1      gcc-gfortran.x86_64 0:4.8.5-28.el7_5.1      indent.x86_64 0:2.2.11-13.el7          intltool.noarch 0:0.50.2-7.el7
  libtool.x86_64 0:2.4.2-22.el7_3       patch.x86_64 0:2.7.1-10.el7_5          patchutils.x86_64 0:0.3.3-4.el7             rcs.x86_64 0:5.9.0-5.el7               redhat-rpm-config.noarch 0:9.1.0-80.el7.centos
  rpm-build.x86_64 0:4.11.3-32.el7      rpm-sign.x86_64 0:4.11.3-32.el7        subversion.x86_64 0:1.7.14-14.el7           swig.x86_64 0:2.0.10-5.el7             systemtap.x86_64 0:3.2-4.el7

Otherwise you will have the following error, when you try to compile the packages from GIT.

[postgres@psqlxla ~]$ cd postgres-xl/
[postgres@psqlxla postgres-xl]$ ./configure
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking which template to use... linux
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for WAL segment size... 16MB
checking for gcc... no
checking for cc... no
configure: error: in `/home/postgres/postgres-xl':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

Don't forget to install install the following packages:

zlib
zlib-devel
readlink
readline-devel
libtermcap-devel

Cloning the Repository

Now we can start to clone the repository, with the postgres user:

[postgres@psqlxla ~]$ git clone git://git.postgresql.org/git/postgres-xl.git
Cloning into 'postgres-xl'...
remote: Counting objects: 555874, done.
remote: Compressing objects: 100% (95291/95291), done.
remote: Total 555874 (delta 470773), reused 542811 (delta 458445)
Receiving objects: 100% (555874/555874), 167.82 MiB | 1.68 MiB/s, done.
Resolving deltas: 100% (470773/470773), done.
[postgres@psqlxla ~]$

Compilation

Once all the packages are clone we can compile them:

[postgres@psqlxla postgres-xl]$ ./configure
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking which template to use... linux
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for WAL segment size... 16MB
checking for gcc... gcc
checking whether the C compiler works... yes
configure: using CPPFLAGS= -D_GNU_SOURCE
configure: using LDFLAGS=  -Wl,--as-needed
configure: creating ./config.status
config.status: creating GNUmakefile
config.status: creating src/Makefile.global
config.status: creating src/include/pg_config.h
config.status: creating src/include/pg_config_ext.h
config.status: creating src/interfaces/ecpg/include/ecpg_config.h
config.status: linking src/backend/port/tas/dummy.s to src/backend/port/tas.s
config.status: linking src/backend/port/dynloader/linux.c to src/backend/port/dynloader.c
config.status: linking src/backend/port/posix_sema.c to src/backend/port/pg_sema.c
config.status: linking src/backend/port/sysv_shmem.c to src/backend/port/pg_shmem.c
config.status: linking src/backend/port/dynloader/linux.h to src/include/dynloader.h
config.status: linking src/include/port/linux.h to src/include/pg_config_os.h
config.status: linking src/makefiles/Makefile.linux to src/Makefile.port

Finish

Compile and install the packages as follows:

Compile

[root@psqlxla postgres-xl]# make


PIC -DREFINT_VERBOSE -I. -I. -I../../src/include  -D_GNU_SOURCE   -c -o refint.o refint.c
gcc -DPGXC -DXCP -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -L../../src/port -L../../src/common -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags -L../../src/port -lpgport  -shared -o refint.so refint.o
gcc -DPGXC -DXCP -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -DREFINT_VERBOSE -I. -I. -I../../src/include  -D_GNU_SOURCE   -c -o timetravel.o timetravel.c
gcc -DPGXC -DXCP -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -L../../src/port -L../../src/common -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags -L../../src/port -lpgport  -shared -o timetravel.so timetravel.o
make[3]: Leaving directory `/home/postgres/postgres-xl/contrib/spi'
gcc -DPGXC -DXCP -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I../../../src/include  -D_GNU_SOURCE  -I../../../src/port '-DHOST_TUPLE="x86_64-pc-linux-gnu"' '-DSHELLPROG="/bin/sh"' '-DDLSUFFIX=".so"'  -c -o pg_regress.o pg_regress.c
gcc -DPGXC -DXCP -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC -I../../../src/include  -D_GNU_SOURCE   -c -o pg_regress_main.o pg_regress_main.c
gcc -DPGXC -DXCP -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -fPIC pg_regress.o pg_regress_main.o -L../../../src/port -L../../../src/common -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags  -lpgcommon -lpgport -lpthread -lz -lreadline -lrt -lcrypt -ldl -lm  -o pg_regress
cp ../../../contrib/spi/refint.so refint.so
cp ../../../contrib/spi/autoinc.so autoinc.so
make[2]: Leaving directory `/home/postgres/postgres-xl/src/test/regress'
make -C test/perl all
make[2]: Entering directory `/home/postgres/postgres-xl/src/test/perl'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/postgres/postgres-xl/src/test/perl'
make[1]: Leaving directory `/home/postgres/postgres-xl/src'
make -C config all
make[1]: Entering directory `/home/postgres/postgres-xl/config'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/postgres/postgres-xl/config'
All of Postgres-XL successfully made. Ready to install.

Install

By default PostgreSQL will install on: /usr/local/pgsql/

[root@psqlxla postgres-xl]# make install
make -C src install
make[1]: Entering directory `/home/postgres/postgres-xl/src'
make -C common install
make[2]: Entering directory `/home/postgres/postgres-xl/src/common'
make -C ../backend submake-errcodes
make[3]: Entering directory `/home/postgres/postgres-xl/src/backend'
make[3]: Nothing to be done for `submake-errcodes'.
make[3]: Leaving directory `/home/postgres/postgres-xl/src/backend'
/bin/mkdir -p '/usr/local/pgsql/lib'
/bin/install -c -m 644  libpgcommon.a '/usr/local/pgsql/lib/libpgcommon.a'
make[2]: Leaving directory `/home/postgres/postgres-xl/src/common'
make -C port install
make[2]: Entering directory `/home/postgres/postgres-xl/src/port'
make -C ../backend submake-errcodes
make[3]: Entering directory `/home/postgres/postgres-xl/src/backend'
make[3]: Nothing to be done for `submake-errcodes'.
make[3]: Leaving directory `/home/postgres/postgres-xl/src/backend'
/bin/mkdir -p '/usr/local/pgsql/lib'
/bin/install -c -m 644  libpgport.a '/usr/local/pgsql/lib/libpgport.a'
make[2]: Leaving directory `/home/postgres/postgres-xl/sr
........................................................
make -C config install
make[1]: Entering directory `/home/postgres/postgres-xl/config'
/bin/mkdir -p '/usr/local/pgsql/lib/pgxs/config'
/bin/install -c -m 755 ./install-sh '/usr/local/pgsql/lib/pgxs/config/install-sh'
/bin/install -c -m 755 ./missing '/usr/local/pgsql/lib/pgxs/config/missing'
make[1]: Leaving directory `/home/postgres/postgres-xl/config'
Postgres-XL installation complete.

Check

[root@psqlxla postgres-xl]# cd /usr/local/pgsql/
[root@psqlxla pgsql]# ls -lart
total 16
drwxr-xr-x. 13 root root  144 May 26 15:47 ..
drwxr-xr-x.  6 root root   56 May 26 15:47 .
drwxr-xr-x.  6 root root 4096 May 26 15:47 include
drwxr-xr-x.  2 root root 4096 May 26 15:47 bin
drwxr-xr-x.  6 root root 4096 May 26 15:47 share
drwxr-xr-x.  4 root root 4096 May 26 15:47 lib
[root@psqlxla pgsql]#

Repeat this on the rest of the nodes :)

Database Installation

In order to start our cluster configuration we should do couple things:

Compile pgxc_ctl utility

This package is located at: “/home/postgres/postgres-xl/contrib/pgxc_ctl”

Firstly, enter there as posgres and compile this as follows:

[postgres@psqlxla pgxc_ctl]$ make
cd ../../contrib/pgxc_ctl && ./make_signature
gcc -DPGXC -DXCP -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -DFRONTEND -DDLSUFFIX=\".so\" -I. -I../../src/interfaces/libpq -I. -I. -I../../src/include  -D_GNU_SOURCE   -c -o pgxc_ctl_bash.o pgxc_ctl_bash.c
gcc -DPGXC -DXCP -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -DFRONTEND -DDLSUFFIX=\".so\" -I. -I../../src/interfaces/libpq -I. -I. -I../../src/include  -D_GNU_SOURCE   -c -o bash_handler.o bash_handler.c
gcc -DPGXC -DXCP -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -DFRONTEND -DDLSUFFIX=\".so\" -I. -I../../src/interfaces/libpq -I. -I. -I../../src/include  -D_GNU_SOURCE   -c -o config.o config.c
gcc -DPGXC -DXCP -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -DFRONTEND -DDLSUFFIX=\".so\" -I. -I../../src/interfaces/libpq -I. -I. -I../../src/include  -D_GNU_SOURCE   -c -o pgxc_ctl.o pgxc_ctl.c
pgxc_ctl.c: In function ‘main’:
pgxc_ctl.c:429:8: warning: variable ‘verb

After this, install the package with root as follows:

[root@psqlxla pgxc_ctl]# make install
/bin/mkdir -p '/usr/local/pgsql/bin'
/bin/install -c  pgxc_ctl '/usr/local/pgsql/bin'

Disable/Edit firewall

To disable/edit the firewall just turn off and disable the “firewalld” demon as follows:

[root@psqlxla pgxc_ctl]# service firewalld stop
[root@psqlxla ~]# chkconfig firewalld off
Note: Forwarding request to 'systemctl disable firewalld.service'.
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@psqlxla ~]# getenforce
Enforcing
[root@psqlxla ~]# setenforce 0
[root@psqlxla ~]# getenforce
Permissive

This will also disable the SeLinux policy to permissive. Repeat that for the rest of the nodes

Edit SeLinux

Edit the /etc/selinux/config file as follows:

[root@psqlxlb ~]# cat /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=permissive                   <- This line to Permissive :)
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

Configure passwordless connection

In order to do that, we have to create RSA public key and ship it to the other nodes. Furthermore, the directory and file permissions should be specific. Otherwise, it won't work if you give them too many permissions as well.

On host1, generate the authentication key file,
ssh-keygen -t rsa (Just press ENTER for all input values)
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys


Create directory ".ssh" in the home of every postgres user.

On host1, upload file authorized_keys to host2, host3 and host3, as following,
scp ~/.ssh/authorized_keys [email protected]:~/.ssh/
scp ~/.ssh/authorized_keys [email protected]:~/.ssh/
scp ~/.ssh/authorized_keys [email protected]:~/.ssh/

On every host, run following commands,
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

On host1, try to connect host2, host3 and host4, make sure no password is needed,
ssh [email protected]
ssh [email protected]
ssh [email protected]

Initialize the cluster

In order to initialize our cluster we have to execute the pgxc_ctl ONCE on host1 so it will create the: /home/postgres/pgxc_ctl directory. PostgreSQL-XL uses this as default directory for it's configuration files. Create a new file called: “pgxc_ctl.conf” with the following values (according your configuration)

#user and path
pgxcOwner=postgres
pgxcUser=$pgxcOwner
pgxcInstallDir=/usr/local/pgsql
tmpDir=/tmp # temporary dir used in XC servers
localTmpDir=$tmpDir # temporary dir used here locally

#gtm and gtmproxy
gtmMasterDir=$HOME/pgxc/nodes/gtm
gtmMasterPort=6666
gtmMasterServer=192.168.100.10
gtmSlave=n

#gtm proxy
gtmProxy=n

#coordinator
coordMasterDir=$HOME/pgxc/nodes/coord
coordNames=(coord1)
coordPorts=(5432)
poolerPorts=(6668)
coordPgHbaEntries=(192.168.100.0/24)
coordMasterServers=(192.168.100.20)
coordMasterDirs=($coordMasterDir/coord1)
coordMaxWALsernder=0
coordMaxWALSenders=($coordMaxWALsernder)
coordSlave=n
coordSpecificExtraConfig=(none none none)
coordSpecificExtraPgHba=(none none none)

#datanode
datanodeNames=(datanode1 datanode2)
datanodePorts=(15432 15433)
datanodePoolerPorts=(6669 6670)
datanodePgHbaEntries=(192.168.100.0/24)
datanodeMasterServers=(192.168.100.30 192.168.100.40)
datanodeMasterDir=$HOME/pgxc/nodes/dn_master
datanodeMasterDirs=($datanodeMasterDir/datanode1 $datanodeMasterDir/datanode2)
datanodeMaxWalSender=0
datanodeMaxWALSenders=($datanodeMaxWalSender $datanodeMaxWalSender)
datanodeSlave=n
primaryDatanode=datanode1

After all this :) We can start the initialization as follows:

[postgres@psqlxla pgxc_ctl]$ pgxc_ctl init all
/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
Initialize GTM master
The files belonging to this GTM system will be owned by user "postgres".
This user must also own the server process.


fixing permissions on existing directory /home/postgres/pgxc/nodes/gtm ... ok
creating configuration files ... ok
creating control file ... ok

Success.
waiting for server to shut down.... done
server stopped
Done.
Start GTM master
server starting
Initialize all the coordinator masters.
Initialize coordinator master coord1.
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /home/postgres/pgxc/nodes/coord/coord1 ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... creating cluster information ... ok
syncing data to disk ... ok
freezing database template0 ... ok
freezing database template1 ... ok
freezing database postgres ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success.
Done.
Starting coordinator master.
Starting coordinator master coord1
2018-05-27 17:44:53.115 EDT [9364] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2018-05-27 17:44:53.115 EDT [9364] LOG:  listening on IPv6 address "::", port 5432
2018-05-27 17:44:53.120 EDT [9364] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2018-05-27 17:44:53.134 EDT [9365] LOG:  database system was shut down at 2018-05-27 17:44:49 EDT
2018-05-27 17:44:53.137 EDT [9364] LOG:  database system is ready to accept connections
2018-05-27 17:44:53.138 EDT [9372] LOG:  cluster monitor started
Done.
Initialize all the datanode masters.
Initialize the datanode master datanode1.
Initialize the datanode master datanode2.
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /home/postgres/pgxc/nodes/dn_master/datanode1 ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... creating cluster information ... ok
syncing data to disk ... ok
freezing database template0 ... ok
freezing database template1 ... ok
freezing database postgres ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success.
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /home/postgres/pgxc/nodes/dn_master/datanode2 ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... creating cluster information ... ok
syncing data to disk ... ok
freezing database template0 ... ok
freezing database template1 ... ok
freezing database postgres ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success.
Done.
Starting all the datanode masters.
Starting datanode master datanode1.
Starting datanode master datanode2.
2018-05-27 17:45:08.891 EDT [1851] LOG:  listening on IPv4 address "0.0.0.0", port 15432
2018-05-27 17:45:08.891 EDT [1851] LOG:  listening on IPv6 address "::", port 15432
2018-05-27 17:45:08.899 EDT [1851] LOG:  listening on Unix socket "/tmp/.s.PGSQL.15432"
2018-05-27 17:45:08.909 EDT [1851] LOG:  redirecting log output to logging collector process
2018-05-27 17:45:08.909 EDT [1851] HINT:  Future log output will appear in directory "pg_log".
2018-05-27 17:45:08.896 EDT [1830] LOG:  listening on IPv4 address "0.0.0.0", port 15433
2018-05-27 17:45:08.896 EDT [1830] LOG:  listening on IPv6 address "::", port 15433
2018-05-27 17:45:08.902 EDT [1830] LOG:  listening on Unix socket "/tmp/.s.PGSQL.15433"
2018-05-27 17:45:08.913 EDT [1830] LOG:  redirecting log output to logging collector process
2018-05-27 17:45:08.913 EDT [1830] HINT:  Future log output will appear in directory "pg_log".
Done.
ALTER NODE coord1 WITH (HOST='192.168.100.20', PORT=5432);
ALTER NODE
CREATE NODE datanode1 WITH (TYPE='datanode', HOST='192.168.100.30', PORT=15432, PRIMARY);
CREATE NODE
CREATE NODE datanode2 WITH (TYPE='datanode', HOST='192.168.100.40', PORT=15433);
CREATE NODE
SELECT pgxc_pool_reload();
 pgxc_pool_reload
------------------
 t
(1 row)

Done.
EXECUTE DIRECT ON (datanode1) 'CREATE NODE coord1 WITH (TYPE=''coordinator'', HOST=''192.168.100.20'', PORT=5432)';
EXECUTE DIRECT
EXECUTE DIRECT ON (datanode1) 'ALTER NODE datanode1 WITH (TYPE=''datanode'', HOST=''192.168.100.30'', PORT=15432, PRIMARY)';
EXECUTE DIRECT
EXECUTE DIRECT ON (datanode1) 'CREATE NODE datanode2 WITH (TYPE=''datanode'', HOST=''192.168.100.40'', PORT=15433)';
EXECUTE DIRECT
EXECUTE DIRECT ON (datanode1) 'SELECT pgxc_pool_reload()';
 pgxc_pool_reload
------------------
 t
(1 row)

EXECUTE DIRECT ON (datanode2) 'CREATE NODE coord1 WITH (TYPE=''coordinator'', HOST=''192.168.100.20'', PORT=5432)';
EXECUTE DIRECT
EXECUTE DIRECT ON (datanode2) 'CREATE NODE datanode1 WITH (TYPE=''datanode'', HOST=''192.168.100.30'', PORT=15432, PRIMARY)';
EXECUTE DIRECT
EXECUTE DIRECT ON (datanode2) 'ALTER NODE datanode2 WITH (TYPE=''datanode'', HOST=''192.168.100.40'', PORT=15433)';
EXECUTE DIRECT
EXECUTE DIRECT ON (datanode2) 'SELECT pgxc_pool_reload()';
 pgxc_pool_reload
------------------
 t
(1 row)

Done.

Congrats, you have a brand new PostgreSQL-XL cluster