0

PostgreSQL version : 11.2 OS : RHEL 7.5

I am new to PostgreSQL. I would like to know which is the ideal way to start 'Database server' . In Oracle world, we call this starting the instance.

Should I be using Option A or Option B ?

Option A. As root user , run

# systemctl start postgresql-11

Option B. As postgres user, run

$ postgres -D /var/lib/pgsql/11/data

NB: For Option B, PostgreSQL 11's official doc mentions a different directory (/usr/local/pgsql/data) as shown below . Maybe the doc not updated.

$ postgres -D /usr/local/pgsql/data

https://www.postgresql.org/docs/11/server-start.html

  • PostgreSQL documentation will give you details about how to manage PostgreSQL... irrespective to your OS mostly or the way you install PostgreSQL (hence paths can change). If you use a Linux distribution using systemctl you should surely only use it to manage PostgreSQL, if you also installed it through your distribution install mechanisms. If you install PostgreSQL all by hand, then it is a different matter. The postgresql systemd unit file calls basically the posgresql command you quote or its equivalent. – Patrick Mevzek Feb 22 at 11:14
0

I would prefer option A.

Using systemctl ensures the service is properly (re)started when the computer is (re)started.

As far as the location of the data directory is concerned: the manual shows some defaults. The actual location of the data directory is essentially driven by the packager that built the RPM (or whatever package the OS uses) and the standards the distribution expects or uses. You could also put it under /databasedata/postgres/pg11/data if you want, or /very/important/data/postgres

0

I prefer Option B, because that is the recommended way to restart the PostgreSQL instance.

As you mentioned, in Oracle we have different ways of stopping and starting instance, even in PostgreSQL we have the same, just check pg_ctl --help

you will get different options to stop the database.

and regarding, /usr/local/pgsql/data, that was just a directory where database files installed, you can install any location you want when doing initdb.

I hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.