- linkend="app-initdb"/>,
initdb which is
- installed with
PostgreSQL . The desired
- file system location of your database cluster is indicated by the
+ /var/lib/pgsql/data are popular.
+ The data directory must be initialized before being used, using the program
+ which is installed with
PostgreSQL .
+
+
+ If you are using a pre-packaged version
+ of
PostgreSQL , it may well have a specific
+ convention for where to place the data directory, and it may also
+ provide a script for creating the data directory. In that case you
+ should use that script in preference to
+ running initdb directly.
+ Consult the package-level documentation for details.
+
+
+ To initialize a database cluster manually,
+ run initdb and specify the desired
+ file system location of the database cluster with the
-D option, for example:
$ initdb -D /usr/local/pgsql/data
Before anyone can access the database, you must start the database
server. The database server program is called
- The postgres program must know where to
- find the data it is supposed to use. This is done with the
- -D option. Thus, the simplest way to start the
- server is:
+
+
+ If you are using a pre-packaged version
+ of
PostgreSQL , it almost certainly includes
+ provisions for running the server as a background task according to the
+ conventions of your operating system. Using the package's
+ infrastructure to start the server will be much less work than figuring
+ out how to do this yourself. Consult the package-level documentation
+ for details.
+
+
+ The bare-bones way to start the server manually is just to invoke
+ postgres directly, specifying the location of the
+ data directory with the -D option, for example:
$ postgres -D /usr/local/pgsql/data
starting the server during
Autostart scripts are operating-system-specific.
- There are a few distributed with
+ There are a few example scripts distributed with
contrib/start-scripts directory. Installing one will require
root privileges.
- There are several ways to shut down the database server. You control
- the type of shutdown by sending different signals to the supervisor
+ There are several ways to shut down the database server.
+ Under the hood, they all reduce to sending a signal to the supervisor
postgres process.
+
+
+ If you are using a pre-packaged version
+ of
PostgreSQL , and you used its provisions
+ for starting the server, then you should also use its provisions for
+ stopping the server. Consult the package-level documentation for
+ details.
+
+
+ When managing the server directly, you can control the type of shutdown
+ by sending different signals to the postgres
+ process:
is to dump and reload the database, though this can be slow. A
faster method is . Replication methods are
also available, as discussed below.
+ (If you are using a pre-packaged version
+ of
PostgreSQL , it may provide scripts to
+ assist with major version upgrades. Consult the package-level
+ documentation for details.)