Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 存储历史数据的tidb我可以吧副本设置成1吗,不要占用太多空间
I want to store historical data on a local server, but the disk space is not enough. Can I set the replica to 1, keeping only one copy of the data to save a lot of space? Will it work? Are there any other impacts?
It works, no significant impact, just reduced data security with 1 replica.
Not sure if it works in version 5.0, but in newer versions, you can modify it with:
set config pd replication.max-replicas=1;
=1 means there is only one copy of the data. I set it to =2. Version 5.0.0 should be fine, right? One leader and one replica. A total of two copies of the data.
I haven’t tested 2, but I have tried 1.
It can be set to a single replica.
Okay, I am just worried about potential issues, so I want to set it to 2.
How many physical machines do you have?
My test database is set to 1, with only one kv.
2.9T, 3 virtual machines.
If all replicas are on a single physical machine, having multiple replicas doesn’t make much sense.
Two sets of TiDB. One is 2.9T and the other is 17T. The three virtual machines for the 2.9T backup files have already been allocated 3T of space. Let’s set it to 2 replicas. The other one will be set to 1 replica.
Should I directly execute the modification in the command window? I checked after executing it, but there was no change.
Found the issue. Placement rules are enabled by default in versions 5.0.0 and above. You need to disable them to modify replicas.
Is it meaningful to change 2? If one part is broken, your database should be unusable as well…
If one leader or one replica fails, can the other one still be used?
If there are 3 virtual machines with 2 replicas and one of them fails, it might become unusable. If there are 9 virtual machines with 2 replicas and one of them fails, it should still be usable, right? The replicas should be distributed across approximately 4.5 machines.
Isn’t it better to use MySQL master-slave for 2.9T?
It was originally TiDB. To restore it, just use BR and stick with TiDB; I don’t want to deal with migration. There’s also a 17TB one.
If one of the two replicas is broken, the cluster will be unusable and unable to elect a leader. Having two replicas is meaningless.