Question

I just installed PostgreSQL 13 on a new SUSE 15-SP1 server. With postgres user, I could run initdb -D /usr/lib/postgresql13/data, and then pg_ctl start-D /usr/lib/postgresql13/data. It works fine.

Then I activated PostgreSQL service:

systemctl enable postgresql
systemctl start postgresql

The service started, but it created a new database in /var/lib/pgsql/data!

Searching around, I found that I could configure the service start up options. I created a configuration file: systemctl edit postgresql.service allowed me to define the following setup in /etc/systemd/system/postgresql.service.d/override.conf:

[Service]
.include /usr/lib/systemd/system/postgresql.service
Environment=PGDATA=/usr/lib/postgresql13/data
END

This is supposed to alter the original service script:

/usr/lib/systemd/system/postgresql.service

[Unit]

Description=PostgreSQL database server
After=syslog.target
After=network.target

[Service]
Type=forking
User=postgres
ExecStart=/usr/share/postgresql/postgresql-script start
ExecStop=/usr/share/postgresql/postgresql-script stop
ExecReload=/usr/share/postgresql/postgresql-script reload

# The server might be slow to stop, and that's fine. Don't kill it
SendSIGKILL=no

[Install]
WantedBy=multi-user.target

When restarting the service:

sudo systemctl daemon-reload
sudo systemctl restart postgresql.service

The status shows that it is still running on the wrong database:

ps -ax | grep [p]ostgres
  6951 ?        Ss     0:00 /usr/lib/postgresql13/bin/postgres -D /var/lib/pgsql/data

My configuration had no effect. What did I miss?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top