cancel
Showing results for 
Search instead for 
Did you mean: 

Running multiple instances of EPAS on a single machine in RHEL 7

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.

 

  1. Choose and create the location for the data directory for the second instance. This example uses /var/lib/edb_2/as11/data as the second data directory.
  2. Update the permissions on the new folder so that the admin user (enterprisedb) owns it:
    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
    
  3. Run 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
    
  4. Create a copy of the EPAS service (EPAS 11 uses edb-as-11.service) and creating a copy called edb-as-11_2.service

    [root@6dab5b954361 as11]# cp /usr/lib/systemd/system/edb-as-11.service /etc/systemd/system/multi-user.target.wants/edb-as-11_2.service
    
  5. Update the new service file to match the settings for the second data directory.
    [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
    
  6. Update the 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)
    
  7. Start the second instance of EPAS:

    [root@6dab5b954361 as11]# systemctl daemon-reload
    [root@6dab5b954361 as11]# systemctl start edb-as-11_2
    
  8. 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
    
Version history
Revision #:
10 of 10
Last update:
2 weeks ago
Updated by: