diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml index cd624828b4..4322a1f42e 100644 --- a/doc/src/sgml/runtime.sgml +++ b/doc/src/sgml/runtime.sgml @@ -1,5 +1,5 @@ @@ -164,6 +164,20 @@ NOTICE: Initializing database with en_US collation order. must also specify the option. + + This shells syntax can get tedious quickly. Therefore the shell + script wrapper pg_ctl is provided that + encapsulates some of the tasks. E.g., + +pg_ctl start -l logfile + + will start the server in the background and put the output into the + named log file. The option has the same + meaning as when invoking postmaster directly. + pg_ctl also implements a symmetric + stop operation. + + Normally, you will want to start the database server when the computer boots up. This is not required; the @@ -178,67 +192,78 @@ NOTICE: Initializing database with en_US collation order. with them. Many systems have a file /etc/rc.local or /etc/rc.d/rc.local which is almost certainly - no bad place to put such a command. Whatever you do, postmaster + no bad place to put such a command. Whatever you do, the server must be run by the Postgres user account and not by root or any other user. Therefore you probably always want to form your command lines along the lines of su -c '...' postgres, for example: -nohup su -c 'postmaster -D /usr/local/pgsql/data > server.log 2>&1' postgres & +su -c 'pg_ctl -D /usr/local/pgsql/data -l serverlog' postgres - (using the program nohup to prevent the - server from dying when you log out). - Here are a few more operating system specific suggestions. + Here are a few more operating system specific suggestions. (Always + replace the proper installation directory and the user name you + chose.) - Edit the file rc.local on - NetBSD or file - rc2.d on Solaris to contain the - following single line: + For FreeBSD, take a look at the file + contrib/start-scripts/freebsd in the + PostgreSQL source distribution. + + + + + + On OpenBSD, add the following lines + to the file /etc/rc.local: -su postgres -c "/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data" +if [ -x /usr/local/pgsql/bin/pg_ctl -a -x /usr/local/pgsql/bin/postmaster ]; then + su - -c '/usr/local/pgsql/bin/pg_ctl start -l /var/postgresql/log -s' postgres + echo -n ' postgresql' +fi - On FreeBSD edit - /usr/local/etc/rc.d/pgsql.sh to contain the - following lines and make it chmod 755 and - chown root:bin. + On Linux systems either add -#!/bin/sh -[ -x /usr/local/pgsql/bin/postmaster ] && { - su -l pgsql -c 'exec /usr/local/pgsql/bin/postmaster - -D/usr/local/pgsql/data - -S -o -F > /usr/local/pgsql/errlog' & - echo -n ' pgsql' -} +/usr/local/pgsql/bin/pg_ctl start -l logfile -D /usr/local/pgsql/data - You may put the line breaks as shown above. The shell is smart - enough to keep parsing beyond end-of-line if there is an - expression unfinished. The exec saves one layer of shell under - the postmaster process so the parent is init. + to /etc/rc.d/rc.local or look into the file + contrib/start-scripts/linux in the + PostgreSQL source distribution to + integrate the start and shutdown into the run level system. - On RedHat Linux add a file - /etc/rc.d/init.d/postgres.init - which is based on the example in contrib/linux/. - Then make a softlink to this file from - /etc/rc.d/rc5.d/S98postgres.init. - - - - + On NetBSD, either use the + FreeBSD or + Linux start scripts, depending on + preference, as an example and place the file at + /usr/local/etc/rc.d/postgresql. + + + + + + On Solaris, edit the file + rc2.d to contain the following single line: + +su - postgres -c "/usr/local/pgsql/bin/pg_ctl start -l logfile -D /usr/local/pgsql/data" + + + + + + While the postmaster is running, it's @@ -248,13 +273,6 @@ su postgres -c "/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data" shutting down the postmaster. - - The shell script wrapper pg_ctl that - comes with Postgres can also be used to - control starting (and stopping!) of the database server in - intelligent fashion. - - Server Start-up Failures