Running multiple clusters on the same machine is not an ideal setup; however, it might be helpful in certain cases and can be beneficial in development or testing environments. In order to ensure that both the clusters work as operating system services, a separate service for the secondary instance of EnterpriseDB PostgreSQL Advanced Server (EPAS) needs to be configured, and this article will walk through the steps for doing so.
This example uses EPAS 11 on Red Hat Enterprise Linux (RHEL) 7 and the filenames reflect that; please ensure the names reflect the version of EPAS installed on the server, and the commands used reflect the OS being used. This article assumes that an instance of EPAS has already been installed and is running; if not, please see this article on how to set up the first instance of EPAS. These steps will also work for community Postgres installations, although the file names and locations may be slightly different.
/var/lib/edb_2/as11/dataas the second data directory.
chown enterprisedb:enterprisedb /var/lib/edb_2/as11/data [root@6dab5b954361 /]# ll /var/lib/edb_2/as11 total 4 drwx------ 21 enterprisedb enterprisedb 4096 May 31 22:35 data
initdb to create the data directory for the second instance.
[root@6dab5b954361 as11]# su - enterprisedb Last login: Fri May 31 21:47:05 UTC 2019 on pts/1 -bash-4.2$ /usr/edb/as11/bin/initdb -D /var/lib/edb_2/as11/data
Create a copy of the EPAS service (EPAS 11 uses
edb-as-11.service) and creating a copy called
[root@6dab5b954361 as11]# cp /usr/lib/systemd/system/edb-as-11.service /etc/systemd/system/multi-user.target.wants/edb-as-11_2.service
[root@6dab5b954361 as11]# vi /etc/systemd/system/multi-user.target.wants/edb-as-11_2.service # Location of database directory Environment=PGDATA=/var/lib/edb_2/as11/data PIDFile=/var/lib/edb_2/as11/data/postmaster.pid
postgresql.conf file for the second data directory so that the second instance is on a different port than the first.
[root@6dab5b954361 /]# vi /var/lib/edb_2/as11/data/postgresql.conf port = 5445 # (change requires restart)
Start the second instance of EPAS:
[root@6dab5b954361 as11]# systemctl daemon-reload [root@6dab5b954361 as11]# systemctl start edb-as-11_2
At this point, you should be set up. You can verify that both EPAS instances are up and running using the
show data_directory; command after signing into each EPAS instance:
[root@6dab5b954361 /]# su - enterprisedb -c "psql -d edb" psql.bin (11.3.10) Type "help" for help. edb=# show data_directory; data_directory ------------------------ /var/lib/edb/as11/data (1 row) edb=# \q [root@6dab5b954361 /]# su - enterprisedb -c "psql -d edb -p 5445" psql.bin (11.3.10) Type "help" for help. edb=# show data_directory; data_directory -------------------------- /var/lib/edb_2/as11/data (1 row) edb=# \q