HomeMogDBMogDB StackUqbar
v1.1

Documentation:v1.1

Supported Versions:

Other Versions:

Operating with a Database

View the Cluster List

After the database clusters is installed, you can run ptk ls to query the list of clusters installed by the current user.

Because PTK metadata is stored in the $HOME/.ptk directory, you can query the list of the clusters installed under the current user.

Example:

$ ptk ls
cluster_name|  id  |         addr          | user |       data_dir        |          db_version          |     create_time     | comment
------------------+------+-----------------------+------+-----------------------+------------------------------+---------------------+----------
     c1     | 6001 | 192.168.100.100:26000 | ptk1 | /home/ptk1/mogdb/data | MogDB 3.0.3 (build 23ba838d) | 2022-11-09 15:01:34 |

The output list describes the following information:

  • cluster_name: specifies the cluster name.
  • id: specifies the ID distributed to an instance during installation.
  • addr: specifies the instance address list.
  • user: specifies the system user.
  • data_dir: specifies the data directory of the instances.
  • db_version: specifies the database version.
  • create_time: specifies the cluster creation time.
  • comment: specifies the cluster comment information.

After the database cluster is installed, please use the -n parameter to specify the cluster name.

View the Cluster Status

ptk cluster -n <CLUSTER_NAME> status

Cluster Status

Status Description
Normal All instances in a cluster are normal.
Unavailable A cluster is unavailable because there is no primary database, or the primary database is abnormal.
Degraded The cluster is available but some standby nodes are unavailable.
Stopped All nodes in a cluster are stopped.
MultiPrimary There are multiple primary instances in a cluster.

Instance Status

The instance status is kept consistent with the list defined by the database kernel. Additionally, the status SSH Disconnect is added.

Status Description
Unknown Unknown
Normal Normal
Need repair The replication is interrupted and is to be fixed.
Starting An instance is being started.
Wait promoting A node is waiting for being a primary one.
Promoting A node is being switched over to a primary node.
Demoting A node is being switched over to a standby node.
Building A node is being rebuilt.
Catchup A node is synchronizing logs from the other node.
Coredump An instance breaks down.
Stopped An instance is stopped.
SSH Disconnect The SSH connection of a server where the instance is located fails.

Start the Cluster

After the database cluster is installed, PTK will start the database cluster by default.

If the --skip-launch-db parameter is specified during installation, the database is in the stopped status.

The command to start the entire cluster is as follows:

ptk cluster -n <CLUSTER_NAME> start

PTK starts all instances in the cluster by default. It also supports the starting of a single instance.

The -H or --host parameter specifies the IP of the instance.

ptk cluster -n <CLUSTER_NAME> start -H <IP>

The -i or --id parameter specifies the ID of the instance (you can get ID by ptk ls).

ptk cluster -n <CLUSTER_NAME> start -i <ID>

Stop the Cluster

The command to stop the entire cluster is as follows:

ptk cluster -n <CLUSTER_NAME> stop

PTK will stop all instances in a cluster by default. It also supports the stopping of a single instance.

The -H or --host parameter specifies the IP of the instance.

ptk cluster -n <CLUSTER_NAME> stop -H <IP>

The -i or --id parameter specifies the ID of the instance (you can get ID by ptk ls).

ptk cluster -n <CLUSTER_NAME> stop -i <ID>

Restart the Cluster

Restarting a cluster is actually to stop the database first and then start the database, it also supports all the parameters supported by start and stop commands.

ptk cluster -n <CLUSTER_NAME> restart

Rebuild a Specified Database Instance

Rebuilding an instance is to actually schedule gs_ctl build to execute related operations. It only supports specifying a single instance for operation.

ptk cluster -n c1 build -H 172.16.0.190
Copyright © 2011-2024 www.enmotech.com All rights reserved.