Modified existing Postgresql elements to support v9.6. This change will no longer support pg<9.6, so "wal_log_hints" is supported by default. Remove "checkpoint_segments" from config.template because the parameter is no longer supported from 9.5. By defult, "trovestack kick-start postgresql" will create a pg-9.6 image. The steps in "30-postgresql" has been tested in ubuntu trusty. Since yum.postgresql.org is no longer support fedora-22[1], trovestack use fedora-27 by default, and steps in "10-postgresql" has been tested too. Releated commits: https://review.openstack.org/#/c/409524/ [1] https://yum.postgresql.org/9.6/fedora/ Closes-bug: 1649084 Change-Id: I65d93635ad45838522abed014825d1f7e567c30c
49 lines
1.6 KiB
Bash
Executable File
49 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -e
|
|
set -o xtrace
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
cat > "/etc/sysctl.d/10-postgresql-performance.conf" << _EOF_
|
|
# See 'http://www.postgresql.org/docs/9.6/static/kernel-resources.html'
|
|
# for best practices.
|
|
# It is recommended to disable memory overcommit,
|
|
# but the Python interpreter may require it on smaller flavors.
|
|
# We therefore stick with the heuristic overcommit setting.
|
|
vm.overcommit_memory=0
|
|
|
|
_EOF_
|
|
|
|
cat > "/etc/rc.local" << _EOF_
|
|
#!/bin/bash
|
|
|
|
# See 'http://www.postgresql.org/docs/9.6/static/kernel-resources.html'
|
|
# Postgres 9.6 added support for THP. Using huge pages reduces overhead when
|
|
# using large contiguous chunks of memory, like PostgreSQL does.
|
|
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
|
|
echo never > /sys/kernel/mm/transparent_hugepage/defrag
|
|
fi
|
|
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
|
|
echo always > /sys/kernel/mm/transparent_hugepage/enabled
|
|
fi
|
|
|
|
exit \$?
|
|
|
|
_EOF_
|
|
|
|
apt-get --allow-unauthenticated -y install postgresql-9.6 postgresql-contrib-9.6 postgresql-server-dev-9.6
|
|
|
|
sed -i "s/external_pid_file =.*/external_pid_file = '\/var\/run\/postgresql\/postgresql.pid'/" /etc/postgresql/9.6/main/postgresql.conf
|
|
|
|
# The script will create a postgresql-9.6 image for user to use.
|
|
# From Postgresql >9.4, pg_rewind is in the main source tree. But, the default location is
|
|
# /usr/lib/postgresql/<version>/bin/pg_rewind. So, there need create a symlink from that
|
|
# location to /usr/bin
|
|
ln -s /usr/lib/postgresql/9.6/bin/pg_rewind /usr/bin/pg_rewind
|
|
|
|
|
|
# Install the native Python client.
|
|
apt-get --allow-unauthenticated -y install libpq-dev python-dev
|
|
pip2 install psycopg2
|