How to use my own PostgreSQL instead of the PostgreSQL bundled with Applications Manager ?

How to use my own PostgreSQL instead of the PostgreSQL bundled with Applications Manager ?

Applications Manager standalone v17 and above comes bundled with PostgreSQL 15 and Applications Manager plugin comes bundled with PostgreSQL 14. If you want to use your own PostgreSQL instead, follow the steps mentioned below :

Prerequisites:
  1. A compatible PostgreSQL database version (PostgreSQL 15.x for Applications Manager standalone or PostgreSQL 14.x for Applications Manager plugin) should be accessible from the Applications Manager installation.
  2. The PostgreSQL database must have the following extensions installed and enabled:
    1. amcheck
    2. citext
    3. pgcrypto
    4. pg_stat_statements
  3. Network connectivity and PostgreSQL configuration requirements:
    1. The IP address of the Applications Manager server must be included in the listen_addresses parameter in the postgresql.conf file.
    2. The pg_hba.conf file must include an entry allowing connections from the Applications Manager server host.
  4. A PostgreSQL user account with the following privileges:
    1. LOGIN
    2. CREATE DATABASE
    3. Full control over tables in the database
Execute the following SQL query to create the required user, database, privileges, and extensions. Replace <username> and <password> below with your preferred values:
-- Create user with appropriate privileges
CREATE USER <username> WITH CREATEDB NOCREATEROLE LOGIN ENCRYPTED PASSWORD '<password>';

-- Create new database (owned by the user)
CREATE DATABASE amdb OWNER <username>;

-- Connect to the database
\c amdb;

-- Grant monitoring role
GRANT pg_monitor TO <username>;

-- Grant backup functions
GRANT EXECUTE ON FUNCTION pg_backup_start(text) TO <username>;
GRANT EXECUTE ON FUNCTION pg_backup_stop() TO <username>;

-- Grant schema privileges
GRANT ALL ON SCHEMA public TO <username>;

-- Set default privileges for future objects
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO <username>;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO <username>;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON FUNCTIONS TO <username>;

-- Create required extensions
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE EXTENSION IF NOT EXISTS citext;
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
CREATE EXTENSION IF NOT EXISTS amcheck;
Steps:
  1. Shut down Applications Manager.
  2. Edit <AppManager_Home>\conf\AMServer.properties file using a text editor (take a backup of this file before making any changes) and make the following changes :
    • Change line 
      am.dbport.check=true
      to 
      am.dbport.check=false

    • Change 
      am.db.port=15432
      to 
      am.db.port=<port of your PostgreSQL>      (ex:  am.db.port=5432)

  3. Edit <AppManager_Home>\working\conf\database_params.conf file using a text editor (take a backup of this file before making any changes) and make the following changes :
    • Specify the host and port of your own PostgreSQL. Change line 
      url jdbc:postgresql://localhost:15432/amdb?dontTrackOpenResources=true&useUnicode=true&characterEncoding=UTF-8 AppModules TopoDB-MapDB-EventDB-AlertDB-PollDB-PolicyDB-USERSTORAGEDB-ApplnDB
      to
      url jdbc:postgresql://<PostgreSQL Host>:<PostgreSQL Port>/amdb?dontTrackOpenResources=true&useUnicode=true&characterEncoding=UTF-8 AppModules TopoDB-MapDB-EventDB-AlertDB-PollDB-PolicyDB-USERSTORAGEDB-ApplnDB

      Example:
      jdbc:postgresql://192.168.233.171:5432/amdb?dontTrackOpenResources=true&useUnicode=true&characterEncoding=UTF-8

    • Specify the username of your own PostgreSQL. Change line 
      username dbuser AppModules TopoDB-MapDB-EventDB-AlertDB-PollDB-PolicyDB-USERSTORAGEDB-ApplnDB
      to 
      username <PostgreSQL username> AppModules TopoDB-MapDB-EventDB-AlertDB-PollDB-PolicyDB-USERSTORAGEDB-ApplnDB

      Example:
      username apm AppModules TopoDB-MapDB-EventDB-AlertDB-PollDB-PolicyDB-USERSTORAGEDB-ApplnDB

    • Specify the password of your own PostgreSQL. Change line 
      encryptedpassword eK6q1CJ9697s7O AppModules TopoDB-MapDB-EventDB-AlertDB-PollDB-PolicyDB-USERSTORAGEDB-ApplnDB
      to
      password <PostgreSQL password> AppModules TopoDB-MapDB-EventDB-AlertDB-PollDB-PolicyDB-USERSTORAGEDB-ApplnDB

      Example:
      password appmanager AppModules TopoDB-MapDB-EventDB-AlertDB-PollDB-PolicyDB-USERSTORAGEDB-ApplnDB

    • Update the same PostgreSQL username and password in below lines

      # Super-user username and Super-user password for the database
      su_username=postgres
      su_encryptedpassword=7a30f67cccd1f622c278718fc8ce25ad8f2d2eb24e432e63e560862fd53a4d35afd5bc242623704c6b9b7118eea81e4530e6238426965aa47acd5f325d73ef2c
      # Read-only username and Read-only password for the database if any
      ro_username=rouser
      ro_encryptedpassword=
      e5dab3bb63a9a813ae9cb6cbd3054a5e9f362df2b0719b60386797a25c52cbcc59c1f07cc574fe0796e2bec4aa2f25ce9c7a8f4bfacaecdbba54fc8a97ca20d5

      to

      # Super-user username and Super-user password for the database
      su_username=
      <PostgreSQL username>
      su_password=<PostgreSQL password>
      # Read-only username and Read-only password for the database if any
      ro_username=
      <PostgreSQL username>
      ro_password=<PostgreSQL password>

      Example:
      # Super-user username and Super-user password for the database
      su_username=
      apm 
      su_password=appmanager 
      # Read-only username and Read-only  assword for the database if any
      su_username=
      apm 
      su_password=appmanager

  4. Take a backup of <AppManager_Home>\working\bin\startPGSQL.bat/.sh file and <AppManager_Home>\working\bin\stopPGSQL.bat/.sh file.
  5. Start Applications Manager.

                    New to ADSelfService Plus?

                      • Related Articles

                      • Steps to configure Azure PostgreSQL Database as Applications Manager's back-end

                        Applications Manager comes bundled with PostgreSQL. If you want to use your own PostgreSQL instead, follow the steps mentioned below: Prerequisites: A compatible PostgreSQL database should be accessible from Applications Manager installation. To know ...
                      • PostgreSQL authentication failure during Applications Manager startup

                        Problem: Applications Manager fails to start due to PostgreSQL authentication failure and shows the following error: The following errors are observed in the startup log (StartUpLogs_err.log) file, located under <Applications Manager Home>\logs\ ...
                      • Migrating the JRE bundled in Applications Manager

                        JRE Upgrade Document for Applications Manager This document helps the end-user in upgrading to the latest version of Java used in Applications Manager. The steps for Java upgrade in both Windows (Service and Non-Service mode) and Linux installations ...
                      • Installing Applications Manager in AWS

                        Applications Manager can be installed in EC2 instances in both Windows and Linux platforms. Applications Manager comes with bundled PostgreSQL. Installing Applications Manager in EC2 for Windows Go to EC2 console and launch an "Windows" instance with ...
                      • Installing Applications Manager in Cloud (AWS, Azure)

                        To install Applications Manager in the cloud, we can use any of the below methods: AWS/Azure marketplace Direct installation AWS/Azure marketplace Applications manager is readily available in AWS/Azure marketplace as a pre-installed product. AWS ...