title | summary | aliases | |
---|---|---|---|
验证集群运行状态 |
介绍如何验证集群运行状态。 |
|
在部署完一套 TiDB 集群后,需要检查集群是否正常运行。本文介绍如何通过 TiUP 命令、TiDB Dashboard 和 Grafana 检查集群状态,以及如何登录 TiDB 数据库执行简单的 SQL 操作。
检查集群状态的命令是 tiup cluster display <cluster-name>
,例如:
{{< copyable "shell-regular" >}}
tiup cluster display tidb-test
预期结果输出:各节点 Status 状态信息为 Up
说明集群状态正常。
本节介绍如何通过 TiDB Dashboard 和 Grafana 检查集群状态。
-
通过
{pd-ip}:{pd-port}/dashboard
登录 TiDB Dashboard,登录用户和口令为 TiDB 数据库root
用户和口令。如果你修改过数据库的root
密码,则以修改后的密码为准,默认密码为空。 -
主页面显示 TiDB 集群中节点信息
注意:
登录数据库前,你需要安装 MySQL 客户端。
执行以下命令登录数据库:
{{< copyable "shell-regular" >}}
mysql -u root -h ${tidb_server_host_IP_address} -P 4000
其中,${tidb_server_host_IP_address}
是在初始化集群拓扑文件时为 tidb_servers
配置的 IP 地址之一,例如 10.0.1.7
。
输出下列信息表示登录成功:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 8.0.11-TiDB-v8.4.0 TiDB Server (Apache License 2.0) Community Edition, MySQL 8.0 compatible
Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
-
检查 TiDB 版本
{{< copyable "sql" >}}
select tidb_version()\G
预期结果输出:
*************************** 1. row *************************** tidb_version(): Release Version: v5.0.0 Edition: Community Git Commit Hash: 689a6b6439ae7835947fcaccf329a3fc303986cb Git Branch: HEAD UTC Build Time: 2020-05-28 11:09:45 GoVersion: go1.13.4 Race Enabled: false TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306 Check Table Before Drop: false 1 row in set (0.00 sec)
-
创建 PingCAP database
{{< copyable "sql" >}}
create database pingcap;
Query OK, 0 rows affected (0.10 sec)
{{< copyable "sql" >}}
use pingcap;
预期输出
Database changed
-
创建
tab_tidb
表{{< copyable "sql" >}}
CREATE TABLE `tab_tidb` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(20) NOT NULL DEFAULT '', `age` int(11) NOT NULL DEFAULT 0, `version` varchar(20) NOT NULL DEFAULT '', PRIMARY KEY (`id`), KEY `idx_age` (`age`));
预期输出
Query OK, 0 rows affected (0.11 sec)
-
插入数据
{{< copyable "sql" >}}
insert into `tab_tidb` values (1,'TiDB',5,'TiDB-v5.0.0');
预期输出
Query OK, 1 row affected (0.03 sec)
-
查看
tab_tidb
结果{{< copyable "sql" >}}
select * from tab_tidb;
预期输出
+----+------+-----+-------------+ | id | name | age | version | +----+------+-----+-------------+ | 1 | TiDB | 5 | TiDB-v5.0.0 | +----+------+-----+-------------+ 1 row in set (0.00 sec)
-
查看 TiKV store 状态、
store_id
、存储情况以及启动时间{{< copyable "sql" >}}
select STORE_ID,ADDRESS,STORE_STATE,STORE_STATE_NAME,CAPACITY,AVAILABLE,UPTIME from INFORMATION_SCHEMA.TIKV_STORE_STATUS;
预期输出
+----------+--------------------+-------------+------------------+----------+-----------+--------------------+ | STORE_ID | ADDRESS | STORE_STATE | STORE_STATE_NAME | CAPACITY | AVAILABLE | UPTIME | +----------+--------------------+-------------+------------------+----------+-----------+--------------------+ | 1 | 10.0.1.1:20160 | 0 | Up | 49.98GiB | 46.3GiB | 5h21m52.474864026s | | 4 | 10.0.1.2:20160 | 0 | Up | 49.98GiB | 46.32GiB | 5h21m52.522669177s | | 5 | 10.0.1.3:20160 | 0 | Up | 49.98GiB | 45.44GiB | 5h21m52.713660541s | +----------+--------------------+-------------+------------------+----------+-----------+--------------------+ 3 rows in set (0.00 sec)
-
退出
{{< copyable "sql" >}}
exit
预期输出
Bye