HomeMogDBMogDB StackUqbar
v1.1

Documentation:v1.1

Supported Versions:

Other Versions:

Instance-Level Cluster O&M Tool - ptkc

The tool is supported since PTK V0.8.

During installation of a database cluster, PTK will generate a tool named ptkc under the database system user.

Comparison Among ptkc, gs_ctl, and gs_om

Function ptkc gs_ctl gs_om
Query the database status Support for cluster and instance Support for the local instance only Support for cluster and instance
Start a database Support for cluster and instance Support for the local instance only Support for cluster and instance
Stop a database Support for cluster and instance Support for the local instance only Support for cluster and instance
Restart a database Support for cluster and instance Support for the local instance only Support for cluster and instance
Rebuild a database Supported on the local and remote servers Support for the local instance only Supported on the local and remote servers
Specify an upstream node to rebuild a database Supported Supported Not supported
Failover Supported on the local and remote servers Support for the local instance only Not supported
Switchover Supported on the local and remote servers Support for the local instance only Not supported
Query database parameters Supported on the local and remote servers Not supported Not supported
View HBA information Supported on the local and remote servers Not supported Not supported

ptkc Usage

ptkc usage is kept consistent with ptk usage. PTK is a multi-cluster management tool and ptkc is a single-cluster O&M tool. Therefore, the ptkc instructions are more simple than those of PTK.

Note: ptkc itself does not store any metadata and completely depends on the existing status file to parse cluster information. Because the current status information does not include the system user information, ptkc does not support such scenarios as multiple nodes, multiple users, and multiple instances on a single server.

The following shows some examples. For more commands, run ptkc -h.

Query the Cluster Status

$ ptkc status
[   Cluster State   ]
cluster_name          : c1
cluster_state         : Normal
database_version      : MogDB 3.0.4 (build cc068866)

[  Datanode State   ]
  cluster_name |  id  |     ip      | port  | user | nodename | db_role | state  | upstream
---------------+------+-------------+-------+------+----------+---------+--------+-----------
  c1           | 6001 | 172.23.1.87 | 33300 | vmx1 | dn_6001  | primary | Normal | -
               | 6002 | 172.23.1.88 | 33300 | vmx1 | dn_6002  | standby | Normal | -

Restart a Cluster

ptkc restart

Perform Primary/Standby Switchover

$ ptkc switchover -H 172.23.1.88
INFO[2023-05-26T17:58:15.234] start switchover, please wait a few moments ...
INFO[2023-05-26T17:58:20.324] switchover output:
[2023-05-26 17:58:15.295][3035571][][gs_ctl]: gs_ctl switchover ,datadir is /home/vmx1/mogdb/data
[2023-05-26 17:58:15.295][3035571][][gs_ctl]: switchover term (1)
[2023-05-26 17:58:15.299][3035571][][gs_ctl]: waiting for server to switchover........
[2023-05-26 17:58:20.323][3035571][][gs_ctl]: done
[2023-05-26 17:58:20.323][3035571][][gs_ctl]: switchover completed (/home/vmx1/mogdb/data)
INFO[2023-05-26T17:58:20.324] switchover successfully
$ ptkc status
[   Cluster State   ]
cluster_name          : c1
cluster_state         : Normal
database_version      : MogDB 3.0.4 (build cc068866)

[  Datanode State   ]
  cluster_name |  id  |     ip      | port  | user | nodename | db_role | state  | upstream
---------------+------+-------------+-------+------+----------+---------+--------+-----------
  c1           | 6001 | 172.23.1.87 | 33300 | vmx1 | dn_6001  | standby | Normal | -
               | 6002 | 172.23.1.88 | 33300 | vmx1 | dn_6002  | primary | Normal | -

Query Database Parameters

$ ptkc show-guc -k port
port = 33300

Generate ptkc

The PTK installation package does not provide the ptkc tool by default. You need to generate the ptkc tool by running the following command.

ptk gen-ptkc
Copyright © 2011-2024 www.enmotech.com All rights reserved.