How to Set the Number of Region Replicas When Expanding TiKV

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

Original topic: tikv扩容 region副本 个数如何设置

| username: TiDBer_31oE6j2g

Regarding TiKV expansion, how to set the number of region replicas? The main requirement is to add a new TiKV node for expansion without the data replication feature.

| username: WalterWj | Original post link

Replica refers to how many copies of data are stored in TiKV, with the default being 3.
TiKV scaling refers to the number of servers storing the data.

Apart from the number of TiKV nodes needing to be >= the number of replicas, there isn’t much other correlation.

| username: Kongdom | Original post link

:rofl: If you don’t want data replicas, set the number of replicas to 1, but then it won’t be highly available.

Can the number of replicas for each region be configured? How to adjust it?

Yes, currently only the global number of replicas can be adjusted. When PD starts for the first time, it reads the configuration file (conf/pd.yml) and uses the max-replicas configuration. After that, modifications need to be made using the pd-ctl configuration command config set max-replicas $num. After configuration, you can check the effective configuration using config show all. Adjustments will not affect the business and will be added in the background. Note that the total number of TiKV instances must always be greater than or equal to the number of replicas set. For example, 3 replicas require at least 3 TiKV instances. Before increasing the number of replicas, you need to estimate the additional storage requirements. For detailed usage of pd-ctl, refer to PD Control User Guide.

| username: h5n1 | Original post link

You can try adjusting the number of replicas with pd-ctl config set max-replicas=1. It’s fine for testing purposes, but for production systems, a minimum of 3 replicas is recommended. TiDB uses replicas for all data types.

| username: TiDBer_31oE6j2g | Original post link

Thank you, that’s the answer I wanted. :handshake:

| username: Kongdom | Original post link

:handshake: :handshake: :handshake: