Check Cluster Status

After a TiDB cluster is deployed, you need to check whether the cluster runs normally. This document introduces how to check the cluster status using TiUP commands, TiDB Dashboard and Grafana, and how to log into the TiDB database to perform simple SQL operations.

Check the TiDB cluster status

This section describes how to check the TiDB cluster status using TiUP commands, TiDB Dashboard, and Grafana.

Use TiUP

Use the tiup cluster display <cluster-name> command to check the cluster status. For example:

  1. tiup cluster display tidb-test

Expected output: If the Status information of each node is Up, the cluster runs normally.

Use TiDB Dashboard

  1. Log in to TiDB Dashboard at ${pd-ip}:${pd-port}/dashboard. The username and password is the same as that of the TiDB root user. If you have modified the root password, enter the modified password. The password is empty by default.

    TiDB-Dashboard

  2. The home page displays the node information in the TiDB cluster.

    TiDB-Dashboard-status

Use Grafana

  1. Log in to the Grafana monitoring at ${Grafana-ip}:3000. The default username and password are both admin.

  2. To check the TiDB port status and load monitoring information, click Overview.

    Grafana-overview

Log in to the database and perform simple operations

Verify Cluster Status - 图4

Note

Install the MySQL client before you log in to the database.

Log in to the database by running the following command:

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

${tidb_server_host_IP_address} is one of the IP addresses set for tidb_servers when you initialize the cluster topology file, such as 10.0.1.7.

The following information indicates successful login:

  1. Welcome to the MySQL monitor. Commands end with ; or \g.
  2. Your MySQL connection id is 3
  3. Server version: 8.0.11-TiDB-v8.1.0 TiDB Server (Apache License 2.0) Community Edition, MySQL 8.0 compatible
  4. Copyright (c) 2000, 2023, 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.
  8. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Database operations

  • Check the version of TiDB:

    1. select tidb_version()\G

    Expected output:

    1. *************************** 1. row ***************************
    2. tidb_version(): Release Version: v5.0.0
    3. Edition: Community
    4. Git Commit Hash: 689a6b6439ae7835947fcaccf329a3fc303986cb
    5. Git Branch: HEAD
    6. UTC Build Time: 2020-05-28 11:09:45
    7. GoVersion: go1.13.4
    8. Race Enabled: false
    9. TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
    10. Check Table Before Drop: false
    11. 1 row in set (0.00 sec)
  • Create a database named pingcap:

    1. create database pingcap;

    Expected output:

    1. Query OK, 0 rows affected (0.10 sec)

    Switch to the pingcap database:

    1. use pingcap;

    Expected output:

    1. Database changed
  • Create a table named tab_tidb:

    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. PRIMARY KEY (`id`),
    7. KEY `idx_age` (`age`));

    Expected output:

    1. Query OK, 0 rows affected (0.11 sec)
  • Insert data:

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

    Expected output:

    1. Query OK, 1 row affected (0.03 sec)
  • View the entries in tab_tidb:

    1. select * from tab_tidb;

    Expected output:

    1. +----+------+-----+-------------+
    2. | id | name | age | version |
    3. +----+------+-----+-------------+
    4. | 1 | TiDB | 5 | TiDB-v5.0.0 |
    5. +----+------+-----+-------------+
    6. 1 row in set (0.00 sec)
  • View the store state, store_id, capacity, and uptime of TiKV:

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

    Expected output:

    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)
  • Exit TiDB:

    1. exit

    Expected output:

    1. Bye