Usage Guidelines
Background
During installation, you are advised to use the -D parameter to invoke gs_initdb to initialize a database. If a database needs to be initialized to rectify a fault, run gs_initdb.
- Although gs_initdb attempts to create the corresponding data directory, it may not have the permission to do so. Because in most cases, the parent directory is owned by user root. To create a data directory, create an empty data directory as user root first and transfer the ownership of this directory to the database user using chown.
- gs_initdb is used to set the template1 database and the settings become the default settings of other databases.
- gs_initdb initializes the default locale and character set encoding of a database. The character set encoding, character encoding order (LC_COLLATE), and character set classes (LC_CTYPE, for example, uppercase letter, lowercase letter, or digit) can be set separately for a database when it is created.
Procedure
Log in to any host of the openGauss database as the OS user omm.
Plan the database directory.
Switch to the root user.
su - root
Enter your username and password as prompted.
Go to the /opt/gaussdb directory and create the data1 directory where the DN resides.
cd /opt/gaussdb mkdir data1
Allocate the ownership of the data1 directory to user omm, and dbgrp is the user group to whom user omm belongs to.
chown omm:dbgrp data1
Log out as user root.
exit
Run the gs_initdb command to initialize the database and set password as prompted.
gs_initdb /opt/gaussdb/data1 --nodename dn1 Enter new system admin password:[PASSWORD] Enter it again:[PASSWORD]
gs_initdb syntax:
gs_initdb [OPTION]... [DATADIR]
For parameters about OPTION, see Command Reference.
Feedback