📄 pg_ctl.1
字号:
.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $.TH "PG_CTL" "1" "2008-01-03" "Application" "PostgreSQL Server Applications".SH NAMEpg_ctl \- start, stop, or restart a PostgreSQL server.SH SYNOPSIS.sp\fBpg_ctl\fR \fBstart\fR [ \fB-w\fR ] [ \fB-s\fR ] [ \fB-D \fIdatadir\fB\fR ] [ \fB-l \fIfilename\fB\fR ] [ \fB-o \fIoptions\fB\fR ] [ \fB-p \fIpath\fB\fR ] \fBpg_ctl\fR \fBstop\fR [ \fB-W\fR ] [ \fB-s\fR ] [ \fB-D \fIdatadir\fB\fR ] [ \fB-m [ s[mart] ] [ f[ast] ] [ i[mmediate] ] \fR ] \fBpg_ctl\fR \fBrestart\fR [ \fB-w\fR ] [ \fB-s\fR ] [ \fB-D \fIdatadir\fB\fR ] [ \fB-m [ s[mart] ] [ f[ast] ] [ i[mmediate] ] \fR ] [ \fB-o \fIoptions\fB\fR ] \fBpg_ctl\fR \fBreload\fR [ \fB-s\fR ] [ \fB-D \fIdatadir\fB\fR ] \fBpg_ctl\fR \fBstatus\fR [ \fB-D \fIdatadir\fB\fR ] \fBpg_ctl\fR \fBkill\fR [ \fB\fIsignal_name\fB\fR ] [ \fB\fIprocess_id\fB\fR ] \fBpg_ctl\fR \fBregister\fR [ \fB-N \fIservicename\fB\fR ] [ \fB-U \fIusername\fB\fR ] [ \fB-P \fIpassword\fB\fR ] [ \fB-D \fIdatadir\fB\fR ] [ \fB-w\fR ] [ \fB-o \fIoptions\fB\fR ] \fBpg_ctl\fR \fBunregister\fR [ \fB-N \fIservicename\fB\fR ] .SH "DESCRIPTION".PP\fBpg_ctl\fR is a utility for starting,stopping, or restarting the PostgreSQLbackend server (\fBpostgres\fR(1)), or displaying thestatus of a running server. Although the server can be startedmanually, \fBpg_ctl\fR encapsulates tasks suchas redirecting log output and properly detaching from the terminaland process group. It also provides convenient options forcontrolled shutdown..PPIn \fBstart\fR mode, a new server is launched. Theserver is started in the background, and standard input is attached to\fI/dev/null\fR. The standard output and standarderror are either appended to a log file (if the \fB-l\fRoption is used), or redirected to \fBpg_ctl\fR's standard output (not standard error). If no log file is chosen, the standard output of \fBpg_ctl\fR should be redirected to a file or piped to another process such as a log rotating programlike \fBrotatelogs\fR; otherwise \fBpostgres\fR will write its output to the controlling terminal (from the background) and will not leave the shell's process group..PPIn \fBstop\fR mode, the server that is running inthe specified data directory is shut down. Three differentshutdown methods can be selected with the \fB-m\fRoption: ``Smart'' mode waits for all the clients todisconnect. This is the default. ``Fast'' mode doesnot wait for clients to disconnect. All active transactions arerolled back and clients are forcibly disconnected, then theserver is shut down. ``Immediate'' mode will abortall server processes without a clean shutdown. This will lead to a recovery run on restart..PP\fBrestart\fR mode effectively executes a stop followedby a start. This allows changing the \fBpostgres\fRcommand-line options..PP\fBreload\fR mode simply sends the\fBpostgres\fR process a \fBSIGHUP\fRsignal, causing it to reread its configuration files(\fIpostgresql.conf\fR,\fIpg_hba.conf\fR, etc.). This allows changing ofconfiguration-file options that do not require a complete restartto take effect..PP\fBstatus\fR mode checks whether a server is running inthe specified data directory. If it is, the PIDand the command line options that were used to invoke it aredisplayed..PP\fBkill\fR mode allows you to send a signal to a specifiedprocess. This is particularly valuable for Microsoft Windowswhich does not have a \fBkill\fR command. Use --help to see a list of supported signal names..PP\fBregister\fR mode allows you to register a system serviceon Microsoft Windows..PP\fBunregister\fR mode allows you to unregister a system serviceon Microsoft Windows, previously registered with the\fBregister\fR command..SH "OPTIONS".TP\fB-D \fIdatadir\fB\fRSpecifies the file system location of the database files. Ifthis is omitted, the environment variable\fBPGDATA\fR is used..TP\fB-l \fIfilename\fB\fRAppend the server log output to\fIfilename\fR. If the file does notexist, it is created. The \fBumask\fR is set to 077, so access tothe log file from other users is disallowed by default..TP\fB-m \fImode\fB\fRSpecifies the shutdown mode. \fImode\fRmay be smart, fast, orimmediate, or the first letter of one ofthese three..TP\fB-o \fIoptions\fB\fRSpecifies options to be passed directly to the\fBpostgres\fR command.The options are usually surrounded by single or doublequotes to ensure that they are passed through as a group..TP\fB-p \fIpath\fB\fRSpecifies the location of the \fIpostgres\fRexecutable. By default the \fIpostgres\fR executable is taken from the samedirectory as \fBpg_ctl\fR, or failing that, the hard-wiredinstallation directory. It is not necessary to use thisoption unless you are doing something unusual and get errorsthat the \fIpostgres\fR executable was not found..TP\fB-s\fROnly print errors, no informational messages..TP\fB-w\fRWait for the start or shutdown to complete. Times out after60 seconds. This is the default for shutdowns. A successful shutdown is indicated by removal of the PID file. For starting up, a successful \fBpsql -l\fR indicates success. \fBpg_ctl\fR will attempt to use the proper port for \fBpsql\fR. If the environment variable \fBPGPORT\fR exists, that is used. Otherwise, it will see if a port has been set in the \fIpostgresql.conf\fR file. If neither of those is used, it will use the default port that PostgreSQL was compiled with (5432 by default). When waiting, \fBpg_ctl\fR willreturn an accurate exit code based on the success of the startup or shutdown..TP\fB-W\fRDo not wait for start or shutdown to complete. This is thedefault for starts and restarts..SS "OPTIONS FOR WINDOWS".TP\fB-N \fIservicename\fB\fRName of the system service to register. The name will be usedas both the service name and the display name..TP\fB-P \fIpassword\fB\fRPassword for the user to start the service..TP\fB-U \fIusername\fB\fRUser name for the user to start the service. For domain users, use theformat DOMAIN\\username..SH "ENVIRONMENT".TP\fBPGDATA\fRDefault data directory location..TP\fBPGPORT\fRDefault port for \fBpsql\fR(1) (used by the -w option)..PPFor additional server variables, see \fBpostgres\fR(1).This utility, like most other PostgreSQL utilities,also uses the environment variables supported by \fBlibpq\fR(see in the documentation)..PP.SH "FILES".TP\fB\fIpostmaster.pid\fB\fRThe existence of this file in the data directory is used to help\fBpg_ctl\fR determine if the server iscurrently running or not..TP\fB\fIpostmaster.opts.default\fB\fRIf this file exists in the data directory,\fBpg_ctl\fR (in \fBstart\fRmode) will pass the contents of the file as options to the\fBpostgres\fR command, unless overridden by the\fB-o\fR option..TP\fB\fIpostmaster.opts\fB\fRIf this file exists in the data directory,\fBpg_ctl\fR (in \fBrestart\fR mode) will pass the contents of the file as options to\fBpostgres\fR, unless overridden by the \fB-o\fR option. The contents of this file are also displayed in \fBstatus\fR mode..TP\fB\fIpostgresql.conf\fB\fRThis file, located in the data directory, is parsed to find theproper port to use with \fBpsql\fR when the\fB-w\fR is given in \fBstart\fR mode..SH "NOTES".PPWaiting for complete start is not a well-defined operation and mayfail if access control is set up so that a local client cannotconnect without manual interaction (e.g., password authentication)..SH "EXAMPLES".SS "STARTING THE SERVER".PPTo start up a server:.sp.nf$ \fBpg_ctl start\fR.sp.fi.PPAn example of starting the server, blocking until the server hascome up is:.sp.nf$ \fBpg_ctl -w start\fR.sp.fi.PPFor a server using port 5433, andrunning without \fBfsync\fR, use:.sp.nf$ \fBpg_ctl -o "-F -p 5433" start\fR.sp.fi.SS "STOPPING THE SERVER".PP.sp.nf$ \fBpg_ctl stop\fR.sp.fistops the server. Using the \fB-m\fR switch allows oneto control \fBhow\fR the backend shuts down..SS "RESTARTING THE SERVER".PPRestarting the server is almost equivalent to stopping theserver and starting it againexcept that \fBpg_ctl\fR saves and reuses the command line options thatwere passed to the previously running instance. To restartthe server in the simplest form, use:.sp.nf$ \fBpg_ctl restart\fR.sp.fi.PPTo restart server,waiting for it to shut down and to come up:.sp.nf$ \fBpg_ctl -w restart\fR.sp.fi.PPTo restart using port 5433 and disabling \fBfsync\fR after restarting:.sp.nf$ \fBpg_ctl -o "-F -p 5433" restart\fR.sp.fi.SS "SHOWING THE SERVER STATUS".PPHere is a sample status output from\fBpg_ctl\fR:.sp.nf$ \fBpg_ctl status\fRpg_ctl: server is running (pid: 13718)Command line was:/usr/local/pgsql/bin/postgres '-D' '/usr/local/pgsql/data' '-p' '5433' '-B' '128'.sp.fiThis is the command line that would be invoked in restart mode..SH "SEE ALSO".PP\fBpostgres\fR(1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -