Project

General

Profile

PostgreSQL work on stkensrv1n for 2015-08

For some past notes, refer to PostgreSQL upgrade on stken of chimera.

Prepare

# Identify running postmaster process
[enstore] ps aux | grep [p]ostmaster

# Dismount namespace
[root] ls /pnfs/fs
[root] umount -fv /pnfs/fs
[root] ls /pnfs/fs
[root] dcache stop nfsDomain
[root] dcache status

# Stop running postmaster process
[root] service postgresql-9.3 status
postgresql-9.3 (pid  3304) is running...
[root] service postgresql-9.3 stop
Stopping postgresql-9.3 service:                           [  OK  ]
[root] service postgresql-9.3 status
postgresql-9.3 is stopped
[enstore] ps aux | grep [p]ostmaster

Upgrade database software

# Inventory installed versions of PostgreSQL
[enstore] rpm -qa | egrep '^(pgdg|postgresql)' | sort

# Install PostgreSQL 9.3
# Note: As a fallback, RPMs for SLF6 are cached in gccensrv1:/home/enstore/pg_rpms/9.3
[root] rpm --nodeps -ivh http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-sl93-9.3-1.noarch.rpm
[root] yum -y install postgresql93 postgresql93-devel postgresql93-libs postgresql93-server postgresql93-contrib
[enstore] rpm -qa | egrep '^(pgdg|postgresql)' | sort

# Setup alternatives
[root]
VER="9.3" 
for PROG in "initdb" "pg_ctl" "pg_config" "postmaster" "psql"; do
  # Configure program:
  rm -f /var/lib/alternatives/pgsql-${PROG};
  /usr/sbin/alternatives --install /usr/bin/${PROG} pgsql-${PROG} /etc/alternatives/pgsql-${PROG} 920 --slave /etc/alternatives/pgsql-${PROG} pgsql-${PROG} /usr/pgsql-${VER}/bin/${PROG};
  # Configure man page:
  rm -f /var/lib/alternatives/pgsql-${PROG}man;
  /usr/sbin/alternatives --install /usr/share/man/man1/${PROG}.1 pgsql-${PROG}man /etc/alternatives/pgsql-${PROG}man 920 --slave /etc/alternatives/pgsql-${PROG}man pgsql-${PROG}man /usr/pgsql-${VER}/share/man/man1/${PROG}.1;
done

# Configure 9.3 service
[root] mv /etc/init.d/postgresql-9.3.rpmnew /etc/init.d/postgresql-9.3
[root] sed -i'-original' -e 's/postgres:postgres/enstore:enstore/g' -e 's/l postgres /l enstore /g' /etc/init.d/postgresql-9.3

Restart database

# Start service
[root] service postgresql-9.3 start
[root] service postgresql-9.3 status
[enstore] ps aux | grep [p]ostmaster
enstore   7653  0.6  0.3 9042348 467888 ?      S    12:41   0:00 /usr/pgsql-9.3/bin/postmaster -p 5432 -D /db/database
[enstore] ls -tr /srv1/postgres-log/* | tail -1 | xargs tail -vn +1

# Check PostgreSQL
[enstore] psql -qt -d postgres -c '\l'
 chimera   | enstore | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 monitor   | enstore | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 pgbench   | enstore | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 postgres  | enstore | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | enstore | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/enstore         +
           |         |          |             |             | enstore=CTc/enstore
 template1 | enstore | UTF8     | en_US.UTF-8 | en_US.UTF-8 | enstore=CTc/enstore+
           |         |          |             |             | =c/enstore
 test      | enstore | UTF8     | en_US.UTF-8 | en_US.UTF-8 |