TiDB Scaling Down: Reducing Servers Without Decreasing the Number of Region Replicas?

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

Original topic: TIDB 缩容 只减少服务器,但是不减少 Regoin 副本数?

| username: TiDBer_JUi6UvZm

[TiDB Usage Environment] Production Environment / Testing / POC
[TiDB Version]
[Reproduction Path] What operations were performed when the issue occurred
[Encountered Issue: Issue Phenomenon and Impact]
[Resource Configuration] Go to TiDB Dashboard - Cluster Info - Hosts and take a screenshot of this page
[Attachments: Screenshots / Logs / Monitoring]

When scaling down with the following command, the current TIKV’s Regions will migrate to other TIKVs, right? Suppose there were originally 3 servers with three Region replicas. Now, by using the scale-down command to reclaim one server, after executing the following command and waiting for PD to complete the data scheduling, will there still be 3 Region replicas, but the servers will be reduced to two?

tiup cluster scale-in prod-cluster -N 172.16.5.140:20160

| username: TiDBer_ivan0927 | Original post link

Yes, after executing the scale-in command, PD will be responsible for migrating the Regions originally deployed on the node to be scaled in, ensuring data reliability and high availability. Assuming that each Region had three replicas before executing the scale-in command and these replicas were distributed across different servers, after scaling in, PD will ensure that each Region still maintains three replicas by migrating one of the replicas to other nodes. Therefore, even though the number of servers decreases after executing the scale-in command, each Region will still maintain its original number of replicas.

| username: TiDBer_QYr0vohO | Original post link

After scaling down from 3 TiKV servers to 1, it seems there might be issues. You can try it in a test environment because the default is 3 replicas, and the number of TiKV servers needs to be greater than or equal to the number of replicas.

| username: TiDBer_jYQINSnf | Original post link

Reducing from 3 nodes to 2 nodes is not possible, as it does not meet the minimum replica count.

| username: tidb菜鸟一只 | Original post link

Originally, there were 3 servers with three region replicas. Now, by using the scale-in command to reclaim one server, it can’t be scaled in because you can’t place 3 replicas on 2 servers, unless one of the servers is expanded with an additional TiKV node…

| username: TiDBer_JUi6UvZm | Original post link

I believe my understanding should be correct. TiDB splits the data into very small pieces (96MB-144MB), and it is automatically scheduled by PD, so it should allow the number of servers to be less than the number of Region replicas. Let’s first sort out the issue and then apply for an environment to test it.

| username: Daniel-W | Original post link

You can check the official documentation for an introduction on this aspect.

| username: DBAER | Original post link

Ensure at least 3 replicas.

| username: terry0219 | Original post link

You need to replace the machine, right? It is recommended to first expand with one machine and then shrink.

| username: TiDBer_RjzUpGDL | Original post link

At least three replicas

| username: Kamner | Original post link

The command can be executed successfully, but the scaled-down node will remain in the Pending Offline state until a new TiKV node receives the third replica and starts migrating data.

At least 3 Raft replicas are required to ensure normal voting.

| username: wangkk2024 | Original post link

At least 3 replicas

| username: 这里介绍不了我 | Original post link

You can try adding a node first and then replacing it. At this point, you can check the monitoring to observe any changes in the number of Regions.

| username: 舞动梦灵 | Original post link

Replicas and nodes are not the same thing. How could you understand reducing servers as reducing replicas? If TiKV has 30 servers, does that mean there are 30 replicas? By default, there are 3 replicas, which are evenly distributed across all TiKV nodes. Regardless of how many nodes you have, if there are fewer than 3, it won’t store well, and you’ll basically have to change the number of replicas to 1.

| username: TiDBer_JUi6UvZm | Original post link

I’ll test it myself and see.

| username: dba远航 | Original post link

The number of replicas must be met.

| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.