yum install -y wget systemtap-sdt-devel gcc make bison flex perl-devel perl-ExtUtils-Embed readline-devel zlib-devel python-devel openssl-devel pam-devel libxml2-devel libxslt-devel openldap-devel tcl-devel
mkdir /opt/resources
cd /opt/resources
wget https://ftp.postgresql.org/pub/source/v9.3.5/postgresql-9.3.5.tar.bz2
tar xvjf postgresql-9.3.5.tar.bz2
cd postgresql-9.3.5
Configure, build, and install:
./configure CFLAGS='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' \
LDFLAGS='-Wl,--as-needed' \
--enable-rpath \
--prefix=/usr/pgsql-9.3 \
--includedir=/usr/pgsql-9.3/include \
--mandir=/usr/pgsql-9.3/share/man \
--datadir=/usr/pgsql-9.3/share \
--with-perl \
--with-python \
--with-tcl \
--with-tclconfig=/usr/lib64 \
--with-openssl \
--with-pam \
--with-includes=/usr/include \
--with-libraries=/usr/lib64 \
--enable-nls \
--enable-dtrace \
--with-libxml \
--with-libxslt \
--with-ldap \
--with-selinux \
--with-system-tzdata=/usr/share/zoneinfo \
--sysconfdir=/etc/sysconfig/pgsql \
--docdir=/usr/pgsql-9.3/doc \
--htmldir=/usr/pgsql-9.3/doc/html
make -j 16 install
make -C contrib/ install
Fix the alternatives:
alternatives --install /usr/bin/psql pgsql-psql /usr/pgsql-9.3/bin/psql 930
alternatives --install /usr/bin/pg_dump pgsql-pg_dump /usr/pgsql-9.3/bin/pg_dump 930
alternatives --install /usr/bin/pg_restore pgsql-pg_restore /usr/pgsql-9.3/bin/pg_restore 930
alternatives --install /usr/bin/vacuumdb pgsql-vacuumdb /usr/pgsql-9.3/bin/vacuumdb 930
alternatives --install /usr/bin/pg_dumpall pgsql-pg_dumpall /usr/pgsql-9.3/bin/pg_dumpall 930
alternatives --install /usr/bin/pg_config pgsql-pg_config /usr/pgsql-9.3/bin/pg_config 930
save on /etc/systemd/system/postgresql-9.3.service
:
# It's not recommended to modify this file in-place, because it will be
# overwritten during package upgrades. If you want to customize, the
# best way is to create a file "/etc/systemd/system/postgresql-9.3.service",
# containing
# .include /lib/systemd/system/postgresql-9.3.service
# ...make your changes here...
# For more info about custom unit files, see
# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F
# Note: changing PGDATA will typically require adjusting SELinux
# configuration as well.
# Note: do not use a PGDATA pathname containing spaces, or you will
# break postgresql-setup.
[Unit]
Description=PostgreSQL 9.3 database server
Documentation=https://www.postgresql.org/docs/9.3/static/
After=syslog.target
After=network.target
[Service]
Type=forking
User=postgres
Group=postgres
# Note: avoid inserting whitespace in these Environment= lines, or you may
# break postgresql-setup.
# Location of database directory
Environment=PGDATA=/var/lib/pgsql/9.3/data/
# Where to send early-startup messages from the server (before the logging
# options of postgresql.conf take effect)
# This is normally controlled by the global default set by systemd
# StandardOutput=syslog
# Disable OOM kill on the postmaster
OOMScoreAdjust=-1000
ExecStart=/usr/pgsql-9.3/bin/pg_ctl start -D ${PGDATA} -s -w -t 300
ExecStop=/usr/pgsql-9.3/bin/pg_ctl stop -D ${PGDATA} -s -m fast
ExecReload=/usr/pgsql-9.3/bin/pg_ctl reload -D ${PGDATA} -s
# Do not set any timeout value, so that systemd will not kill postmaster
# during crash recovery.
TimeoutSec=0
Create a new user:
useradd postgres -c "PostgreSQL Server" --home-dir /var/lib/pgsql
Then initialize the cluster:
su - postgres
mkdir /var/lib/pgsql/9.3
/usr/pgsql-9.3/bin/initdb -D /var/lib/pgsql/9.3/data
To fix the python devel conflict:
https://forums.cpanel.net/threads/update-error-python-devel-conflicts-with-python.655331/