summaryrefslogtreecommitdiff
path: root/scripts/files/elements/ubuntu-postgresql/install.d/10-postgresql
blob: cf5419321cc482787c821b11f1dac20fedd8e08e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/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.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.
apt-get -y install libpq-dev
pip install psycopg2