Merge "Elements for PostgreSQL 9.4 and pg_rewind"
This commit is contained in:
commit
233a9b8f42
|
@ -3,4 +3,4 @@
|
|||
"instance_eph_flavor_name": "test.eph.medium",
|
||||
"instance_bigger_eph_flavor_name": "test.eph.medium.resize",
|
||||
"trove_volume_support": true,
|
||||
"trove_volume_size": "1",
|
||||
"trove_volume_size": 1,
|
||||
|
|
|
@ -28,17 +28,49 @@ exit \$?
|
|||
|
||||
_EOF_
|
||||
|
||||
dnf install -y http://yum.postgresql.org/9.3/fedora/fedora-22-x86_64/pgdg-fedora93-9.3-3.noarch.rpm
|
||||
dnf install -y postgresql93-server postgresql93-contrib
|
||||
dnf install -y http://yum.postgresql.org/9.4/fedora/fedora-22-x86_64/pgdg-fedora94-9.4-4.noarch.rpm
|
||||
|
||||
dnf install -y postgresql94-server postgresql94-contrib postgresql94-devel gcc
|
||||
|
||||
###########################################
|
||||
# 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
|
||||
|
||||
dev_pkgs="readline-devel zlib-devel krb5-devel openssl-devel pam-devel libxml2-devel libxslt-devel"
|
||||
|
||||
yum install -y $dev_pkgs
|
||||
|
||||
# We need pg_config to be accessible on the path
|
||||
mkdir -p /tmp/build
|
||||
cd /tmp/build
|
||||
git clone https://github.com/vmware/pg_rewind.git --branch REL9_4_STABLE
|
||||
git clone https://github.com/postgres/postgres.git --branch REL9_4_STABLE
|
||||
|
||||
ln -s /usr/pgsql-9.4/bin/pg_config /usr/bin/pg_config
|
||||
|
||||
cd pg_rewind
|
||||
make USE_PGXS=1 top_srcdir=/tmp/build/postgres install
|
||||
ln -s /usr/pgsql-9.4/bin/pg_rewind /usr/bin/pg_rewind
|
||||
|
||||
# Cleanup
|
||||
|
||||
cd
|
||||
rm -rf /tmp/build
|
||||
yum remove -y $dev_pkgs
|
||||
|
||||
|
||||
# Though /var/lib/pgsql is the preferred directory, need to move it as
|
||||
# this is where the volume will be mounted
|
||||
su - postgres -c "/usr/pgsql-9.3/bin/initdb /var/lib/pgsql/9.3/data"
|
||||
su - postgres -c "/usr/pgsql-9.4/bin/initdb /var/lib/pgsql/9.4/data"
|
||||
mv /var/lib/pgsql /var/lib/postgresql
|
||||
|
||||
mv /lib/systemd/system/postgresql-9.3.service /lib/systemd/system/postgresql.service
|
||||
mv /lib/systemd/system/postgresql-9.4.service /lib/systemd/system/postgresql.service
|
||||
|
||||
sed -i 's/PGDATA=\/var\/lib\/pgsql\/9.3\/data/PGDATA=\/var\/lib\/postgresql\/9.3\/data/' /lib/systemd/system/postgresql.service
|
||||
sed -i 's/PGDATA=\/var\/lib\/pgsql\/9.4\/data/PGDATA=\/var\/lib\/postgresql\/9.4\/data/' /lib/systemd/system/postgresql.service
|
||||
|
||||
# Create a volatile directory for runtime files.
|
||||
echo "d /var/run/postgresql/ 0755 postgres postgres" > /lib/tmpfiles.d/postgresql.conf
|
||||
|
|
|
@ -6,31 +6,73 @@ set -o xtrace
|
|||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
cat > "/etc/sysctl.d/10-postgresql-performance.conf" << _EOF_
|
||||
# See 'http://www.postgresql.org/docs/9.3/static/kernel-resources.html'
|
||||
# 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.3/static/kernel-resources.html'
|
||||
# Disable Linux kernel transparent huge pages. This feature is not supported by
|
||||
# by Postgres 9.3 and may negatively impact performance of the database.
|
||||
# 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 never > /sys/kernel/mm/transparent_hugepage/enabled
|
||||
echo always > /sys/kernel/mm/transparent_hugepage/enabled
|
||||
fi
|
||||
|
||||
exit \$?
|
||||
|
||||
_EOF_
|
||||
|
||||
apt-get -y install postgresql-9.3
|
||||
apt-get -y install postgresql-9.4 postgresql-contrib-9.4 postgresql-server-dev-9.4
|
||||
|
||||
###########################################
|
||||
# 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"
|
||||
|
||||
apt-get install $dev_pkgs -y
|
||||
|
||||
# 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
|
||||
./configure
|
||||
make
|
||||
cd contrib/pg_rewind
|
||||
make install
|
||||
|
||||
# Make the pg_rewind binary and the library used by the
|
||||
# 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.
|
||||
apt-get -y install libpq-dev
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
set -o xtrace
|
||||
|
||||
cat <<EOL > /etc/apt/sources.list.d/postgresql.list
|
||||
deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
|
||||
EOL
|
||||
|
||||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
|
||||
|
||||
apt-get update
|
|
@ -559,8 +559,8 @@ function cmd_set_datastore() {
|
|||
PACKAGES=${PACKAGES:-"couchbase-server"}
|
||||
VERSION="2.2.0"
|
||||
elif [ "$DATASTORE_TYPE" == "postgresql" ]; then
|
||||
PACKAGES=${PACKAGES:-"postgresql-9.3"}
|
||||
VERSION="9.3"
|
||||
PACKAGES=${PACKAGES:-"postgresql-9.4"}
|
||||
VERSION="9.4"
|
||||
elif [ "$DATASTORE_TYPE" == "couchdb" ]; then
|
||||
PACKAGES=${PACKAGES:-"couchdb"}
|
||||
VERSION="1.6.1"
|
||||
|
|
Loading…
Reference in New Issue