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.
Example
> pg_ctl start -D /database/inst1
The message FATAL:the database system is starting up(11189)" may be output in the following cases. This is output by the pg_ctl command to see if the instance's processes have finished starting. Therefore, if there are no other applications, commands, or processes connecting to the database, ignore this message.
If an application, command, or process connects to the database while the instance is starting up
If the instance is started without specifying the -W option
If the -W option is specified, the command will return without waiting for the instance to finish starting. Therefore, you need to check the server log to see if the instance has started successfully.
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.