I am using PostgreSQL for CentOS. And i changed the data directory to store PostgreSQL data on a different disk.
nano /usr/lib/systemd/system/postgresql.service
#Environment=PGDATA=/var/lib/pgsql/data
Environment=PGDATA=/data/pgsql/data
However, after installing the package update, the contents of the configuration file were changed back to the default settings.
Do I need to check the configuration file every time I install a package update later? Or is there a way to preserve the config file?
There are two ways to deal with this:
the old way:
You create a file /etc/systemd/system/postgresql.service
that contains
.include /usr/lib/systemd/system/postgresql.service [Service] Environment=PGDATA=/data/pgsql/data
the new way:
You create a directory /etc/systemd/system/postgresql.service.d
that contains a file named (for example) pgdata.conf
with the contents
[Service] Environment=PGDATA=/data/pgsql/data
Then notify systemd
with
systemctl daemon-reload
This configuration change will override the corresponding value from /usr/lib/systemd/system/postgresql.service
, so the change will survive an upgrade.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.