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.
It is recommended to specify the -w option, which causes the command to return after waiting for the instance to start. If the -w option is not specified, it may not be possible to determine if the starting of the instance completed successfully or if it failed.
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 with 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 -w -D /database/inst1
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.