'br}
'br}
{\
pg_createcluster - create a new PostgreSQL cluster
pg_createcluster [options] version name [-- initdb options]
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 package is f(CW*(C`main*(C'. However, you might wish to create other clusters for testing, with other superusers, a cluster for each user on a shared server, etc. f(CW*(C`pg_createcluster*(C' 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 *(L"8.2*(R" or *(L"8.3*(R") and a cluster name, it creates the necessary configuration files in f(CW*(C`/etc/postgresql/*(C'versionf(CW*(C`/*(C'namef(CW*(C`/*(C'; in particular these are f(CW*(C`postgresql.conf*(C', f(CW*(C`pg_ident.conf*(C', f(CW*(C`pg_hba.conf*(C', a postgresql-common specific configuration file f(CW*(C`start.conf*(C' (see s-1STARTUP CONTROLs0 below), f(CW*(C`pg_ctl.conf*(C', and a symbolic link f(CW*(C`log*(C' which points to the log file (by default, f(CW*(C`/var/log/postgresql/postgresql-*(C'versionf(CW*(C`-*(C'namef(CW*(C`.log*(C').
f(CW*(C`postgresql.conf*(C' 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 existing cluster.
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 (f(CW*(C`postgresql.conf*(C' etc.) must be present in the data directory.
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 f(CW*(C`postgresql.conf*(C' can be customized to specify f(CW*(C`log_directory*(C' and/or f(CW*(C`log_filename*(C'; if at least one of these options is present, then the symbolic link f(CW*(C`log*(C' in the cluster configuration directory is ignored.
If the default snakeoil s-1SSLs0 certificate exists (f(CW*(C`/etc/ssl/certs/ssl-cert-snakeoil.pem*(C' and f(CW*(C`/etc/ssl/private/ssl-cert-snakeoil.key*(C'), and the f(CW*(C`postgres*(C' user is in the f(CW*(C`ssl-cert*(C' Unix group, pg_createcluster configures the cluster to use this certificate, and enables s-1SSL.s0 Therefore all clusters will use the same s-1SSLs0 certificate by default. For versions up to 9.1, symlinks in the data directory will be created (f(CW*(C`server.crt*(C' and f(CW*(C`server.key*(C'); for 9.2 and later, the appropriate f(CW*(C`postgresql.conf*(C' options will be set (f(CW*(C`ssl_cert_file*(C' and f(CW*(C`ssl_key_file*(C'). Of course you can replace this with a cluster specific certificate. Similarly for f(CW*(C`/etc/postgresql-common/root.crt*(C' and f(CW*(C`/etc/postgresql-common/root.crl*(C', these files will be configured as client certificate s-1CAs0 and revocation list, when present. (f(CW*(C`root.crt*(C' is initially a placeholder that will only be used if real certificates are added to the file.)
\fB-u\fR \fIuser\fR, \fB--user=\fR\fIuser\fR 4
Set the user who owns the cluster and becomes the database superuser to the given name or uid. By default, this is the user postgres. A cluster must not be owned by root.
\fB-g\fR \fIgroup\fR, \fB--group=\fR\fIgroup\fR 4
Change the group of the cluster related data files. By default this will be the primary group of the database owner.
\fB-d\fR \fIdir\fR, \fB--datadir=\fR\fIdir\fR 4
Explicitly set the data directory path, which is used to store all the actual databases and tables. This will become quite big (easily in the order of five times the amount of actual data stored in the cluster). Defaults to f(CW*(C`/var/lib/postgresql/*(C'versionf(CW*(C`/*(C'cluster.
\fB-s\fR \fIdir\fR, \fB--socketdir=\fR\fIdir\fR 4
Explicitly set the directory where the postmaster|(1) server stores the Unix socket for local connections. Defaults to f(CW*(C`/var/run/postgresql/*(C' for clusters owned by the user postgres, and f(CW*(C`/tmp*(C' for clusters owned by other users. Please be aware that f(CW*(C`/tmp*(C' is 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.
\fB-l\fR \fIpath\fR, \fB--logfile=\fR\fIpath\fR 4
Explicitly set the path for the postmaster|(1) server log file. Defaults to f(CW*(C`/var/log/postgresql/postgresql-*(C'versionf(CW*(C`-*(C'clusterf(CW*(C`.log*(C'.
Set the default locale for the database cluster. If this option is not specified, the locale is inherited from the environment that pg_createcluster runs in.
\fB--lc-collate=\fR\fIlocale\fR 4
\fB--lc-ctype=\fR\fIlocale\fR 4
\fB--lc-messages=\fR\fIlocale\fR 4
\fB--lc-monetary=\fR\fIlocale\fR 4
\fB--lc-numeric=\fR\fIlocale\fR 4
\fB--lc-time=\fR\fIlocale\fR 4
Like --locale, but only sets the locale in the specified category.
\fB-e\fR \fIencoding\fR, \fB--encoding=\fR\fIencoding\fR 4
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 s-1SQL_ASCIIs0 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.
\fB-p\fR \fIport\fR, \fB--port=\fR\fIport\fR 4
Select the port the new cluster listens on (for the Unix socket and the s-1TCPs0 port); this must be a number between 1024 and 65535, since PostgreSQL does not run as root and thus needs an unprivileged port number. By default the next free port starting from 5432 is assigned.
Immediately start a server for the cluster after creating it (i. e. call f(CW*(C`pg_ctlcluster*(C' version cluster f(CW*(C`start*(C' on it). By default, the cluster is not started.
\fB--start-conf=\fR\fBauto\fR|\fBmanual\fR|\fBdisabled\fR 4
Set the initial value in the f(CW*(C`start.conf*(C' configuration file. See s-1STARTUP CONTROLs0 below. By default, auto is used, which means that the cluster is handled by f(CW*(C`/etc/init.d/postgresql*(C', i. e. starts and stops automatically on system boot.
\fB-o\fR \fIguc\fR\fB=\fR\fIvalue\fR, \fB--pgoption\fR \fIguc\fR\fB=\fR\fIvalue\fR 4
Configuration option to set in the new f(CW*(C`postgresql.conf*(C' file.
\fB--createclusterconf=\fR\fIfile\fR 4
Alternative createcluster.conf file to use. Default is f(CW*(C`/etc/postgresql-common/createcluster.conf*(C' (or f(CW*(C`$PGSYSCONFDIR/createcluster.conf*(C').
\fB--environment=\fR\fIfile\fR 4
Alternative default environment file to use. Default is f(CW*(C`/etc/postgresql-common/environment*(C' (or f(CW*(C`$PGSYSCONFDIR/environment*(C'). If the file is missing, a placeholder string is used. f(CW%v and f(CW%c are replaced; see s-1DEFAULT VALUESs0 below.
\fB--\fR \fIinitdb options\fR 4
Options passed directly to initdb|(1).
Per default, pg_createcluster will update the f(CW*(C`pg_hba.conf*(C' file generated by initdb to use peer authentication on local (unix) connections, and md5 on s-1TCP s0(host) connections. If explicit authentication config is included here (-A, --auth, --auth-host, --auth-local), the f(CW*(C`pg_hba.conf*(C' file will be left untouched.
The f(CW*(C`start.conf*(C' 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:
The postmaster process is started/stopped automatically in the init script. This is also the default if the file is missing.
The postmaster process is not handled by the init script, but manually controlling the cluster with pg_ctlcluster|(1) is permitted.
Neither the init script nor pg_ctlcluster|(1) are permitted to start/stop the cluster. Please be aware that this will not stop the cluster owner from calling lower level tools to control the postmaster process; this option is only meant to prevent accidents during maintenance, not more.
The f(CW*(C`pg_ctl.conf*(C' file in the cluster configuration directory can contain additional options passed to pg_ctl of that cluster.
Some default values used by pg_createcluster can be modified in f(CW*(C`/etc/postgresql-common/createcluster.conf*(C'. Occurrences of f(CB%v are replaced by the major version number, and f(CB%c by the cluster name. Use %% for a literal %.
\fBcreate_main_cluster\fR (Default: \fBtrue\fR) 4
Create a main cluster when a new postgresql-x.y server package is installed.
\fBstart_conf\fR (Default: \fBauto\fR) 4
Default f(CW*(C`start.conf*(C' \fBdata_directory\fR (Default: \fB/var/lib/postgresql/%v/%c\fR) 4
Default data directory.
\fBxlogdir\fR (Default: unset) 4
Default directory for transaction logs. When used, initdb will create a symlink from f(CW*(C`pg_xlog*(C'
\fBinitdb_options\fR (Default: unset) 4
Other options to pass to initdb.
All other options listed are copied into the new cluster's postgresql.conf, e.g.:
listen_addresses = *(Aq**(Aq log_line_prefix = *(Aq%%t *(Aq
Some postgresql.conf options are treated specially:
Only added to postgresql.conf if the default snakeoil certificates exist and are readable for the cluster owner as detailed above.
Only added to postgresql.conf if existing, and writable for the cluster owner, or else if the parent directory is writable.
initdb|(1), pg_ctlcluster|(8), pg_lsclusters|(1), pg_wrapper|(1)
Martin Pitt <mpitt@debian.org>, Christoph Berg <myon@debian.org>