summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Tomic <atomic@tesora.com>2016-02-25 15:17:07 -0500
committerAlex Tomic <atomic@tesora.com>2016-03-04 14:51:23 -0500
commitbfccda12ed9eec45ab311711a75632c696ee59d0 (patch)
tree29167d931276fc2b9b8645d4f1f727f7601df806
parentfd2442a7f227931f7100765d37c7da95b6fa5abe (diff)
downloadtrove-integration-bfccda12ed9eec45ab311711a75632c696ee59d0.tar.gz
Elements for PostgreSQL 9.4 and pg_rewind
Failover for postgresql requires pg_rewind, which needs to be compiled for 9.4 Change-Id: I226955dd8af1107b63685bf71e37859eb924d487 Partially-implements: bp/pgsql-replication
-rw-r--r--scripts/conf/postgresql.conf2
-rwxr-xr-xscripts/files/elements/fedora-postgresql/install.d/10-postgresql42
-rwxr-xr-xscripts/files/elements/ubuntu-postgresql/install.d/10-postgresql54
-rwxr-xr-xscripts/files/elements/ubuntu-postgresql/pre-install.d/10-postgresql-repo12
-rwxr-xr-xscripts/redstack4
5 files changed, 100 insertions, 14 deletions
diff --git a/scripts/conf/postgresql.conf b/scripts/conf/postgresql.conf
index a47f0eb..9972a2e 100644
--- a/scripts/conf/postgresql.conf
+++ b/scripts/conf/postgresql.conf
@@ -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,
diff --git a/scripts/files/elements/fedora-postgresql/install.d/10-postgresql b/scripts/files/elements/fedora-postgresql/install.d/10-postgresql
index fbafb44..a2ee463 100755
--- a/scripts/files/elements/fedora-postgresql/install.d/10-postgresql
+++ b/scripts/files/elements/fedora-postgresql/install.d/10-postgresql
@@ -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
diff --git a/scripts/files/elements/ubuntu-postgresql/install.d/10-postgresql b/scripts/files/elements/ubuntu-postgresql/install.d/10-postgresql
index cf54193..cd85325 100755
--- a/scripts/files/elements/ubuntu-postgresql/install.d/10-postgresql
+++ b/scripts/files/elements/ubuntu-postgresql/install.d/10-postgresql
@@ -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
diff --git a/scripts/files/elements/ubuntu-postgresql/pre-install.d/10-postgresql-repo b/scripts/files/elements/ubuntu-postgresql/pre-install.d/10-postgresql-repo
new file mode 100755
index 0000000..48a25d1
--- /dev/null
+++ b/scripts/files/elements/ubuntu-postgresql/pre-install.d/10-postgresql-repo
@@ -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
diff --git a/scripts/redstack b/scripts/redstack
index 7213cc4..0500e08 100755
--- a/scripts/redstack
+++ b/scripts/redstack
@@ -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"