In-case you face postgres corruption and cases where re-installation doesn’t work. Please take a note of below steps,
Below are the cause for the same and the rectification steps . Please note according to the PG version, the libraries and its versions might change.
1) libcre, libssl and other libraries has to be installed from ansible dependent rpms and linked to equivalent bits amongst shared and standalone lib dirs.
2) Softlinks between postgresql-9.5-libs.conf and pgsql-ld-conf were broken. The same was recreated.
pgsql-ld-conf -> /usr/pgsql-9.5/share/postgresql-9.5-libs.conf
postgresql-9.5-libs.conf -> /etc/alternatives/pgsql-ld-conf
3) Psycopg2 module as stated earlier was removed manually and installed manually as well. This broke all the links from python shared modules. We tried importing the same and it failed.
[postgres@repdb2 ~]$ python -c “import psycopg2”
Traceback (most recent call last):
File “<string>”, line 1, in <module>
File “/usr/lib64/python2.7/site-packages/psycopg2/__init__.py”, line 50, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: /usr/lib64/python2.7/site-packages/psycopg2/_psycopg.so: undefined symbol: lo_truncate64
Dynamic dependencies showed that libpq.so.5 library was not having symbolic links to shared libraries in usr-lib64. This means that both python and libraried varied with differences in 32-bit and 64-bit
ldd /usr/lib64/python2.7/site-packages/psycopg2/_psycopg.so | grep libpq
libpq.so.5 => /usr/pgsql-9.5/lib/libpq.so.5 (0x00007f5334309000)
4) Created missing soft link and removal of 32-bit libs
/usr/pgsql-9.5/lib/libpq.so.5
[postgres@testmobwltrepdb2 ~]$ cd /usr/lib64/libpq.so.5
[postgres@repdb2 ~]$ cd /usr/lib64/
[postgres@repdb2 lib64]$ ls -la libpq.so.5
lrwxrwxrwx. 1 root root 12 Feb 28 13:39 libpq.so.5 -> libpq.so.5.5
postgres@repdb2 lib64]$ sudo rm libpq.so.5
[postgres@repdb2 lib64]$ sudo ln -s /usr/pgsql-9.5/lib/libpq.so.5 libpq.so.5
5) Removal of wrong version of lib in 32-bit
[postgres@repdb2 lib64]$ rm libpq.so.5.8
6) Installed correct version of library and created the symbolic link with 64-bit
[postgres@repdb2 lib64]$ sudo ln -s /usr/pgsql-9.5/lib/libpq.so.5 libpq.so.5
7) Imported psycopg2 module successfully,
[postgres@repdb2 lib64]$ python -c “import psycopg2”
[postgres@repdb2 lib64]$
8) Restarted postgres,
[root@repdb2 bin]# su postgres
[postgres@repdb2 bin]$ ./pg_ctl stop -D /var/lib/pgsql/9.5/data
waiting for server to shut down…. done
server stopped
[postgres@repdb2 bin]$ ./pg_ctl start -D /var/lib/pgsql/9.5/data
/usr/pgsql-9.5/bin/postgres: /usr/pgsql-9.5/lib/libxml2.so.2: no version information available (required by /usr/pgsql-9.5/bin/postgres)
/usr/pgsql-9.5/bin/postgres: /usr/pgsql-9.5/lib/libxml2.so.2: no version information available (required by /usr/pgsql-9.5/bin/postgres)
server starting
[postgres@repdb2 bin]$ /usr/pgsql-9.5/bin/postgres: /usr/pgsql-9.5/lib/libxml2.so.2: no version information available (required by /usr/pgsql-9.5/bin/postgres)
/usr/pgsql-9.5/bin/postgres: /usr/pgsql-9.5/lib/libxml2.so.2: no version information available (required by /usr/pgsql-9.5/bin/postgres)
LOG: redirecting log output to logging collector process
HINT: Future log output will appear in directory “pg_log”.
9) DB console below,
[postgres@repdb2 bin]$
[postgres@repdb2 bin]$
[postgres@repdb2 bin]$ psql -p 5433
psql (9.5.5)
Type “help” for help.
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
— — — — — -+ — — — — — + — — — — — + — — — — — — -+ — — — — — — -+ — — — — — — — — — — — –
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)
postgres=# \q
[postgres@repdb2 bin]$
The postgres DB is now up and running!