HOW-To - Resolving PostgreSQL and CMS Issues During CMS Upgrade

book

Article ID: 100074129

calendar_today

Updated On:

Description

Description

 

Resolving PostgreSQL and CMS Issues During CMS Upgrade

Issue Summary

This issue occurs during CMS upgrades (e.g., from CMS 8.0 to CMS 8.0.2), where the backend PostgreSQL database is also upgraded. During the upgrade process, the unix_socket_directories path in the PostgreSQL configuration (postgresql.conf) may change, and required directories may be missing. This results in PostgreSQL failing to start, causing the Database Service and other CMS services to stop functioning.
 

Environment Details

PostgreSQL Version

  • CMS 8.0: PostgreSQL 14.5
  • CMS 8.0.2: PostgreSQL 14.10

 

Scenarios Where This Issue Occurs

1. CMS Upgrade:

When upgrading CMS (e.g., from CMS 8.0 to CMS 8.0.2), the PostgreSQL version is upgraded (e.g., from PostgreSQL 14.5 to PostgreSQL 14.10).

The unix_socket_directories path in postgresql.conf changes from /tmp to /opt/VRTSsfmcs/tmp/psql

2. Missing Directory:

The directory specified unix_socket_directories does not exist in the upgraded environment, causing PostgreSQL to fail with a FATAL error:

FATAL: could not create lock file "/opt/VRTSsfmcs/tmp/psql/.s.PGSQL.5636.lock": No such file or directory

3. Library Path Issues:

The LD_LIBRARY_PATH environment variable is not set, causing PostgreSQL to fail due to missing libraries.

4. Permission Issues:

Incorrect ownership or permissions on the PostgreSQL data directory (/var/opt/VRTSsfmcs/db/data) prevents PostgreSQL from starting.


Steps to Resolve

 

1. Verify PostgreSQL Configuration. Check the postgresql.conf file for the unix_socket_directories and listen_addresses parameters:

 

cat /var/opt/VRTSsfmcs/db/data/postgresql.conf | egrep -i "unix_socket_directories|listen_addresses"

Example configuration:

listen_addresses = 'localhost'          # what IP address(es) to listen on

unix_socket_directories = '/opt/VRTSsfmcs/tmp/psql'

 

2. Create Missing Directory. If the directory specified in unix_socket_directories is missing, create it:

 

create a user & group if they don't exist 

# groupadd -g 99999 -o habdbsync

# useradd -g habdbsync -u 99999 -o habdbsync -s /bin/bash -m -d /var/opt/VRTSsfmh/home

# chown habdbsync:habdbsync /var/opt/VRTSsfmh/home

# mkdir -p /opt/VRTSsfmcs/tmp/psql

# chown -R habdbsync:habdbsync /opt/VRTSsfmcs/tmp/psql

# chmod 700 /opt/VRTSsfmcs/tmp/psql

 

3. Update Permissions

Ensure the PostgreSQL data directory has the correct ownership and permissions:

# chown -R habdbsync:habdbsync /var/opt/VRTSsfmcs/db/data

# chmod 700 /var/opt/VRTSsfmcs/db/data

 

4. Export Library Path

If libraries are missing, export the LD_LIBRARY_PATH to include the PostgreSQL library path:

# export LD_LIBRARY_PATH=/opt/VRTSsfmcs/pgsql/lib

# echo $LD_LIBRARY_PATH

 

5. Restart PostgreSQL

Restart the PostgreSQL service using the appropriate command:

# /opt/VRTSsfmcs/config/adm/vxsfmcsdb start

Verify the database logs to ensure the service is started successfully:

# tail -f /var/opt/VRTSsfmcs/db/data/db_logs/SFMdb3-03.dblog

 

6. Test Database Connectivity

Test connectivity to the database using the psql command:

# /opt/VRTSsfmcs/pgsql/bin/psql "dbname=SFMdb3 host=localhost user=habdbsync password= port=5636"

Example query to verify the database is operational:

# select * from habdbsync.p_sf_task where STATE='RUNNING';

 

7. Verify CMS Services

Check the status of all CMS services to ensure they are running:

# /opt/VRTSsfmcs/bin/vomsc --status ALL | grep -i server101

Example output:

Web Server (server101).........................................................[RUNNING]

Authentication Service (server101).............................................[RUNNING]

Messaging Service (server101)..................................................[RUNNING]

Database Service (server101)...................................................[RUNNING]

SNMP Trap Service (server101)..................................................[RUNNING]


Key Changes Made

Directory Creation

  • Created the missing directory /opt/VRTSsfmcs/tmp/psql and set appropriate permissions.

Configuration Updates

  • Verified and updated unix_socket_directories in postgresql.conf to point to /opt/VRTSsfmcs/tmp/psql

Library Path

  • Exported LD_LIBRARY_PATH to include /opt/VRTSsfmcs/pgsql/lib

Permissions

  • Ensured correct ownership and permissions for /var/opt/VRTSsfmcs/db/data

Service Restart

  • Restarted PostgreSQL and verified the database and CMS services were running.

Final Verification

Database Connectivity

  • Successfully connected to the database:

# /opt/VRTSsfmcs/pgsql/bin/psql "dbname=SFMdb3 host=localhost user=habdbsync password= port=5636"

CMS Services

  • Verified CMS services:

# /opt/VRTSsfmcs/bin/vomsc --status ALL | grep -i server101


Additional Notes

LD_LIBRARY_PATH

  • Ensure the LD_LIBRARY_PATH is set permanently if required by adding it to the shell profile:
  • # echo "export LD_LIBRARY_PATH=/opt/VRTSsfmcs/pgsql/lib" >> ~/.bashrc

# source ~/.bashrc

Future Updates

  • If the unix_socket_directories path changes in future updates, ensure the directory exists and is properly configured.

Conclusion

This issue arises during CMS upgrades when the backend PostgreSQL database is upgraded, leading to changes in the unix_socket_directories parameters. In PostgreSQL 14.5, the default path is /tmp, whereas in PostgreSQL 14.10, it is updated to /opt/VRTSsfmcs/tmp/psql. To resolve the issue, the missing directory was created, permissions were updated, and the correct library path was configured. To ensure consistency across environments, it is recommended to standardize the unix_socket_directories configuration, verify directory existence, set appropriate permissions, and confirm service functionality. PostgreSQL and CMS services are now running as expected.

 

Issue/Introduction

HOW-To - Resolving PostgreSQL and CMS Issues during CMS Upgrade