Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 查看tidb每个 region有几个副本
[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version]
[Reproduction Path] I deployed three KV storage nodes. To save disk space in the testing environment, I set max-replicas to 1.
[Encountered Problem: Problem Phenomenon and Impact] I want to check how many replicas each region actually has to verify if my setting of max-replicas to 1 has taken effect.
[Resource Configuration]
[Attachment: Screenshot/Log/Monitoring]
Setting max-replicas to 1 means there is only one replica. For example, my test cluster is set to 1.
To check the number of replicas for each Region in TiDB, you can use TiDB’s official tool, TiDB Lightning, which provides the check_region_replica.py
script to check the number of replicas for each Region.
The specific steps are as follows:
- Run the following command in the command line to install TiDB Lightning:
curl https://raw.githubusercontent.com/pingcap/tidb-lightning/master/scripts/run_lightning.sh | bash -s -- --tidb-server <TiDB address> --binlog <binlog address> --deploy-mode=standalone --no-start
- After installation, switch to the bin directory of TiDB Lightning:
cd lightning-bin
- Run the
check_region_replica.py
script:
./check_region_replica.py --pd "http://<PD address>"
Here, <PD address>
refers to the address of the PD Server, which needs to be replaced with the actual address.
After executing the above commands, the script will output detailed information such as the ID of each Region, the number of replicas, and the TiKV nodes where the replicas are located.
tiup ctl:v6.5.0 tidb table -d test -t history_wti_alarm_utc regions --host 192.168.2.21
For example, all Regions with a replica count not equal to 3:
region --jq=".regions[] | {id: .id, peer_stores: [.peers[].store_id] | select(length != 3)}"
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.