summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.rpm-dist34
-rw-r--r--postgresql.service3
2 files changed, 30 insertions, 7 deletions
diff --git a/README.rpm-dist b/README.rpm-dist
index c7cb21f..6d2d920 100644
--- a/README.rpm-dist
+++ b/README.rpm-dist
@@ -172,17 +172,24 @@ MULTIPLE POSTMASTERS
-------------------------------------------------------------------------------
The postgresql-server RPM contains a systemd "unit" file, postgresql.service,
that is used to start the PostgreSQL postmaster. If you need to run multiple
-postmasters on one machine, you should clone this file and modify it as
-necessary.
+postmasters on one machine, you can create additional unit files derived
+from this one.
As an example, let us create a secondary postmaster called, creatively enough,
'secondary'. Here are the steps:
-1.) Copy /lib/systemd/system/postgresql.service to
- /etc/systemd/system/secondary.service.
+1.) Create a file named /etc/systemd/system/secondary.service.
(Note that user-created unit files must go into /etc not /lib!)
-2.) Edit /etc/systemd/system/secondary.service to change the PGDATA and
- PGPORT settings so they don't conflict with any other postmaster.
-3.) Create the target PGDATA directory.
+ Put these lines in it:
+ .include /lib/systemd/system/postgresql.service
+ [Service]
+ Environment=PGPORT=nnnn
+ Environment=PGDATA=/path/to/data/directory
+ Replace "nnnn" and "/path/to/data/directory" with appropriate
+ settings that don't conflict with any other postmaster.
+2.) As root, do "/bin/systemctl daemon-reload" to ensure systemd has
+ noticed your updates to the service file.
+3.) Create the target PGDATA directory, making sure that its parent
+ directories have appropriate ownership and permissions.
4.) Initdb the target PGDATA with 'postgresql-setup initdb secondary'.
5.) Edit postgresql.conf in the target PGDATA to change settings as needed.
6.) Start the new postmaster with 'systemctl start secondary.service'.
@@ -194,6 +201,19 @@ service name in the postgresql-setup command, for example 'postgresql-setup
upgrade secondary'. This will let postgresql-setup find the correct data
directory from the service file.
+If you are running SELinux in enforcing mode (which is highly recommended,
+particularly for network-exposed services like PostgreSQL) you will need to
+adjust SELinux policy to allow the postmaster to use non-default PGPORT or
+PGDATA settings. To allow use of a non-default port, say 5433, do this
+as root:
+ semanage port -a -t postgresql_port_t -p tcp 5433
+To allow use of a non-default data directory, say /special/pgdata, do:
+ semanage fcontext -a -t postgresql_db_t "/special/pgdata(/.*)?"
+If you already created the directory, follow that with:
+ restorecon -R /special/pgdata
+These settings are persistent across reboots. For more information
+see "man semanage".
+
REGRESSION TESTING
-------------------------------------------------------------------------------
If you install the postgresql-test RPM then you can run the PostgreSQL
diff --git a/postgresql.service b/postgresql.service
index 6545b6e..4a55a66 100644
--- a/postgresql.service
+++ b/postgresql.service
@@ -14,6 +14,9 @@
# Environment=PGPORT=5433
# This will override the setting appearing below.
+# Note: changing PGPORT or PGDATA will typically require adjusting SELinux
+# configuration as well; see /usr/share/doc/postgresql-*/README.rpm-dist.
+
# Note: do not use a PGDATA pathname containing spaces, or you will
# break postgresql-setup.