Apply recommended tweaks on Postgres images

Apply few recommended optimalizations on Postgres 9.3/9.4
redstack images.

Implements: blueprint postgres-configuration-groups
Change-Id: Ib7dad31dafdf97adb3200493b334ff93be93fc7b
This commit is contained in:
Petr Malik
2015-07-22 15:37:42 -04:00
parent ea31039afd
commit dc11ba9ff6
2 changed files with 51 additions and 0 deletions

View File

@@ -3,6 +3,31 @@
set -e
set -o xtrace
cat > "/etc/sysctl.d/10-postgresql-performance.conf" << _EOF_
# See 'http://www.postgresql.org/docs/9.3/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_
# 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.
if test -f /sys/kernel/mm/redhat_transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag
fi
if test -f /sys/kernel/mm/redhat_transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
fi
exit \$?
_EOF_
dnf install -y http://yum.postgresql.org/9.3/fedora/fedora-21-x86_64/pgdg-fedora93-9.3-2.noarch.rpm
dnf install -y postgresql93-server postgresql93-contrib

View File

@@ -4,6 +4,32 @@ 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.3/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_
# 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.
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
fi
exit \$?
_EOF_
apt-get -y install postgresql-9.3
# Install the native Python client.