文档中心MogDBMogDB StackUqbar

文档:v2.0

支持的版本:

管理Uqbar

通过PTK安装Uqbar数据库后,用户可对数据库进行相关操作,包括启动、停止、重启数据库以及查看数据库状态。

说明:下面以集群uqbar110为例。

启动数据库集群

在安装完数据库集群后,PTK 默认会将数据库集群启动。

此外,可通过 cluster start 指令启动集群,需指定集群的集群名称。

# ptk cluster -n uqbar110 start
INFO[2022-12-02T10:22:56.957] operation: start                             
INFO[2022-12-02T10:22:56.957] ========================================     
INFO[2022-12-02T10:22:56.957] start db [172.16.0.127:27009] ...            
INFO[2022-12-02T10:22:58.058] start db [172.16.0.127:27009] successfully   
INFO[2022-12-02T10:22:58.203] ========================================     
INFO[2022-12-02T10:22:58.203] start cluster successfully

同时,PTK 默认会启动集群内所有实例,PTK 也支持指定单个实例启动,需指定实例的IP:

# ptk cluster -n uqbar110 start -H 192.168.122.101

停止数据库集群

如果想要停止数据库集群,可以通过 cluster stop 指令,默认会停止集群内所有实例:

# ptk cluster -n uqbar110 stop
INFO[2022-12-02T10:16:28.092] operation: stop                              
INFO[2022-12-02T10:16:28.092] ========================================     
INFO[2022-12-02T10:16:28.092] stop db [172.16.0.127:27009] ...             
INFO[2022-12-02T10:16:29.157] stop db [172.16.0.127:27009] successfully    
INFO[2022-12-02T10:16:29.157] ========================================     
INFO[2022-12-02T10:16:29.158] stop successfully             

如果想要停止集群内某个实例,可通过 -H 指定实例的IP,例如:

ptk cluster -n uqbar110 stop -H 192.168.122.101

重启数据库集群

重启集群的操作,本质上是先停止数据库,再启动数据库的组合操作。

可通过 cluster restart 指令来实现:

# ptk cluster -n uqbar110 restart
INFO[2022-12-02T10:01:09.013] operation: stop                              
INFO[2022-12-02T10:01:09.014] ========================================     
INFO[2022-12-02T10:01:09.014] stop db [172.16.0.127:27009] ...             
INFO[2022-12-02T10:01:10.079] stop db [172.16.0.127:27009] successfully    
INFO[2022-12-02T10:01:10.079] ========================================     
INFO[2022-12-02T10:01:10.079] stop successfully                            

INFO[2022-12-02T10:01:10.080] operation: start                             
INFO[2022-12-02T10:01:10.080] ========================================     
INFO[2022-12-02T10:01:10.080] start db [172.16.0.127:27009] ...            
INFO[2022-12-02T10:01:11.185] start db [172.16.0.127:27009] successfully   
INFO[2022-12-02T10:01:11.329] ========================================     
INFO[2022-12-02T10:01:11.329] start cluster successfully

查看数据库状态

可通过-n指定集群名称或通过-f指定配置文件来查看数据库状态:

注意:如果通过配置文件查询数据库状态,需要在配置文件所在目录下执行查询命令。

[root@hostname]# ptk cluster status -n uqbar110
[   Cluster State   ]
database_version                        : Uqbar-Uqbar
cluster_name                            : uqbar110
cluster_state                           : Normal
current_az                              : AZ_ALL

[  Datanode State   ]
   id  |      ip      | port  | user  | instance | db_role | state   
-------+--------------+-------+-------+----------+---------+---------
  6001 | 172.16.0.245 | 27000 | omm01 | dn_6001  | Normal  | Normal  
Copyright © 2011-2024 www.enmotech.com All rights reserved.