PostgreSQL upgrade on CentOS

[root@database ~]# yum install https://yum.postgresql.org/9.6/redhat/rhel-7.3-x86_64/pgdg-redhat96-9.6-3.noarch.rpm
[root@database ~]# yum install postgresql96-server postgresql96-contrib
[root@database ~]# /usr/pgsql-9.6/bin/postgresql96-setup initdb
[root@database ~]# su postgres # pg_upgrade cannot be run as root
[postgres@database /root]$ cd ~
[postgres@database ~]$ /usr/pgsql-9.6/bin/pg_upgrade --old-bindir=/usr/pgsql-9.5/bin/ --new-bindir=/usr/pgsql-9.6/bin/ --old-datadir=/var/lib/pgsql/9.5/data/ --new-datadir=/var/lib/pgsql/9.6/data/ --check # check only, won't change any data
[root@database ~]# service postgresql-9.5 stop
[postgres@database ~]$ /usr/pgsql-9.6/bin/pg_upgrade --old-bindir=/usr/pgsql-9.5/bin/ --new-bindir=/usr/pgsql-9.6/bin/ --old-datadir=/var/lib/pgsql/9.5/data/ --new-datadir=/var/lib/pgsql/9.6/data/
[root@database ~]# cp /var/lib/pgsql/9.5/data/postgresql.conf /var/lib/pgsql/9.6/data/postgresql.conf
[root@database ~]# cp /var/lib/pgsql/9.5/data/pg_hba.conf /var/lib/pgsql/9.6/data/pg_hba.conf
[root@database ~]# service postgresql-9.6 start
[root@database ~]# systemctl enable postgresql-9.6
[postgres@database ~]$ ./analyze_new_cluster.sh

--

--

Software engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store