pg_createcluster - create a new PostgreSQL cluster
pg_createcluster [options] version name
pg_createcluster creates a new PostgreSQL server cluster (i. e. a collection of databases served by a postmaster(1) instance) and integrates it into the multi-version/multi-cluster architecture of the postgresql-common package.
Every cluster is uniquely identified by its version and name. The name can be
arbitrary. The default cluster that is created on installation of a server
main. However, you might wish to create other clusters for
testing, with other superusers, a cluster for each user on a shared server,
pg_createcluster will abort with an error if you try to create a
cluster with a name that already exists for that version.
Given a major PostgreSQL version (like "7.4" or "8.0") and a cluster
name, it creates the necessary configuration files in
/; in particular these are
pg_hba.conf, a postgresql-common
specific configuration file
start.conf (see STARTUP CONTROL below), and a
log which points to the log file (by default,
To enable easy integration of pg_autovacuum for Servers prior to 8.1, this
program also creates a symbolic link
autovacuum_log which points to the
pg_autuvacuum log file (by default,
8.1 and later has an integrated autovacuuming which does not need this.
postgresql.conf is automatically adapted to use the next available port, i.
e. the first port (starting from 5432) which is not yet used by an already
If the data directory does not yet exist, PostgreSQL's initdb(1) command is
used to generate a new cluster structure. If the data directory already exists,
it is integrated into the postgresql-common structure by moving the
configuration file and setting the data_directory option. Please note that this
only works for data directories which were created directly with initdb, i.
e. all the configuration files (
postgresql.conf etc.) must be present in the
If a custom socket directory is given and it does not exist, it is created.
If the log file does not exist, it is created. In any case the permissions are
adjusted to allow write access to the cluster owner. Please note that
postgresql.conf can be customized to specify
log_filename; if at least one of these options is present, then the symbolic
log in the cluster configuration directory is ignored.
If the default snakeoil SSL certificate exists
/etc/ssl/private/ssl-cert-snakeoil.key), this program creates symlinks to
these files in the data directory (
server.key) and enables
SSL for that cluster (option ssl in
postgresql.conf). Therefore all
clusters will use the same SSL certificate by default. Of course you can
replace these symlinks with a cluster specific certificate.
/var/run/postgresql/for clusters owned by the user postgres, and
/tmpfor clusters owned by other users. Please be aware that
/tmpis an unsafe directory since everybody can create a socket there and impersonate the database server. If the given directory does not exist, it is created with appropriate permissions.
Select the encoding of the template database. This will also be the default encoding of any database you create later, unless you override it there. The default is derived from the locale, or SQL_ASCII if that does not work. The character sets supported by the PostgreSQL server are described in the documentation.
Note: It is not recommended to set this option directly! Set the locale instead.
starton it). By default, the cluster is not started.
start.confconfiguration file. See STARTUP CONTROL below. By default, auto is used, which means that the cluster is handled by
/etc/init.d/postgresql-version, i. e. starts and stops automatically on system boot.
start.conf file in the cluster configuration directory controls the
start/stop behavior of that cluster's postmaster process. The file can contain
comment lines (started with '#'), empty lines, and must have exactly one
line with one of the following keywords:
pg_ctlcluster(8), pg_lsclusters(1), pg_wrapper(1)
Martin Pitt <firstname.lastname@example.org>