summaryrefslogtreecommitdiff
path: root/openstack
diff options
context:
space:
mode:
authorFrancisco Redondo Marchena <francisco.marchena@codethink.co.uk>2014-12-17 18:02:47 +0000
committerFrancisco Redondo Marchena <francisco.marchena@codethink.co.uk>2015-01-22 12:46:28 +0000
commitb18f85176ffefafbe91b1ac0c0f7141bb7a59dea (patch)
tree9cd9604cafd3e86070cca7a4468b649be6de80cd /openstack
parent94e657440e11a33adbff3eeec367f28fa7612a7f (diff)
downloaddefinitions-b18f85176ffefafbe91b1ac0c0f7141bb7a59dea.tar.gz
Add databases stratum to system and add configuration and services for postgres
Diffstat (limited to 'openstack')
-rw-r--r--openstack/etc/systemd/system/postgres-server.service26
-rw-r--r--openstack/etc/systemd/system/postgres-setup.service11
-rw-r--r--openstack/manifest3
-rw-r--r--openstack/usr/share/openstack/postgres-setup35
4 files changed, 75 insertions, 0 deletions
diff --git a/openstack/etc/systemd/system/postgres-server.service b/openstack/etc/systemd/system/postgres-server.service
new file mode 100644
index 00000000..6ee25e98
--- /dev/null
+++ b/openstack/etc/systemd/system/postgres-server.service
@@ -0,0 +1,26 @@
+[Unit]
+Description=PostgreSQL database server
+Requires=postgres-setup.service
+After=postgres-setup.service
+
+[Service]
+Type=forking
+TimeoutSec=120
+User=postgres
+Group=postgres
+
+Environment=PGROOT=/var/lib/pgsql
+
+SyslogIdentifier=postgres
+PIDFile=/var/lib/pgsql/data/postmaster.pid
+
+ExecStart= /usr/bin/pg_ctl -s -D ${PGROOT}/data start -w -t 120
+ExecReload=/usr/bin/pg_ctl -s -D ${PGROOT}/data reload
+ExecStop= /usr/bin/pg_ctl -s -D ${PGROOT}/data stop -m fast
+
+# Due to PostgreSQL's use of shared memory, OOM killer is often overzealous in
+# killing Postgres, so adjust it downward
+OOMScoreAdjust=-200
+
+[Install]
+WantedBy=multi-user.target
diff --git a/openstack/etc/systemd/system/postgres-setup.service b/openstack/etc/systemd/system/postgres-setup.service
new file mode 100644
index 00000000..281d0d77
--- /dev/null
+++ b/openstack/etc/systemd/system/postgres-setup.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Run postgres-setup (once)
+After=network.target
+
+[Service]
+Type=oneshot
+ExecStart=/usr/share/openstack/postgres-setup
+Restart=no
+
+[Install]
+WantedBy=multi-user.target
diff --git a/openstack/manifest b/openstack/manifest
index 404acc23..a2d79412 100644
--- a/openstack/manifest
+++ b/openstack/manifest
@@ -169,3 +169,6 @@
0100755 0 0 /usr/share/openstack/openstack-neutron-network-configuration-for-one-node
0100644 0 0 /etc/systemd/system/openstack-neutron-network-configuration-one-node.service
0100644 0 0 /etc/systemd/system/openvswitch-initialize-db.service
+0100755 0 0 /usr/share/openstack/postgres-setup
+0100644 0 0 /etc/systemd/system/postgres-setup.service
+0100644 0 0 /etc/systemd/system/postgres-server.service
diff --git a/openstack/usr/share/openstack/postgres-setup b/openstack/usr/share/openstack/postgres-setup
new file mode 100644
index 00000000..36d89d97
--- /dev/null
+++ b/openstack/usr/share/openstack/postgres-setup
@@ -0,0 +1,35 @@
+#!/bin/sh
+#
+# Copyright (C) 2014 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+set -xe
+
+# Create postgres directories
+install -dm700 /var/lib/pgsql/data
+install -dm755 /var/run/postgresql
+
+# Create required system users and groups
+getent group postgress >/dev/null || groupadd -r -g 41 postgres
+getent passwd neutron >/dev/null || \
+ useradd --uid 41 -r -g postgres -d /var/lib/pgsql -s /sbin/nologin \
+ -c "PostgreSQL Server" postgres
+
+chown -R postgres:postgres /var/lib/pgsql /var/run/postgresql
+
+test -d /var/lib/pgsql/data/base || sudo -u postgres pg_ctl -D /var/lib/pgsql/data initdb
+
+
+exit 0