Article ID: 130548, created on Mar 30, 2017, last review on May 18, 2017

Overview

This instruction for relocating the Operations database to a remote DB node is applicable to Odin Automation Premium 7.1.

The article contains instructions on how to move the Operations database (PostgreSQL 9.6.x) from the Management Node (MN) to a remote DB node. Please note that during the operation, the provisioning engine and control panel will not be available. The new database node should have at least as much memory as the Management Node has.

The database migration process consists of the following parts:

  1. Preparing Linux environment on the MN and remote DB node.

    Note: Make sure that there is enough disk space on the MN and remote DB node. The node hosting database needs extra 256 GB of free disk space for storing WAL files (16384 WAL files * 16 MB each).

  2. Installing the PGHA package on the MN. Propagating the scripts from the MN to the remote DB node.
  3. Running the scripts for Operations DB pre-configuration and migration to the remote DB node.
  4. Enabling PostgreSQL on the remote DB node.

Preparing Linux Environment on the Management and Remote DB Node

Preparing Linux environment on the MN:

  1. Log in to the MN via SSH using root credentials.
  2. Update /etc/hosts file by adding the record for resolving IP addresses in the specified hostname (replace placeholder <...> with actual backnet IP address of the remote DB node).

    <Remote_DB_Node_Backnet_IP> a.db.node
    
  3. Make sure that there are no already generated keys on the node:

    ls ~/.ssh/id_rsa.pub
    

    If the execution result contains the string "No such file or directory", which denotes absence of the key, then the user has no ssh key generated. Generate new RSA key:

    ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
    

    Important: If there is already existing key, you should not generate a new key, otherwise the existing key will be overwritten with the newly generated one. Note that the existing key should not have password protection, otherwise this key is not appropriate for usage.

  4. Propagate it to the remote DB node.

    ssh-copy-id root@a.db.node
    

    To check that the passwordless access works successfully, try to log in to the remote DB node (the password won't be asked):

    ssh root@a.db.node
    

Preparing Linux environment on the remote DB node:

  1. Log in to the remote DB node via SSH using root credentials.
  2. Configure the kernel parameters kernel.shmall and kernel.shmmax on the remote DB node in the same way they are configured on the MN:

    1. Copy the lines kernel.shmmax = ... and kernel.shmall = ... from the /etc/sysctl.conf on the MN, paste them to the /etc/sysctl.conf on the remote DB node.
    2. Execute the following command on the remote DB node:

      sysctl -p
      
  3. Install PostgreSQL on the remote DB node. It should be of exactly the same version as Operations DB (the version can be different from the written below).

    • postgresql96.x86_64

    • postgresql96-contrib.x86_64

    • postgresql96-libs.x86_64

    • postgresql96-server.x86_64

Installing the PGHA Package Containing Scripts for DB Migration

To install the PGHA package on the MN, do the following:

  1. In OA Operations control panel, go to Infrastructure > Service Nodes.
  2. Click the Management Node link in the list.
  3. Switch to the Packages tab and click Install Package.
  4. Find the ppm package by name pgha-cluster and click install icon in the Actions column.
  5. Specify the necessary settings by clicking enter_parameters icon in the Actions column. The following property should be set:

    Backnet IP address of DB node A – backnet IP address of the remote DB node where the Operations database will be relocated.

  6. When ready, click Finish.

After the package installation is completed, the scripts are installed on the Management Node. To view them, do the following:

  1. Log in to the MN by SSH using root credentials.
  2. Open the folder where the scripts are located:

    cd /usr/local/pem/bin/pgha
    
  3. Make sure that the folder is not empty.

To copy the scripts and poaupdater library files to the remote DB node, do the following:

  1. On the MN, log in remotely to the DB node and create the folder for scripts:

    ssh root@a.db.node mkdir /usr/local/pem/bin/pgha/ -p
    
  2. Copy the scripts from the a.db.node folder on the MN to the newly created folder on the remote DB node:

    scp -r ./dbnode/a.db.node/* root@a.db.node:/usr/local/pem/bin/pgha/
    
  3. Copy the poaupdater library files from the MN to the remote DB node:

    scp -r /usr/lib/python2.7/site-packages/poaupdater root@a.db.node:/usr/lib/python2.7/site-packages
    

Running Scripts for the Operations DB Pre-Configuration and Migration

To make the needed pre-configuration of the Operations DB before the migration, do the following:

  1. Log in to the MN via SSH using root credentials.
  2. Open the folder where the scripts are located:

    cd /usr/local/pem/bin/pgha
    
  3. Run the following script:

    ./preconf.py
    

    Note: The log data are written in the preconf.log file, located in the /var/log/pa folder. If any issues occur, refer to this log file for details.

To move the Operations DB to the remote DB node, run the following script:

    ./move_master.py move-to-remote

Note: The log data are written in the move_master.log file, located in the /var/log/pa folder. If any issues occur, refer to this log file for details.

Enabling PostgreSQL on the Remote DB Node

After the Operations DB relocation to the remote DB node, do the following:

  1. Disable PostgreSQL on the MN. To do it, log in to the MN and perform the following script:

    systemctl disable postgresql-9.6
    

    PostgreSQL packages installed on the MN should not be deleted while the content of the database folder /var/lib/pgsql/9.6/data can be deleted at your option.

  2. Enable PostgreSQL on the remote DB node. To do it, log in to the remote DB node and perform the following script:

    systemctl enable postgresql-9.6
    

    As a result, the Operations DB is located on the remote DB node and the DB Client is switched to this database.

Email subscription for changes to this article
Save as PDF