验证集群运行状态

    检查集群状态的命令是 ,例如:

    预期结果输出:各节点 Status 状态信息为 Up 说明集群状态正常。

    本节介绍如何通过 TiDB Dashboard 和 Grafana 检查集群状态。

    1. 通过 {pd-ip}:{pd-port}/dashboard 登录 TiDB Dashboard,登录用户和口令为 TiDB 数据库 root 用户和口令。如果你修改过数据库的 root 密码,则以修改后的密码为准,默认密码为空。

    2. 主页面显示 TiDB 集群中节点信息

      TiDB-Dashboard-status

    • 通过 {Grafana-ip}:3000 登录 Grafana 监控,默认用户名及密码为 admin/admin

    • 点击 Overview 监控页面检查 TiDB 端口和负载监控信息。

    注意

    登录数据库前,你需要安装 MySQL 客户端。

    执行以下命令登录数据库:

    1. mysql -u root -h ${tidb_server_host_IP_address} -P 4000

    其中,${tidb_server_host_IP_address} 是在初始化集群拓扑文件时为 tidb_servers 配置的 IP 地址之一,例如 10.0.1.7

    输出下列信息表示登录成功:

    1. Welcome to the MySQL monitor. Commands end with ; or \g.
    2. Your MySQL connection id is 3
    3. Server version: 5.7.25-TiDB-v5.0.0 TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible
    4. Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
    5. Oracle is a registered trademark of Oracle Corporation and/or its
    6. affiliates. Other names may be trademarks of their respective
    7. owners.
    • 创建 PingCAP database

      1. create database pingcap;
      1. use pingcap;

      预期输出

      1. Database changed
      1. CREATE TABLE `tab_tidb` (
      2. `id` int(11) NOT NULL AUTO_INCREMENT,
      3. `name` varchar(20) NOT NULL DEFAULT '',
      4. `age` int(11) NOT NULL DEFAULT 0,
      5. `version` varchar(20) NOT NULL DEFAULT '',
      6. KEY `idx_age` (`age`));

      预期输出

      1. Query OK, 0 rows affected (0.11 sec)
    • 插入数据

      1. insert into `tab_tidb` values (1,'TiDB',5,'TiDB-v5.0.0');

      预期输出

    • 查看 tab_tidb 结果

      1. select * from tab_tidb;

      预期输出

      1. +----+------+-----+-------------+
      2. | id | name | age | version |
      3. +----+------+-----+-------------+
      4. | 1 | TiDB | 5 | TiDB-v5.0.0 |
      5. +----+------+-----+-------------+
      6. 1 row in set (0.00 sec)
    • 查看 TiKV store 状态、store_id、存储情况以及启动时间

      1. select STORE_ID,ADDRESS,STORE_STATE,STORE_STATE_NAME,CAPACITY,AVAILABLE,UPTIME from INFORMATION_SCHEMA.TIKV_STORE_STATUS;

      预期输出

      1. +----------+--------------------+-------------+------------------+----------+-----------+--------------------+
      2. | STORE_ID | ADDRESS | STORE_STATE | STORE_STATE_NAME | CAPACITY | AVAILABLE | UPTIME |
      3. +----------+--------------------+-------------+------------------+----------+-----------+--------------------+
      4. | 1 | 10.0.1.1:20160 | 0 | Up | 49.98GiB | 46.3GiB | 5h21m52.474864026s |
      5. | 4 | 10.0.1.2:20160 | 0 | Up | 49.98GiB | 46.32GiB | 5h21m52.522669177s |
      6. | 5 | 10.0.1.3:20160 | 0 | Up | 49.98GiB | 45.44GiB | 5h21m52.713660541s |
      7. +----------+--------------------+-------------+------------------+----------+-----------+--------------------+
      8. 3 rows in set (0.00 sec)