Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disaster-recovery tutorial for HUB and DPS #156

Merged
merged 13 commits into from
Jun 27, 2024
69 changes: 69 additions & 0 deletions content/en/docs/configuration/mongodb-standby-tool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---

title: 'MongoDB Standby Tool'
description: 'MongoDB Standby Tool overview'
date: '2024-06-26'
categories: [configuration, deployment, disaster recovery]
keywords: [configuration, mongodb, disaster recovery]
weight: 11
---

MongoDB Standby Tool is used to reconfigure some of the MongoDB replica set members to be in a hidden and secondary state. For example, you can have a replica set where members are running in multiple regions for disaster recovery purposes.

## Docker Image

```bash
docker pull ghcr.io/plgd-dev/hub/mongodb-standby-tool:latest
```

## YAML Configuration

A configuration template is available at [tools/mongodb/standby-tool/config.yaml](https://github.com/plgd-dev/hub/blob/main/tools/mongodb/standby-tool/config.yaml).

### Logging

| Property | Type | Description | Default |
|----------|------|-------------|---------|
| `log.level` | string | `Logging enabled from this level.` | `"info"` |
| `log.encoding` | string | `Logging format. Supported values are: "json", "console".` | `"json"` |
| `log.stacktrace.enabled` | bool | `Log stacktrace.` | `false` |
| `log.stacktrace.level` | string | `Stacktrace from this level.` | `"warn"` |
| `log.encoderConfig.timeEncoder` | string | `Time format for logs. Supported values are: "rfc3339nano", "rfc3339".` | `"rfc3339nano"` |

## Mode

When the tool is started, it is in standby mode by default. In this mode, all members in the replica set are available, and members in the standby list are set as hidden, without votes, priority, and with a delay. All other members are reconfigured as secondary members. You can change the mode to active by setting the `mode` property to `active`. In this mode, standby members are set as secondary members with votes, priority, and without delay, and other members are set as hidden, without votes, priority, and with a delay.

| Property | Type | Description | Default |
|----------|------|-------------|---------|
| `mode` | string | `Set the running mode of the tool. Supported modes are "standby" and "active".` | `"standby"` |

### Replica Set

| Property | Type | Description | Default |
|----------|------|-------------|---------|
| `replicaSet.forceUpdate` | bool | `Update the replica set configuration with the force flag. More info [here](https://www.mongodb.com/docs/manual/reference/method/rs.reconfig/#std-label-rs-reconfig-method-force).` | `false` |
| `replicaSet.maxWaitsForReady` | int | `Set the maximum number of retries for members to be ready.` | `30` |
| `replicaSet.standby.members` | []string | `List of the MongoDB members in the replica set which are used as hidden (mode == "standby") or secondary (mode == "active") members. All other members are reconfigured to the opposite.` | `[]` |
| `replicaSet.standby.delays` | string | `Set the delay for syncing the hidden members with the secondary/primary members.` | `6m` |
| `replicaSet.secondary.priority` | int | `Used to configure the secondary members' priority.` | `10` |
| `replicaSet.secondary.votes` | int | `Set the number of votes for the secondary members.` | `1` |

### MongoDB

The tool uses the first member in the standby list (`replicaSet.standby.members`) to connect to MongoDB.

| Property | Type | Description | Default |
|----------|------|-------------|---------|
| `clients.storage.mongoDB.timeout` | string | `The maximum duration for the entire request operation.` | `"20s"` |
| `clients.storage.mongoDB.tls.enabled` | bool | `If true, use TLS for the connection.` | `false` |
| `clients.storage.mongoDB.tls.caPool` | []string | `File paths to the root certificates in PEM format. The file may contain multiple certificates.` | `[]` |
| `clients.storage.mongoDB.tls.keyFile` | string | `File path to the private key in PEM format.` | `""` |
| `clients.storage.mongoDB.tls.certFile` | string | `File path to the certificate in PEM format.` | `""` |
| `clients.storage.mongoDB.tls.useSystemCAPool` | bool | `If true, use the system certification pool.` | `false` |

{{< note >}}

Note that string types related to time (i.e. timeout, idleConnTimeout, expirationTime) are decimal numbers, each with an optional fraction and a unit suffix, such as "300ms", "1.5h", or "2h45m". Valid time units are "ns", "us", "ms", "s", "m", "h".

{{< /note >}}
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@ If your device is unable to connect to the Hub, follow these steps:

If your device can connect to the DPS service but is unable to retrieve certificates from the certificate authority or obtain an authorization code due to lack of trust, follow these steps:

- For the certificate authority, you need to append the certificate authority for that endpoint to the `global.authorizationCAPool` and set `deviceProvisioningService.enrollmentGroups[].hub.certificateAuthority.grpc.tls.caPool` to `/certs/extra/ca.crt` as described in the [Customize client certificates for DPS](/docs/deployment/device-provisioning-service/advanced#customize-client-certificates-for-dps) section. Alternatively, you can create an extra volume, mount it, and set the `deviceProvisioningService.enrollmentGroups[].hub.certificateAuthority.grpc.tls.caPool` field to the CA in that volume.
- For the certificate authority, you need to append the certificate authority for that endpoint to the `global.extraCAPool.authorization` and set `deviceProvisioningService.enrollmentGroups[].hub.certificateAuthority.grpc.tls.caPool` to `/certs/extra/ca.crt` as described in the [Customize client certificates for DPS](/docs/deployment/device-provisioning-service/advanced#customize-client-certificates-for-dps) section. Alternatively, you can create an extra volume, mount it, and set the `deviceProvisioningService.enrollmentGroups[].hub.certificateAuthority.grpc.tls.caPool` field to the CA in that volume.
- For the authorization provider, follow similar steps as for the certificate authority, but set `enrollmentGroups.[].hub.authorization.provider.http.tls.caPool`.
11 changes: 6 additions & 5 deletions content/en/docs/deployment/hub/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ used by plgd hub services. For including custom authorization CA pool into autho

```yaml
global:
# -- Custom CA certificate for authorization endpoint in PEM format
authorizationCAPool: |-
-----BEGIN CERTIFICATE-----
your custom authorization CA pool in PEM format
-----END CERTIFICATE-----
extraCAPool:
# -- Custom CA certificate for authorization endpoint in PEM format
authorization: |-
-----BEGIN CERTIFICATE-----
your custom authorization CA pool in PEM format
-----END CERTIFICATE-----
```

{{< warning >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ To back up the database, two approaches can be used:

![active-backup-replica-set](/docs/features/monitoring-and-diagnostics/static/disaster-recovery-active-replica-set-backup.drawio.svg)

The primary and standby cluster MongoDB members are in the same MongoDB replica set. The standby cluster members are configured as [hidden](https://www.mongodb.com/docs/manual/core/replica-set-hidden-member), [delayed](https://www.mongodb.com/docs/manual/core/replica-set-delayed-member/), and with [zero priority](https://www.mongodb.com/docs/manual/core/replica-set-priority-0-member/). When the primary cluster goes down, the standby cluster MongoDB members are promoted to standby state—one of them will become primary by administrator. After the primary is back online, the primary cluster members will be demoted to hidden. For switching back, the primary cluster members will be promoted to secondary MongoDB members and standby cluster members will be demoted. **This approach is supported by the plgd hub helm chart because it complies with the MongoDB Community Server license.** For setup instructions, please refer to this [tutorial]().
The primary and standby cluster MongoDB members are in the same MongoDB replica set. The standby cluster members are configured as [hidden](https://www.mongodb.com/docs/manual/core/replica-set-hidden-member), [delayed](https://www.mongodb.com/docs/manual/core/replica-set-delayed-member/), and with [zero priority](https://www.mongodb.com/docs/manual/core/replica-set-priority-0-member/). When the primary cluster goes down, the standby cluster MongoDB members are promoted to standby state—one of them will become primary by administrator. After the primary is back online, the primary cluster members will be demoted to hidden. For switching back, the primary cluster members will be promoted to secondary MongoDB members and standby cluster members will be demoted. **This approach is supported by the plgd hub helm chart because it complies with the MongoDB Community Server license.** For setup instructions, please refer to this [tutorial](/docs/tutorials/disaster-recovery-replica-set/).

* **Cluster to cluster synchronization**

Expand Down
Loading
Loading