Server commands enable you to start or stop an instance and check its operating status.
To use sever commands, configure the environment variables.
See
Refer to " Configure the environment variables" in the procedure to create instances in " Using the initdb Command" in the Installation and Setup Guide for Server for information on configuring the environment variables.
Use the pg_ctl command to start an instance.
Specify the following values in the pg_ctl command:
Specify "start" as the mode.
Specify the data storage destination in the -D option. If the -D option is omitted, the value of the PGDATA environment variable is used by default.
If an application, command, or process tries to connect to the database while the instance is starting up, the message "FATAL:the database system is starting up(11189)" is output. However, this message may also be output if the instance is started without the -W option specified.
This message is output by the pg_ctl command to check if the instance has started successfully. Therefore, ignore this message if there are no other applications, commands, or processes that connect to the database.
Example
> pg_ctl start -D /database/inst1
Note
If the -W option is specified, the command will return without waiting for the instance to start. Therefore, it may be unclear as to whether the instance startup was successful or failed.
Use the pg_ctl command to stop an instance.
Specify the following values in the pg_ctl command:
Specify "stop" as the mode.
Specify the data storage destination in the -D option. If the -D option is omitted, the value of the PGDATA environment variable is used by default.
Example
> pg_ctl stop -D /database/inst1
Checking the operating status of an instance
Use the pg_ctl command to check the operating status of an instance.
Specify the following values in the pg_ctl command:
Specify "status" as the mode.
Specify the data storage destination in the -D option. If the -D option is omitted, the value of the PGDATA environment variable is used by default.
Example
When the instance is active:
> pg_ctl status -D /database/inst1 pg_ctl: server is running (PID: 1234)
When the instance is inactive:
> pg_ctl status -D /database/inst1 pg_ctl: no server running.
See
Refer to "pg_ctl" under "Reference" in the PostgreSQL Documentation for information on pg_ctl command.