2016-10-09 07:13:29 -04:00
|
|
|
#!/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.4/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
|
|
|
|
vm.nr_hugepages=64
|
|
|
|
|
|
|
|
_EOF_
|
|
|
|
|
|
|
|
cat > "/etc/rc.local" << _EOF_
|
|
|
|
# See 'http://www.postgresql.org/docs/9.4/static/kernel-resources.html'
|
|
|
|
# Postgres 9.4 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_
|
|
|
|
|
2016-12-02 10:08:13 -05:00
|
|
|
apt-get --allow-unauthenticated -y install postgresql-9.4 postgresql-contrib-9.4 postgresql-server-dev-9.4
|
2016-10-09 07:13:29 -04:00
|
|
|
|
|
|
|
###########################################
|
|
|
|
# Hack alert:
|
|
|
|
# For Postgresql 9.4, pg_rewind is not in the main source tree and
|
|
|
|
# no packages exist in the repos, so it must be compiled manually
|
|
|
|
# and installed on the image until we can move to 9.5
|
|
|
|
# See README at
|
|
|
|
# https://github.com/vmware/pg_rewind/tree/REL9_4_STABLE
|
|
|
|
|
|
|
|
tmpdir=/tmp/build
|
|
|
|
mkdir -p $tmpdir
|
|
|
|
cd $tmpdir
|
|
|
|
git clone https://github.com/postgres/postgres.git --branch REL9_4_STABLE
|
|
|
|
cd postgres/contrib
|
|
|
|
git clone https://github.com/vmware/pg_rewind.git --branch REL9_4_STABLE
|
|
|
|
|
|
|
|
dev_pkgs="libreadline-dev libkrb5-dev libssl-dev libpam-dev libxml2-dev libxslt-dev libedit-dev libselinux1-dev bison flex"
|
|
|
|
|
2016-12-02 10:08:13 -05:00
|
|
|
apt-get --allow-unauthenticated install $dev_pkgs -y
|
2016-10-09 07:13:29 -04:00
|
|
|
|
|
|
|
# Unfortunately, on ubuntu, was not able to get pg_rewind to build
|
|
|
|
# outside of the pgsql source tree. Configure and compile postgres
|
|
|
|
# but only call make install against the contrib/pg_rewind directory
|
|
|
|
# so that support library is accessible to the server
|
|
|
|
cd $tmpdir/postgres
|
2016-12-02 10:08:13 -05:00
|
|
|
./configure
|
2016-10-09 07:13:29 -04:00
|
|
|
make
|
|
|
|
cd contrib/pg_rewind
|
|
|
|
make install
|
|
|
|
|
2016-12-02 10:08:13 -05:00
|
|
|
# Make the pg_rewind binary and the library used by the
|
2016-10-09 07:13:29 -04:00
|
|
|
# pg_rewind stored procedures accessible
|
|
|
|
ln -s /usr/local/pgsql/bin/pg_rewind /usr/bin/pg_rewind
|
|
|
|
ln -s /usr/local/pgsql/lib/pg_rewind_support.so /usr/lib/postgresql/9.4/lib/pg_rewind_support.so
|
|
|
|
|
|
|
|
cd
|
|
|
|
rm -rf $tmpdir
|
|
|
|
apt-get remove -y $dev_pkgs
|
|
|
|
|
|
|
|
# End hack
|
|
|
|
################################
|
|
|
|
|
|
|
|
# Install the native Python client.
|
2016-12-02 10:08:13 -05:00
|
|
|
apt-get --allow-unauthenticated -y install libpq-dev
|
2016-12-16 06:13:15 -05:00
|
|
|
pip2 install psycopg2
|