debugsqlMinor
unable to run postgres with pg_ctl
Viewed 0 times
pg_ctlpostgreswithunablerun
Problem
I was reading a postgresql book (PostgreSQL from Novice to Pro) and it says you can start the postmaster daemon by invoking the postgres binary which was part of the installation:
Notice we had to pass both the data directory and configuration as parameters to the postgres binary.
The book then goes on to say that the pg_ctl executable, which also happens to be stored in the /usr/lib/postgresql/9.3/bin directory when installing via apt-get, is used to simplify the task. But I cannot get pg_ctl to run:
It says it cannot find the configuration file, but there is no way to specify the configuration file here:
How do I get pg_ctl to run?
/usr/lib/postgresql/9.3/bin/postgres "-D" "/var/lib/postgresql/9.3/main" "-c" "config_file=/etc/postgresql/9.3/main/postgresql.conf"Notice we had to pass both the data directory and configuration as parameters to the postgres binary.
The book then goes on to say that the pg_ctl executable, which also happens to be stored in the /usr/lib/postgresql/9.3/bin directory when installing via apt-get, is used to simplify the task. But I cannot get pg_ctl to run:
$ /usr/lib/postgresql/9.3/bin/pg_ctl -D "/var/lib/postgresql/9.3/main" start
server starting
postgres@estonia:/usr/lib/postgresql/9.3/bin$ postgres cannot access the server configuration file "/var/lib/postgresql/9.3/main/postgresql.conf": No such file or directoryIt says it cannot find the configuration file, but there is no way to specify the configuration file here:
$ /usr/lib/postgresql/9.3/bin/pg_ctl start "-D" "/var/lib/postgresql/9.3/main" "-c" "config_file=/etc/postgresql/9.3/main/postgresql.conf"
pg_ctl: too many command-line arguments (first is "start")
Try "pg_ctl --help" for more information.How do I get pg_ctl to run?
Solution
When used to start the instance,
From its manpage:
So your last command in the question should be amended as:
pg_ctl accepts options to the postgres executable, passed with -oFrom its manpage:
-o options
Specifies options to be passed directly to the postgres command.
The options should usually be surrounded by single or double quotes
to ensure that they are passed through as a group.So your last command in the question should be amended as:
/usr/lib/postgresql/9.3/bin/pg_ctl start \
"-D" "/var/lib/postgresql/9.3/main" \
"-o -c config_file=/etc/postgresql/9.3/main/postgresql.conf"Code Snippets
-o options
Specifies options to be passed directly to the postgres command.
The options should usually be surrounded by single or double quotes
to ensure that they are passed through as a group./usr/lib/postgresql/9.3/bin/pg_ctl start \
"-D" "/var/lib/postgresql/9.3/main" \
"-o -c config_file=/etc/postgresql/9.3/main/postgresql.conf"Context
StackExchange Database Administrators Q#101103, answer score: 6
Revisions (0)
No revisions yet.