pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedMoving the data directory for systemd service startup
6+ messages / 3 participants
[nested] [flat]
* Moving the data directory for systemd service startup
@ 2018-07-23 17:19 Evan Rempel <erempel@uvic.ca>
0 siblings, 2 replies; 6+ messages in thread
From: Evan Rempel @ 2018-07-23 17:19 UTC (permalink / raw)
To: pgsql-admin@lists.postgresql.org
I am using the official RPMs for RHEL-7 and am having difficulty in using a different database directory than the
default of
/var/lib/pgsql/9.6/data/
or
/var/lib/pgsql/10/data/
It is easy to modify the service file
/usr/lib/systemd/system/postgresql-9.6.service
with the line
Environment=PGDATA=/var/lib/pgsql/9.6/data/
to point to the location I want, but an RPM update will replace this file and break database startup.
I was hoping that there would be a line
EnvironmentFile=-/etc/sysconfig/pgsql/postgresql-9.6
or
EnvironmentFile=-/etc/sysconfig/pgsql/postgresql-10
to allow for customization of the environment variables, similar to the init.d startup, but I don't see one.
Am I missing something, or is the configuration of the systemd unit file an oversight?
Any information would be helpful.
Evan.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Moving the data directory for systemd service startup
@ 2018-07-23 17:26 Johannes Truschnigg <johannes@truschnigg.info>
parent: Evan Rempel <erempel@uvic.ca>
1 sibling, 1 reply; 6+ messages in thread
From: Johannes Truschnigg @ 2018-07-23 17:26 UTC (permalink / raw)
To: Evan Rempel <erempel@uvic.ca>; +Cc: pgsql-admin@lists.postgresql.org
Hi Evan,
On Mon, Jul 23, 2018 at 10:19:31AM -0700, Evan Rempel wrote:
> [...]
> Am I missing something, or is the configuration of the systemd unit file an oversight?
That's not really a question related to PostgreSQL, but to systemd, and how to
"override" (parts of) your systems' unit files.
Since you appear to be on EL7, you best check out the docs your distro
provides on the matter:
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_...
(Spoiler alert: All systemd-using distros are pretty much the same in these
regards, which is one of the benefits of converging towards this service
manager in the GNU/Linux ecosystem.)
Hth.
--
with best regards:
- Johannes Truschnigg ( johannes@truschnigg.info )
www: https://johannes.truschnigg.info/
phone: +43 650 2 133337
xmpp: johannes@truschnigg.info
Please do not bother me with HTML-email or attachments. Thank you.
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Moving the data directory for systemd service startup
@ 2018-07-23 17:29 Evan Rempel <erempel@uvic.ca>
parent: Johannes Truschnigg <johannes@truschnigg.info>
0 siblings, 2 replies; 6+ messages in thread
From: Evan Rempel @ 2018-07-23 17:29 UTC (permalink / raw)
To: pgsql-admin@lists.postgresql.org
Except that the systemd file comes from the postgresql10-server RPM produced by the PostgreSQL community.
I was trying to figure out how the PostgreSQL systemd service file authors intended users to configure a different
data directory than the default.
On 07/23/2018 10:26 AM, Johannes Truschnigg wrote:
> Hi Evan,
>
> On Mon, Jul 23, 2018 at 10:19:31AM -0700, Evan Rempel wrote:
>> [...]
>> Am I missing something, or is the configuration of the systemd unit file an oversight?
> That's not really a question related to PostgreSQL, but to systemd, and how to
> "override" (parts of) your systems' unit files.
>
> Since you appear to be on EL7, you best check out the docs your distro
> provides on the matter:
>
> https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_...
>
> (Spoiler alert: All systemd-using distros are pretty much the same in these
> regards, which is one of the benefits of converging towards this service
> manager in the GNU/Linux ecosystem.)
>
> Hth.
>
--
Evan Rempel erempel@uvic.ca
Senior Systems Administrator 250.721.7691
Data Centre Services, University Systems, University of Victoria
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Moving the data directory for systemd service startup
@ 2018-07-23 17:36 Evan Rempel <erempel@uvic.ca>
parent: Evan Rempel <erempel@uvic.ca>
1 sibling, 0 replies; 6+ messages in thread
From: Evan Rempel @ 2018-07-23 17:36 UTC (permalink / raw)
To: pgsql-admin@lists.postgresql.org
Sorry for the quick reply (without reading it completely).
The document you refer to does address by question on how to augment/extend the configuration of the system unit file.
Thanks,
On 07/23/2018 10:29 AM, Evan Rempel wrote:
> Except that the systemd file comes from the postgresql10-server RPM produced by the PostgreSQL community.
>
> I was trying to figure out how the PostgreSQL systemd service file authors intended users to configure a different
> data directory than the default.
>
> On 07/23/2018 10:26 AM, Johannes Truschnigg wrote:
>> Hi Evan,
>>
>> On Mon, Jul 23, 2018 at 10:19:31AM -0700, Evan Rempel wrote:
>>> [...]
>>> Am I missing something, or is the configuration of the systemd unit file an oversight?
>> That's not really a question related to PostgreSQL, but to systemd, and how to
>> "override" (parts of) your systems' unit files.
>>
>> Since you appear to be on EL7, you best check out the docs your distro
>> provides on the matter:
>>
>> https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_...
>>
>> (Spoiler alert: All systemd-using distros are pretty much the same in these
>> regards, which is one of the benefits of converging towards this service
>> manager in the GNU/Linux ecosystem.)
>>
>> Hth.
>>
>
--
Evan
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Moving the data directory for systemd service startup
@ 2018-07-23 17:40 Johannes Truschnigg <johannes@truschnigg.info>
parent: Evan Rempel <erempel@uvic.ca>
1 sibling, 0 replies; 6+ messages in thread
From: Johannes Truschnigg @ 2018-07-23 17:40 UTC (permalink / raw)
To: Evan Rempel <erempel@uvic.ca>; +Cc: pgsql-admin@lists.postgresql.org
Hi Evan,
On Mon, Jul 23, 2018 at 10:29:52AM -0700, Evan Rempel wrote:
> Except that the systemd file comes from the postgresql10-server RPM produced by the PostgreSQL community.
The origin of your unit file doesn't matter to systemd on your EL7 host. You
can run
# systemctl edit <yourunitfilename>
and (recent releases of) systemd will drop you into your $EDITOR in an
appropriately created drop-in unit extension file, or you can run
# mkdir /etc/systemd/system/<yourunitfilename>.service.d/
# $EDITOR /etc/systemd/system/<yourunitfilename>.service.d/environment.conf
and put your "Environment=PGDATA=/var/lib/pgsql/9.6/data/" stanza (take care
to get the INI-style section right!) into the resulting editor buffer.
Once you save that and `systemctl daemon-reload` your unit configuration, you
can use
# systemctl cat <yourunitfilename>
to see what systemd makes of your changes, and then restart the service with
the changes applied.
The delta you introduced that way will survive package upgrades (but you'll
have to re-apply these changes to postgres service units with new/different
unit names, i. e. different major versions, in the same manner).
--
with best regards:
- Johannes Truschnigg ( johannes@truschnigg.info )
www: https://johannes.truschnigg.info/
phone: +43 650 2 133337
xmpp: johannes@truschnigg.info
Please do not bother me with HTML-email or attachments. Thank you.
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 6+ messages in thread
* RE: Moving the data directory for systemd service startup
@ 2018-07-23 18:02 Michael Ireland <mireland@esri.com>
parent: Evan Rempel <erempel@uvic.ca>
1 sibling, 0 replies; 6+ messages in thread
From: Michael Ireland @ 2018-07-23 18:02 UTC (permalink / raw)
To: Evan Rempel <erempel@uvic.ca>; pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Hi,
Here is how I setup PGDATA in a non-default location on RHEL 7 for PostgreSQL 9.6, installed with postgres.org RPMs, leaving the /usr/lib/systemd/system/postgresql-9.6.service file unchanged:
[root@pgs-p01 ~]# mkdir /data/postgres/pgdata
[root@pgs-p01 ~]# chown -R postgres:postgres /data/postgres
[postgres@pgs-p01 ~]$ pg_ctl -D /data/postgres/pgdata initdb
[root@pgs-p01 ~]# vi /etc/systemd/system/postgresql-9.6.service
[root@pgs-p01 ~]# cat /etc/systemd/system/postgresql-9.6.service
.include /lib/systemd/system/postgresql-9.6.service
[Service]
Environment=PGDATA=/data/postgres/pgdata
[root@pgs-p01 ~]# systemctl daemon-reload
[root@pgs-p01 ~]# systemctl enable postgresql-9.6
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-9.6.service to /etc/systemd/system/postgresql-9.6.service.
[root@pgs-p01 ~]# systemctl start postgresql-9.6
[root@pgs-p01 ~]# systemctl status postgresql-9.6
â postgresql-9.6.service - PostgreSQL 9.6 database server
Loaded: loaded (/etc/systemd/system/postgresql-9.6.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2018-04-04 13:29:26 PDT; 12s ago
Docs: https://urldefense.proofpoint.com/v2/url?u=https-3A__www.postgresql.org_docs_9.6_static_&d=DwIGa...
Process: 23865 ExecStartPre=/usr/pgsql-9.6/bin/postgresql96-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 23871 (postmaster)
CGroup: /system.slice/postgresql-9.6.service
ââ23871 /usr/pgsql-9.6/bin/postmaster -D /data/postgres/pgdata
ââ23873 postgres: logger process
ââ23875 postgres: checkpointer process
ââ23876 postgres: writer process
ââ23877 postgres: wal writer process
ââ23878 postgres: autovacuum launcher process
ââ23879 postgres: stats collector process
Apr 04 13:29:26 pgs-p01.xxx.com systemd[1]: Starting PostgreSQL 9.6 database server...
Apr 04 13:29:26 pgs-p01.xxx.com postmaster[23871]: < 2018-04-04 13:29:26.297 PDT > LOG: redirecting log output ...cess
Apr 04 13:29:26 pgs-p01.xxx.com postmaster[23871]: < 2018-04-04 13:29:26.297 PDT > HINT: Future log output will...og".
Apr 04 13:29:26 pgs-p01.xxx.com systemd[1]: Started PostgreSQL 9.6 database server.
[root@pgs-p01 ~]#
[postgres@pgs-p01 ~]$ grep PGDATA= /usr/lib/systemd/system/postgresql-9.6.service
Environment=PGDATA=/var/lib/pgsql/9.6/data/
[postgres@pgs-p01 ~]$
-----Original Message-----
From: Evan Rempel [mailto:erempel@uvic.ca]
Sent: Monday, July 23, 2018 10:20 AM
To: pgsql-admin@lists.postgresql.org
Subject: Moving the data directory for systemd service startup
I am using the official RPMs for RHEL-7 and am having difficulty in using a different database directory than the default of
/var/lib/pgsql/9.6/data/
or
/var/lib/pgsql/10/data/
It is easy to modify the service file
/usr/lib/systemd/system/postgresql-9.6.service
with the line
Environment=PGDATA=/var/lib/pgsql/9.6/data/
to point to the location I want, but an RPM update will replace this file and break database startup.
I was hoping that there would be a line
EnvironmentFile=-/etc/sysconfig/pgsql/postgresql-9.6
or
EnvironmentFile=-/etc/sysconfig/pgsql/postgresql-10
to allow for customization of the environment variables, similar to the init.d startup, but I don't see one.
Am I missing something, or is the configuration of the systemd unit file an oversight?
Any information would be helpful.
Evan.
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2018-07-23 18:02 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-07-23 17:19 Moving the data directory for systemd service startup Evan Rempel <erempel@uvic.ca>
2018-07-23 17:26 ` Johannes Truschnigg <johannes@truschnigg.info>
2018-07-23 17:29 ` Evan Rempel <erempel@uvic.ca>
2018-07-23 17:36 ` Evan Rempel <erempel@uvic.ca>
2018-07-23 17:40 ` Johannes Truschnigg <johannes@truschnigg.info>
2018-07-23 18:02 ` Michael Ireland <mireland@esri.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox