Skip to content

Commit

Permalink
Refine the format of JSON and add methods to change PD configuration (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
en-jin19 authored May 5, 2022
1 parent ab96612 commit e9bb629
Showing 1 changed file with 94 additions and 72 deletions.
166 changes: 94 additions & 72 deletions two-data-centers-in-one-city-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
]
Expand All @@ -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".
Expand Down

0 comments on commit e9bb629

Please sign in to comment.