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

0

2 Answers 2

1

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

1

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 and acknowledge you have read our privacy policy.

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