From e9bb629e3e33f0b869b9ba7b255d5015938da839 Mon Sep 17 00:00:00 2001 From: Enwei Date: Thu, 5 May 2022 16:50:55 +0800 Subject: [PATCH] Refine the format of JSON and add methods to change PD configuration (#8374) --- two-data-centers-in-one-city-deployment.md | 166 ++++++++++++--------- 1 file changed, 94 insertions(+), 72 deletions(-) diff --git a/two-data-centers-in-one-city-deployment.md b/two-data-centers-in-one-city-deployment.md index 5ced6853c113b..24fada8515331 100644 --- a/two-data-centers-in-one-city-deployment.md +++ b/two-data-centers-in-one-city-deployment.md @@ -88,68 +88,75 @@ cat rule.json [ { "group_id": "pd", - "id": "zone-east", - "start_key": "", - "end_key": "", - "role": "voter", - "count": 2, - "label_constraints": [ + "group_index": 0, + "group_override": false, + "rules": [ { - "key": "zone", - "op": "in", - "values": [ - "east" + "group_id": "pd", + "id": "zone-east", + "start_key": "", + "end_key": "", + "role": "voter", + "count": 2, + "label_constraints": [ + { + "key": "zone", + "op": "in", + "values": [ + "east" + ] + } + ], + "location_labels": [ + "zone", + "rack", + "host" ] - } - ], - "location_labels": [ - "zone", - "rack", - "host", - ] - }, - { - "group_id": "pd", - "id": "zone-west", - "start_key": "", - "end_key": "", - "role": "voter", - "count": 1, - "label_constraints": [ + }, { - "key": "zone", - "op": "in", - "values": [ - "west" + "group_id": "pd", + "id": "zone-west", + "start_key": "", + "end_key": "", + "role": "voter", + "count": 1, + "label_constraints": [ + { + "key": "zone", + "op": "in", + "values": [ + "west" + ] + } + ], + "location_labels": [ + "zone", + "rack", + "host" ] - } - ], - "location_labels": [ - "zone", - "rack", - "host" - ] - }, - { - "group_id": "pd", - "id": "zone-west", - "start_key": "", - "end_key": "", - "role": "learner", - "count": 1, - "label_constraints": [ + }, { - "key": "zone", - "op": "in", - "values": [ - "west" + "group_id": "pd", + "id": "zone-west", + "start_key": "", + "end_key": "", + "role": "learner", + "count": 1, + "label_constraints": [ + { + "key": "zone", + "op": "in", + "values": [ + "west" + ] + } + ], + "location_labels": [ + "zone", + "rack", + "host" ] } - ], - "location_labels": [ - "zone", - "rack", - "host" ] } ] @@ -165,24 +172,39 @@ pd-ctl config placement-rules rule-bundle save --in="rule.json" ### Enable the DR Auto-Sync mode -The replication mode is controlled by PD. When deploying a cluster, you can configure the replication mode in the PD configuration file. For example: - -{{< copyable "" >}} - -```toml -[replication-mode] -replication-mode = "dr-auto-sync" -[replication-mode.dr-auto-sync] -label-key = "zone" -primary = "east" -dr = "west" -primary-replicas = 2 -dr-replicas = 1 -wait-store-timeout = "1m" -wait-sync-timeout = "1m" -``` +The replication mode is controlled by PD. You can configure the replication mode in the PD configuration file using one of the following methods: + +- Method 1: Configure the PD configuration file, and then deploy a cluster. + + {{< copyable "" >}} + + ```toml + [replication-mode] + replication-mode = "dr-auto-sync" + [replication-mode.dr-auto-sync] + label-key = "zone" + primary = "east" + dr = "west" + primary-replicas = 2 + dr-replicas = 1 + wait-store-timeout = "1m" + wait-sync-timeout = "1m" + ``` + +- Method 2: If you have deployed a cluster, use pd-ctl commands to modify the configurations of PD. + + {{< copyable "" >}} + + ```shell + config set replication-mode dr-auto-sync + config set replication-mode dr-auto-sync label-key zone + config set replication-mode dr-auto-sync primary east + config set replication-mode dr-auto-sync dr west + config set replication-mode dr-auto-sync primary-replicas 2 + config set replication-mode dr-auto-sync dr-replicas 1 + ``` -In the configuration above: +Descriptions of configuration items: + `replication-mode` is the replication mode to be enabled. In the above example, it is set to `dr-auto-sync`. By default, the majority protocol is used. + `label-key` is used to distinguish different data centers and needs to match Placement Rules. In this example, the primary data center is "east" and the DR data center is "west".