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.
Configure the environment variables before using the commands.
See
Refer to "Configure the environment variables" under the procedure for creating an instance in " Using the initdb Command" in the Installation and Setup Guide for Server for information on the values to be set in the environment variables.
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.
Preferably, specify the -w option. This option ensures that instance startup completes successfully before the command is returned. If you omit the -w option, it may be impossible to tell if the instance started successfully.
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.