Failover Support Using PostgreSQL as Backend DB Server


Follow the steps given below to configure failover using PostgreSQL as database backend in Applications Manager:

1. Configuring database server:

For setting up the remote database server, PostgreSQL DB has to be installed and started. To do so, follow the steps given below:

  • Install Applications Manager on the remote server where you need to run the DB. While installing, make sure to select the database as PostgreSQL and complete the installation. Installation Steps

    Note: For Windows users, make sure to install Applications Manager as administrator.

  • Once the installation is complete, start the Applications Manager instance once and then stop it.
  • Open the command terminal as administrator, then navigate to <Applications Manager Home> directory and execute the below command:
    • shutdownApplicationsManager.bat -force (Windows)
    • sh shutdownApplicationsManager.sh -force (Linux)
    • Repeat the above command to ensure that all processes are stopped.
  • Open the command terminal as an administrator, navigate to the <Applications Manager Home>/bin directory, and execute the following command to uninstall the Applications Manager service:
    • uninstallservice.bat (Windows)
    • sh uninstallservice.sh (Linux)
  • Once the above step is complete, navigate to <Applications Manager Home>/working/pgsql/data/amdbdirectory and implement the following changes:
    • Open the pg_hba.conf file and change the ADDRESS from 127.0.0.1/32 to 0.0.0.0/0 under # IPv4 local connections. (This will allow connections to be made to this PGSQL DB from remote servers.)
    • Open the postgresql.conf file, then uncomment the line listen_addresses and replace 'localhost' with '*'.
  • Now start the PostgreSQL database using any one of the following steps:
    • Windows: Install PostgreSQL as Windows service by navigating to <Applications Manager Home>/working/bin directory and executing the register_pgdbservice.bat file in command terminal. Then start the PostgreSQL DB server by executing the startPGSQL.bat file.
    • Linux: Navigate to <Applications Manager Home>/working/bin directory in command terminal and start the PostgreSQL DB server by executing the command: sh startPGSQL.sh &

Upon completing the above steps, the PostgreSQL database server should be ready for connections.

2. Configuring Primary Server:

  • Install Applications Manager on the remote server by selecting the database as PostgreSQL and complete the installation. Installation Steps
  • Start this installation at least once and stop it as follows:
    • In Windows services, make sure the ManageEngine Applications Manager service is stopped.
    • From Applications Manager server, open an Administrator command prompt window.
    • Go to <Applications Manager Home> folder and run the following command:
      shutdownApplicationsManager.bat -force
    • Repeat the above command to ensure that all processes are stopped.
  • Open the AMServer.properties file located under <Applications Manager Home>/conf/ directory and update the below entries:

    am.dbserver.type=pgsql
    am.db.port=15432 (Port number can be confirmed from the postgres_ext.conf file of the PostgreSQL database server installed, which is located under <Applications Manager Home>/working/pgsql/data/amdb/ directory.)
    am.dbport.check=false

  • Open the database_params.conf file located under <Applications Manager Home>/working/conf/PGSQL as well as <Applications Manager Home>/working/conf directories and replace existing the JDBC URL with that of the following URL containing the hostname and port of the PostgreSQL DB server for both the files:

    Url jdbc:postgresql://apm-db-server:15432/amdb?dontTrackOpenResources=true&useUnicode=true&characterEncoding=UTF-8 AppModules TopoDB-MapDB-EventDB-AlertDB-PollDB-PolicyDB-USERSTORAGEDB-ApplnDB

  • Now start Applications Manager in Primary server using any one of the following steps:
    • Windows: Start the Applications Manager as a service by executing the installservice.bat file located under <Applications Manager Home>/bin directory. Refer here for detailed steps
    • Linux: Start the Applications Manager as a service by executing the installservice.sh file located under <Applications Manager Home>/bin directory. Refer here for detailed steps

Upon completing the above steps, the Primary server will be started and will be connected to the database server containing PostgreSQL DB.

3. Configuring Secondary/Failover Server:

  • Install Applications Manager on the remote server by selecting the database as PostgreSQL and complete the installation. Installation Steps
  • Start this installation at least once and stop it as follows:
    • In Windows services and make sure the ManageEngine Applications Manager service is stopped.
    • From Applications Manager server, open an Administrator command prompt window.
    • Go to <Applications Manager Home> folder and run the following command:
      shutdownApplicationsManager.bat -force
    • Repeat the above command to ensure that all processes are stopped.
  • Open the AMServer.properties file located under <Applications Manager Home>/conf/ directory and update the below entries:

    am.dbserver.type=pgsql
    am.db.port=15432 (Port number can be confirmed from the postgres_ext.conf file of the PostgreSQL database server installed, which is located under <Applications Manager Home>/working/pgsql/data/amdb/ directory.)
    am.dbport.check=false

  • Open the database_params.conf file located under <Applications Manager Home>/working/conf/PGSQL as well as <Applications Manager Home>/working/conf directories and replace existing the JDBC URL with that of the following URL containing the hostname and port of the PostgreSQL DB server for both the files:

    Url jdbc:postgresql://apm-db-server:15432/amdb?dontTrackOpenResources=true&useUnicode=true&characterEncoding=UTF-8 AppModules TopoDB-MapDB-EventDB-AlertDB-PollDB-PolicyDB-USERSTORAGEDB-ApplnDB

  • Now start Applications Manager in Secondary/Failover server using any one of the following steps:
    • Windows: Start the Applications Manager as a service by executing the installservice.bat file located under <Applications Manager Home>/bin directory. Refer here for detailed steps
    • Linux: Start the Applications Manager as a service by executing the installservice.sh file located under <Applications Manager Home>/bin directory. Refer here for detailed steps

Upon completing the above steps, the Secondary server will be connected to the PostgreSQL database and will listen to the Primary server. However, the installation will not be started completely as the Primary is already up and running.

You can verify whether the failover setup is configured properly with the help of logs generated from Applications Manager. Click here to view sample output