How to Check Which TiKV Instances a Region is Distributed On

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 如何看1个region 分布在哪几个tikv上

| username: Raymond

May I ask how to see which TiKV instances a region is distributed on, and is it possible to know the IP and port of the TiKV instances?

| username: TiDBer_wTKU9jv6 | Original post link

Database: INFORMATION_SCHEMA
Tables: TIKV_REGION_PEERS, TIKV_REGION_STATUS, TIKV_STORE_STATUS
You can join the above three tables to get the required information.
For example, you can use the following query and add some other conditions if needed:

select r.REGION_ID, r.IS_LEARNER, r.IS_LEADER, s.ADDRESS 
from TIKV_REGION_PEERS r, TIKV_STORE_STATUS s 
where r.STORE_ID = s.STORE_ID 
limit 2;
| username: cs58_dba | Original post link

Generally, the pd-ctl tool is used. Refer to the official documentation: PD Control 使用说明 | PingCAP 文档中心

| username: ddhe9527 | Original post link

The correspondence information between region and store is in the TIKV_REGION_PEERS table.

| username: banana_jian | Original post link

Executing the region command in pdctl

>> region 2
{
  "id": 2,
  "start_key": "7480000000000000FF1D00000000000000F8",
  "end_key": "7480000000000000FF1F00000000000000F8",
  "epoch": {
    "conf_ver": 1,
    "version": 15
  },
  "peers": [
    {
      "id": 40,
      "store_id": 3
    }
  ],
  "leader": {
    "id": 40,
    "store_id": 3
  },
  "written_bytes": 0,
  "read_bytes": 0,
  "written_keys": 0,
  "read_keys": 0,
  "approximate_size": 1,
  "approximate_keys": 0
}
| username: ealam_小羽 | Original post link

  1. SHOW TABLE REGIONS: View the TiKV Leader node id of the table’s region

    SHOW TABLE REGIONS | PingCAP 文档中心
  2. INFORMATION_SCHEMA.tikv_store_status: View node information

    TIKV_STORE_STATUS | PingCAP 文档中心
| username: system | Original post link

This topic was automatically closed 1 minute after the last reply. No new replies are allowed.