HomeMogDBMogDB StackUqbar
v5.0

Documentation:v5.0

Supported Versions:

Other Versions:

gs_ctl

Function

gs_ctl is a tool provided by MogDB for controlling database services. It can be used to start or stop a database and to query the database status. It is invoked by the database management module.

  • Start, stop, and restart the MogDB node.
  • Reload the configuration files (postgresql.conf and pg_hba.conf) without stopping the database.
  • Perform primary/standby switchover, query primary/standby status, DN rebuild the database instance, and query the rebuilding status.

Parameter Description

The gs_ctl tool can use the following types of parameters:

  • option parameters. For details, see Table 1.
  • Common parameters. For details, see Table 2.
  • start and restart parameters. For details, see Table 3.
  • stop and restart parameters. For details, see Table 4.
  • switchover parameters. For details, see Table 5.
  • build parameters. For details, see Table 6.
  • Parameters for query. For details, see Table 7.
  • Parameters for member. For details, see Table 8.
  • Parameters for changerole. For details, see Table 9.
  • Parameters for setrunmode. For details, see Table 10.

Table 1 Parameters for option

Parameter Description
init[db] Initializes a DN.
start Starts a DN.
restart Restarts a DN.
build Rebuilds the instance on the node where the instance needs to be rebuilt.
stop Stops a DN.
reload Reloads the configuration files (postgresql.conf and pg_hba.conf).
status Displays the DN running status.
failover Promotes the standby DN to the primary DN when the primary DN is faulty.
switchover When the primary/standby DN relationship is normal, and the standby DN is switched to the primary DN for maintenance purposes, data will not be lost during the switchover.
query Queries the status between the primary and standby DNs.
notify Specifies the primary/standby DNs after startup.
kill Sends semaphore to a specified process.
querybuild Checks the rebuild process of a DN.
finishredo Forcibly stops redo.
CAUTION:
This parameter is a high-risk operation. Exercise caution when performing this operation.
copy Copies Xlogs in the dual-center DR mode based on shared storage.

Table 2 Common parameters

Parameter Description Value Range
-D, --pgdata=DATADIR Specifies the data directory. The value of DATADIR must be valid.
-s, --silent Prints partial prompt information only for the reload, restart, and stop commands.
Prints information such as "gstl stopped, xxx". Information such as " waiting for server to shut down, server stopped" is not printed.
-
-t, --timeout=SECS This parameter controls the following functions:Maximum seconds for waiting the completion of database startup or shutdown. Value range: integer (s)
Default value:
Maximum seconds for waiting the completion of database startup or shutdown: 60s.
-V , --version Prints the gs_ctl version information and exits. -
-w Waits for the transaction to complete and then executes the database startup or shutdown operation. Default value: If this parameter is not specified, the operation is executed until the transaction is complete.
-W Does not wait for the transaction to complete and executes the database startup or shutdown operation forcibly. -
-M -M must be followed by the SERVERMODE parameter, which specifies the start mode of a database upon startup. The value of SERVERMODE can be one of the following three:
primary: The local host starts as the primary node.
standby: The local host starts as the standby node.
pending: The local host waits for switching to the primary or standby node.
-T -T is followed by a term. The term is used as the host term when the command for switching the standby server to primary is executed. During the rebuilding, hosts greater than the term will be connected. Value range: unsigned integer
-q The process does not automatically start after the build is complete. It needs to be started by the invoker. -
-d Prints more debugging information. -
-L To query the validity of lsn:XX/XX and display max_lsn, run the following command: -
-P PASSWORD Used together with the -U parameter and specifies the password of the user that connects to the local database.
NOTE:
The -P parameter is invalid when the -U parameter is omitted and the authentication method is trust.
-
-U USERNAME Specifies the user that connects to the database. This parameter can be used only with the parameter notify, query, or querybuild.
For domain users, use the **DOMAIN**username format.
Value range: users exist in MogDB.
Default value: If this parameter is not specified, the current OS user is used.
-?, -h, --help Displays help information about gs_ctl command parameters. -

Table 3 Common parameters for start and restart

Parameter Description Value Range
-c, --core-file Allows the mogdb process to produce core files. -
-l, --log=FILENAME Appends the server log output to the FILENAME file. The value of FILENAME is a file that the user who starts the database service has the permission to operate.
For example, the value is a file in the data directory.
-o OPTIONS Specifies the mogdb command options to be transferred and executed by MogDB.
The options should usually be surrounded by single or double quotation marks to ensure that they are passed through as a whole.
Parameters supported in mogdb.
-p PATH-TO-POSTGRES Specifies the location of the mogdb executable. By default, the mogdb executable is taken from the same directory as gs_ctl. In most cases, it is not necessary to use this option.

Table 4 Common parameters for stop and restart

Parameter Description Value Range
-m, --mode=MODE Specifies the stop mode. Values of mode:
- fast: All active transactions are rolled back and all clients are disconnected forcibly, and then the server is disabled.
- immediate: The server is shut down forcibly and fault recovery occurs on the next startup.
Default value: fast

Table 5 Parameters for switchover

Parameter Description Value Range
-f All active transactions are rolled back and all clients are disconnected forcibly, and then the server is switched and no checkpoint is performed. N/A
--m SWITCHOVER-MODE Specifies the switchover mode when the primary/standby instances are normal. Values of mode:
- fast: All active transactions are rolled back and all clients are disconnected forcibly, and then the server is switched.
- smart: The cluster is switched over after all the clients are disconnected. If the server is in hot standby, recovery and replication flows will be terminated once all clients have been disconnected.
Note: In the cluster environment, the cluster management connection and customer service connection make it difficult to execute the smart mode. Therefore, this mode is discarded in this version.
Default value: fast

Table 6 Parameters for build

Parameter Description Value Range
-b, --mode=MODE Specifies the rebuild mode of a DN standby server. Values of mode:
- full: fully resynchronizes the data directory of the primary DN using an image.
- incremental: incrementally restores the standby DN based on the differences between the data of primary and standby DNs found in Xlogs.
WARNING:
1. Incremental rebuild is used for active-active clusters with inconsistent primary/standby logs.
2. If damaged data files and lost data directories of a standby DN cannot be restored by incremental rebuild, full rebuild can be used to restore the standby DN.
- auto (not specified): selects incremental first and then Full after incremental fails for three times.
- standby_full: uses the standby server to rebuild the standby server or uses the first standby server in a DR scenario to rebuild the faulty standby server in the DR database instance.
- copy_secure_files: In the streaming DR scenario, obtains the content in the gs_secure_files directory in the data directory of a specified node.
- copy_upgrade_file: obtains specified files required for the upgrade on a specified node in the Dorado DR scenario.
- cross_cluster_full: performs cross-cluster full build based on shared storage in the intra-city dual-center scenario.
- cross_cluster_incremental: performs cross-cluster incremental build based on shared storage in the same-city dual-center scenario.
- auto (not specified): Selects incremental first and then full after incremental fails for three times.
Default value: auto
-r, --recvtimeout=INTERVAL Specifies the timeout duration that a standby DN waits for receiving logs synchronized from the primary DN. Value range: an integer (s).
Default value: 120s
-d Prints more build process information. -
-C CONNECTOR Specifies the connection string used for connecting to the source DN to rebuild a DN on the current node. Only the connection from the standby server to the standby server is supported. The connection string contains the IP address and port number of the DN to be rebuilt on the current node and those of the source DN. Its format is as follows:
'localhost=Local DN IP localport=Local DN Port+1 remotehost=DN IP remoteport=DN Port+1'

Table 7 Parameters for query

Parameter Description Value Range
-L Queries the LSN and displays the maximum length. None

Table 8 Parameters for member

Parameter Description Value Range
--operation Adds or deletes nodes in DCF mode in an MogDB database instance. - add: adds a node to the DCF node configuration of the database instance.
- remove: deletes a node from the DCF node configuration of the database instance.
-u, --nodeid Specifies a new DCF node ID. Unsigned integer
-i, --ip Specifies an IP address used by the new node to communicate with the DCF module of the database instance. Character string
-e, --port Specifies a port number used by the new node to communicate with the DCF module of the database instance. Integer
[-D, --pgdata=]DATADIR Specifies the data directory. Set DATADIR as required.

Table 9 Parameters for changerole

Parameter Description Value Range
-R, --role Specifies the node role in DCF mode in an MogDB database instance. This role must be used on the node whose role is primary. - passive: passive role
- follower: follower role
-u, --nodeid Specifies a new DCF node ID. Unsigned integer
[-D, --pgdata=]DATADIR Specifies the data directory. Set DATADIR as required.

Table 10 Parameters for setrunmode

Parameter Description Value Range
-v, --votenum Specifies the number of votes. Unsigned integer
-x, --xmode Specifies the running mode (used on minority DNs). - minority: minority forcible startup
- normal: resuming
[-D, --pgdata=]DATADIR Specifies the data directory. Set DATADIR as required.
Copyright © 2011-2024 www.enmotech.com All rights reserved.