Skip to content

Instantly share code, notes, and snippets.

@jedi-jiang
Last active April 19, 2019 05:10
Show Gist options
  • Save jedi-jiang/f403aeb25f2745e2b6e317315d4ea63e to your computer and use it in GitHub Desktop.
Save jedi-jiang/f403aeb25f2745e2b6e317315d4ea63e to your computer and use it in GitHub Desktop.

Environment

  • CentOS OS 7.3 64 Bit
  • Docker 1.12.5

Steps

  1. Add following into the /etc/yum.repos.d/CentOS-Base.repo

exclude=postgresql*

  1. Add two new yum repo file in /etc/yum.repos.d

    pgdg-94-centos.repo with following content

    [pgdg94]
    name=PostgreSQL 9.4 $releasever - $basearch
    baseurl=https://download.postgresql.org/pub/repos/yum/9.4/redhat/rhel-$releasever-$basearch
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-94
    
    [pgdg94-source]
    name=PostgreSQL 9.4 $releasever - $basearch - Source
    failovermethod=priority
    baseurl=https://download.postgresql.org/pub/repos/yum/srpms/9.4/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-94

    pgdg-96-centos.repo with following content

    [pgdg96]
    name=PostgreSQL 9.6 $releasever - $basearch
    baseurl=https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-$releasever-$basearch
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-96
    
    [pgdg96-source]
    name=PostgreSQL 9.6 $releasever - $basearch - Source
    failovermethod=priority
    baseurl=https://download.postgresql.org/pub/repos/yum/srpms/9.6/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-96
    
    [pgdg96-updates-testing]
    name=PostgreSQL 9.6 $releasever - $basearch
    baseurl=https://download.postgresql.org/pub/repos/yum/testing/9.6/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-96
    
    [pgdg96-source-updates-testing]
    name=PostgreSQL 9.6 $releasever - $basearch - Source
    failovermethod=priority
    baseurl=https://download.postgresql.org/pub/repos/yum/srpms/testing/9.6/redhat/rhel-$releasever-$basearch
    enabled=0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-96
  2. Install the postgresql 9.4 and postgresql 9.6

    yum install postgresql94-server
    yum install postgresql96-server
  3. Backup the mounted openproject data directory e.g. /var/lib/openproject

  4. Init postgresql 9.6 db

    PGSETUP_INITDB_OPTIONS="--locale=C --encoding=UTF8" /usr/pgsql-9.6/bin/postgresql96-setup initdb
  5. Copy the pgdata of the openproject to the data directory of the postgresql 9.4

    cp -R /var/lib/openproject/pgdata/* /var/lib/pgsql/9.4/data
    chown -R postgres: /var/lib/pgsql/9.4/data/*
  6. Upgrade the pgdata from 9.4 to 9.6

    su - postgres
    /usr/pgsql-9.6/bin/pg_upgrade --old-bindir=/usr/pgsql-9.4/bin/ --new-bindir=/usr/pgsql-9.6/bin/ --old-datadir=/var/lib/pgsql/9.4/data/ --new-datadir=/var/lib/pgsql/9.6/data/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment