gaussdb
Background
gaussdb is a major process of openGauss and also an executable command. A database process can be started using gaussdb.
Syntax
gaussdb [OPTION]...
Description
To access the database, the client application connects (over a local network or the Internet) to a running gaussdb process. Then the process starts an independent thread to handle the connection.
NOTICE: When starting the database using gaussdb, you also need to open another window to connect to the database or use the symbol (&) to enable the application to run in the background.
A gaussdb process manages all data in a database. A system can operate multiple gaussdb processes using different data directories and port numbers. When gaussdb is started, the location of the data directory must be specified by -D. Typically, -D points directly to the database directory created by gs_initdb.
By default, gaussdb starts in the foreground and prints log information to the standard error. In practice, most gaussdb processes start automatically on the background when the system is started.
The gaussdb tool can also be called in single-user mode. The primary use for this mode is during the initialization of gs_initdb. Sometimes, it is used for debugging or disaster recovery. However, running a single-user server is not truly suitable for debugging the server, because no realistic inter-process communication and locking happens. When the gaussdb command is called in single-user mode from the shell, you can enter queries, and the results will be printed to the screen, but in a form that is more favorable for developers rather than common users. In single-user mode, the session user ID is set to 1 and given the administrator permission. The user does not need to be existent. Therefore, servers in single-user mode can be used to manually recover damaged system catalogs.
Options
gaussdb supports command parameters listed in Table 1.
Table 1 Parameter description
Parameters described in Table 2 are used for debugging purposes, and in some cases for assisting in restoring severely damaged databases. Do not use these parameters for debugging if databases are providing services for applications.
Table 2 Developer options
Options listed in Table 3 apply only to the single-user mode.
Table 3 Options for the single-user mode
Selects the single-user mode. This must be the first option of the command. | ||
Saves all server standard output and standard errors to filename. |
Table 4 Options for the automatic startup mode
Table 5 Options for the upgrade mode
Except the preceding parameters, all other parameters in postgres.conf can be transferred to GaussDB in --guc_name=guc_value mode when GaussDB is started. Example: --enable_fast_query_shipping=off
Environment Variables
- PGLINETENCODING: indicates the default character encoding used by clients. The clients can override this variable individually. This value can also be set in the configuration file.
- PGDATESTYLE: indicates the default value of the DateStyle run-time parameter. The use of this environment variable is deprecated.
- TZ: indicates the time zone of the server.
Error Processing
A failure message mentioning semget or shmget probably indicates that you need to reconfigure your kernel to provide adequate shared memory and semaphore. You can decrease shared_buffers to reduce the shared memory consumption of openGauss, or decrease max_connections to reduce the semaphore consumption of openGauss.
A failure message suggesting that another server is already running should be checked carefully, for example by using the following command depending on your system:
ps ax | grep gaussdb
Or
ps -ef | grep gaussdb
If you are certain that no conflicting server is running, you can remove the lock file mentioned in the message and try again.
A port binding failure message indicates that the port is already in use by a non-openGauss process. This message may also be reported if you terminate gaussdb and immediately restart it using the same port. In this case, you must simply wait a few seconds until the operating system closes the port before trying again. Finally, you may get this error if you specify a port number that your operating system considers it to be reserved. For example, the Unix considers ports whose IDs are under 1024 to be “trusted” and permits only Unix administrators to access the Unix.
NOTICE:
- Using SIGKILL to kill the main process prevents gaussdb from releasing system resources (such as shared memory and semaphores) that is holds, which affects new processes.
- To properly terminate the server process, signals SIGTERM, SIGINT, and SIGQUIT can be used. SIGTERM will wait for all clients to terminate before exit. SIGINT will forcibly disconnect all clients, and SIGQUIT will exit immediately without proper shutdown, resulting in a recovery run during restart.
- The SIGHUP signal will reload the server configuration files. It is also possible to send SIGHUP to an individual server process, but that is usually not sensible.
- To cancel a running query, send the SIGINT signal to the process running that command.
Usage
Run the following command to start a server in single-user mode:
gaussdb --single -D /usr/local/pgsql/data other-options my_database
Use -D to provide the correct path of the database directory for the server. Besides, specify the name of the existing particular database.
NOTICE:
- In most cases, the single-user mode server treats newline as the command entry terminator. To continue a command across multiple lines, you must type a backslash just before each newline except the last one.
- If you use the -j option, then newline does not terminate command entry. In this case, the server will read the standard input until the end-of-file (EOF) marker, then process the input as a single command string. Backslashs and newlines are treated as common characters in this case.
- To quit the session, type EOF (by pressing Ctrl+D). If you have used -j, two consecutive EOFs are needed to exit the session.
- The single-user mode server does not provide complex line-editing functions (no command history, for example). The single-user mode also does not do any background processing, like automatic checkpoints.
Examples
Run the following command to start gaussdb in the background using the default value:
nohup gaussdb >logfile 2>&1 </dev/null &
Start gaussdb on a specified port (for example, 1234). The -D parameter indicates the data directory after gs_initdb initialization.
gaussdb -p 1234 -D /usr/local/pgsql/data
To connect to this server using gsql, specify this port with the -p option:
gsql -d postgres -p 1234