Can I set the replica count to 1 for TiDB storing historical data to save space?

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

Original topic: 存储历史数据的tidb我可以吧副本设置成1吗,不要占用太多空间

| username: 舞动梦灵

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?

| username: zhanggame1 | Original post link

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;

| username: 舞动梦灵 | Original post link

=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.

| username: zhanggame1 | Original post link

I haven’t tested 2, but I have tried 1.

| username: andone | Original post link

It can be set to a single replica.

| username: 舞动梦灵 | Original post link

Okay, I am just worried about potential issues, so I want to set it to 2.

| username: zhanggame1 | Original post link

How many physical machines do you have?

| username: 像风一样的男子 | Original post link

My test database is set to 1, with only one kv.

| username: 舞动梦灵 | Original post link

2.9T, 3 virtual machines.

| username: zhanggame1 | Original post link

If all replicas are on a single physical machine, having multiple replicas doesn’t make much sense.

| username: 舞动梦灵 | Original post link

:joy: 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.

| username: zhanggame1 | Original post link

No problem with that.

| username: 舞动梦灵 | Original post link

Should I directly execute the modification in the command window? I checked after executing it, but there was no change.

| username: 舞动梦灵 | Original post link

Found the issue. Placement rules are enabled by default in versions 5.0.0 and above. You need to disable them to modify replicas.

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

Is it meaningful to change 2? If one part is broken, your database should be unusable as well…

| username: 舞动梦灵 | Original post link

If one leader or one replica fails, can the other one still be used?

| username: 舞动梦灵 | Original post link

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.

| username: xingzhenxiang | Original post link

Isn’t it better to use MySQL master-slave for 2.9T?

| username: 舞动梦灵 | Original post link

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.

| username: 像风一样的男子 | Original post link

If one of the two replicas is broken, the cluster will be unusable and unable to elect a leader. Having two replicas is meaningless.