This section describes the procedure to create an instance using the initdb command.
Creating an instance
Create an instance, with the database cluster storage destination specified in the PGDATA environment variable or in the -D option. Furthermore, the user that executed the initdb command becomes the instance administrator.
Note
Instances created using the initdb command cannot be managed using WebAdmin.
When creating multiple instances, ensure there is no duplication of database clusters and port numbers.
See
Refer to "initdb" in "Reference" in the PostgreSQL Documentation for information on the initdb command.
The procedure to create an instance is described below.
Use the OS user account that you want as the instance administrator.
Connect with the server using the OS user account that you want as the instance administrator.
You cannot use the OS superuser (root).
The following example shows the OS superuser connected to the server being changed to the OS user account "symfo".
# su symfo
Configure the environment variables
Configure the environment variables in the server with the newly created instance.
Set the following environment variables:
PATH environment variables
Add the installation directory "/bin".
MANPATH environment variables
Add the installation directory "/share/man".
LD_LIBRARY_PATH environment variables
Add the installation directory "/lib".
The following example configures environment variables when the installation directory is "/opt/symfoserver64".
$ PATH=/opt/symfoserver64/bin:$PATH ; export PATH $ MANPATH=/opt/symfoserver64/share/man:$MANPATH ; export MANPATH $ LD_LIBRARY_PATH=/opt/symfoserver64/lib:$LD_LIBRARY_PATH ; export LD_LIBRARY_PATH
$ setenv PATH /opt/symfoserver64/bin:$PATH $ setenv MANPATH /opt/symfoserver64/share/man:$MANPATH $ setenv LD_LIBRARY_PATH /opt/symfoserver64/lib:$LD_LIBRARY_PATH
Create a database cluster
Create the database cluster with the initdb command, specifying the storage destination directory.
Specify the transaction log storage destination and the locale setting option as required.
$ initdb -D /database/inst1 --xlogdir=/transaction/inst1 --lc-collate="C" --lc-ctype="C"
Note
To balance I/O load, consider deploying the transaction log storage destination to a disk device other than the database cluster storage destination and the backup data storage destination.
Specify "C" or "POSIX" for collation and character category. Performance deteriorates if you specify a value other than "C" or "POSIX", although the behavior will follow the rules for particular languages, countries and regions. Furthermore, this may need to be revised when running applications on systems with different locales.
For example, specify as follows:
initdb --locale="C" --lc_messages="C" initdb --lc-collate="C" --lc-ctype="C"
See
Refer to "Locale Support" in "Localization" in "Server Administration" in the PostgreSQL Documentation for information on locales.
Set port number.
Set the port number and instance name in the /etc/services file of the OS. Specify a port number that does not conflict with other software.
The port number specified here must also be set in the port parameter of postgresql.conf. The default is "26500".
Set the corefile output destination.
Specify the output destination of the corefile, which can later be used to collect information for investigation, by setting the core_directory and core_contents parameters of postgresql.conf.
See
Refer to "Parameters" in the Operation Guide for information on the settings for these parameters.
Set the backup storage destination.
Specify the backup data storage destination and other backup settings when backup is to be performed as a provision against database errors.
See
Refer to "Backup Methods" in the Operation Guide for information on specifying backup settings.
Start an instance.
Start with the start mode of the pg_ctl command.
It is recommended to specify the -w option, which causes the command to return after waiting for the instance to start. If the -w option is not specified, it may not be possible to determine if the starting of the instance completed successfully or if it failed.
$ pg_ctl start -w -D /database/inst1
See
Refer to "pg_ctl" in "Reference" in the PostgreSQL Documentation for information on the pg_ctl command.