qhb_bootstrap

qhb_bootstrap — create a new QHB database cluster


Synopsis

qhb_bootstrap [switch...] [option...] datadir

Description

qhb_bootstrap creates a new QHB database cluster. A database cluster is a collection of databases that are managed by a single server instance.

Bootstrap a database cluster consists of creating the directories in which the database data will live, generating the shared catalog tables (tables that belong to the whole cluster rather than to any particular database), and creating the qhb, template1 и template0. databases. The qhb database is a default database meant for use by users, utilities and third party applications. template1 and template0 are meant as source databases to be copied by later CREATE DATABASE commands. template0 should never be modified, but you can add objects to template1, which by default will be copied into databases created later. See Section Template Databases for more details.


Security

qhb_bootstrap must be run as the user that will own the server process, because the server needs to have access to the files and directories that qhb_bootstrap creates. Since the server cannot be run as superuser, qhb_bootstrap will refuse be run as superuser either.

For security reasons the new cluster created by qhb_bootstrap will only be accessible by the cluster owner by default. The --allow-group-access option allows any user in the same group as the cluster owner to read files in the cluster. This is useful for performing backups as a non-privileged user.

Do not use trust authentication method unless you trust all local users on your system. trust is the default for ease of installation.


Localization

qhb_bootstrap initializes the database cluster's default locale and character set encoding. These can also be set separately for each database when it is created. qhb_bootstrap determines those settings for the template databases, which will serve as the default for all other databases. Specified locale must be set in the system. (To check what locales are installed on your system, you can use the command locale -a.)

To choose a different locale for the cluster, use the option --locale. There are also individual options --lc-* (see below) to set values for the individual locale categories. Note that inconsistent settings for different locale categories can give nonsensical results, so this should be used with care. See article «Еще раз про collation в PostgreSQL».

When qhb_bootstrap runs, it will print out the locale settings it has chosen. If you have complex requirements or specified multiple options, it is advisable to check that the result matches what was intended.

More details about locale settings can be found in Section Locale Support.

To alter the default encoding, use the --encoding. More details can be found in Section Character Set Support.


Options

-A authmethod
--auth=authmethod
This option specifies the default authentication method for local users used in qhb_hba.conf (host and local lines). See Section The qhb_hba.conf File for an overview of valid values. The default is trust.
qhb_bootstrap will prepopulate qhb_hba.conf entries using the specified authentication method for non-replication as well as replication connections.

--auth-host=authmethod
This option specifies the authentication method for local users via TCP/IP connections used in qhb_hba.conf (host lines). Possible values are trust, reject, scram_sha_256, md5, password, radius, pam, bsd, ldap, ident, gss, sspi, cert. By default, the value is derived from --auth option.

--auth-local=authmethod
This option specifies the authentication method for local users via Unix-domain socket connections used in qhb_hba.conf (local lines). Possible values are trust, reject, scram_sha_256, md5, password, radius, pam, bsd, ldap, peer. By default, the value is derived from --auth option.

-D directory
--pgdata=directory
This option specifies the directory where the database cluster should be stored. This is the only information required by qhb_bootstrap, but you can avoid writing it by setting the PGDATA environment variable, which can be convenient since the database server (qhb) can find the database directory later by the same variable.

-E encoding
--encoding=encoding
Selects the encoding of the template databases. This will also be the default encoding of any database you create later, unless you override it then. Currently only the UTF8 encoding is supported. The default is UTF8.

--locale=locale
Sets the default locale for the database cluster. By default, the neutral locale C (C Locale) is set. Locale support is described in Section Locale Support.

--lc-collate=locale
Sets the locale for the string sort order. By default, the value is derived from --locale option.

--lc-ctype=locale
Sets the locale for the character classification. By default, the value is derived from --locale option.

--lc-messages=locale
Sets the locale for the language of messages. By default, the value is derived from --locale option.

--lc-monetary=locale
Sets the locale for the formatting of currency amounts. By default, the value is derived from --locale option.

--lc-numeric=locale
Sets the locale for the formatting of numbers. By default, the value is derived from --locale.

--lc-time=locale
Sets the locale for the formatting of dates and times. By default, the value is derived from --locale option.

--no-locale
Equivalent to --locale=C, i. e. setting default neutral locale. Cannot be used with --locale option.

--pwfile=filename
Makes qhb_bootstrap read the database superuser's password from the first line of the file. pwprompt and pwfile options are mutually exclusive. When auth-host or auth-local specifies authentication method other than trust, then using pwprompt or pwfile is mandatory.

-L directory
--share-dir=directory
Specifies where qhb_bootstrap should find its input files to initialize the database cluster. The default is share in the directory from data-dir option.

-T config
--text-search-config=config
Sets the default text search configuration. See default_text_search_config for further information. Defaults to the value of the lc_ctype; otherwise it is simple.

-U username
--username=username
Selects the user name of the database superuser. This defaults to the name of the effective user running qhb_bootstrap. It is really not important what the superuser's name is, but one might choose to keep the customary name qhb, even if the operating system user's name is different.

-X directory
--waldir=directory
This option specifies the directory where the write-ahead log should be stored. The default is pg_wal in the directory from data-dir.

--wal-segsize=size
Set the WAL segment size, in megabytes. This is the size of each individual file in the WAL log. The default size is 16 megabytes. The value must be a power of 2 between 1 and 1024 (megabytes). This option can only be set during initialization, and cannot be changed later.
It may be useful to adjust this size to control the granularity of WAL log shipping or archiving. Also, in databases with a high volume of WAL, the sheer number of WAL files per directory can become a performance and management problem. Increasing the WAL file size will reduce the number of WAL files.


Switches

-d
--debug
Print debugging output from the bootstrap backend and a few other messages. The bootstrap backend is the program qhb_bootstrap uses to create the catalog tables. This option generates a lot of debugging and informative output. The default is false.

-h
--help
Show help.

-g
--allow-group-access
Allows users in the same group as the cluster owner to read all cluster files created by qhb_bootstrap. The default is false.

-k
--data-checksums
Use checksums on data pages to help detect corruption by the I/O system that would otherwise be silent. Enabling checksums may incur a noticeable performance penalty. If set, checksums are calculated for all objects, in all databases. All checksum failures will be reported in the pg_stat_database view. See Section Data Checksums for details. The default is false.

-n
--no-clean
By default, when qhb_bootstrap determines an error while creating the database cluster, it removes any files it might have created up to this moment. This option inhibits tidying-up and is thus useful for debugging. The default is false (to remove files).

-N
--no-sync
By default, qhb_bootstrap will wait for all files to be written safely to disk. This option causes qhb_bootstrap to return without waiting, which is faster, but means that a subsequent operating system crash can leave the data directory corrupt. Generally, this option is useful for testing, but should not be used when creating a production installation. The default is false.

-s
--show
Print configuration without creating of the cluster. This does not perform any of the normal qhb_bootstrap operations. The default is false.

-S
--sync-only
Safely write all database files to disk and exit. This does not perform any of the normal qhb_bootstrap operations. The default is false.

-V
--version
Print the current qhb_bootstrap version.

-W
--pwprompt
Makes qhb_bootstrap prompt for a password to give the database superuser. If you don't plan on using password authentication, this is not important. Otherwise you won't be able to use password authentication until you have a password set up.


Environment

PGDATA
Specifies the directory where the database cluster is to be stored; can be overridden using the -D option.

PG_COLOR
Specifies whether to use color in diagnostic messages. Possible values are always, auto and never.

TZ
Specifies the default time zone of the created database cluster. The value should be a full time zone name (see Section Time Zones).

This utility, like most other QHB utilities, also uses the environment variables supported by libpq (see Section Environment Variables).


Examples

To create cluster in /qhb/qhb-data directory with default settings:

qhb_bootstrap --data-dir /qhb/qhb-data

To create cluster in /qhb/qhb-data directory with encoding ru_RU and encryption SCRAM-SHA-256, with printing verbose debugging output:

qhb_bootstrap --data-dir /qhb/qhb-data --locale ru_RU --auth scram_sha_256 -d

See Also

qhb_ctl, qhb Instance, Section The qhb_hba.conf File