diff --git a/docs/how_to/query.md b/docs/how_to/query.md index 7dfecab03e..8ec164a6b6 100644 --- a/docs/how_to/query.md +++ b/docs/how_to/query.md @@ -25,7 +25,7 @@ All namespaces that you wish to query from must be configured when [setting up M ### etcd -The configuration file linked above uses an embedded etcd cluster, which is fine for development purposes. However, if you wish to use this in production, you will want an external etcd cluster. +The configuration file linked above uses an embedded etcd cluster, which is fine for development purposes. However, if you wish to use this in production, you will want an [external etcd](../operational_guide/etcd.md) cluster. diff --git a/docs/operational_guide/etcd.md b/docs/operational_guide/etcd.md new file mode 100644 index 0000000000..f348cc7f03 --- /dev/null +++ b/docs/operational_guide/etcd.md @@ -0,0 +1,83 @@ +# etcd + +The M3 stack leverages `etcd` as a distributed key-value storage to: + +1. Update cluster configuration in realtime +2. Manage placements for our distributed / sharded tiers like M3DB and M3Aggregator +3. Perform leader-election in M3Aggregator + +and much more! + +## Overview + +`M3DB` ships with support for running embedded `etcd` (called `seed nodes`), and while this is convenient for testing and development, we don't recommend running with this setup in production. + +Both `M3` and `etcd` are complex distributed systems, and trying to operate both within the same binary is challenging and dangerous for production workloads. + +Instead, we recommend running an external `etcd` cluster that is isolated from the `M3` stack so that performing operations like node adds, removes, and replaces are easier. + +While M3 relies on `etcd` to provide strong consistency, the perations we use it for are all low-throughput so you should be able to operate a very low maintenance `etcd` cluster. [A 3-node setup for high availability](https://github.com/etcd-io/etcd/blob/v3.3.11/Documentation/faq.md#what-is-failure-tolerance) should be more than sufficient for most workloads. + +## Configuring an External etcd Cluster + +### M3DB + +Most of our documentation demonstrates how to run `M3DB` with embedded etcd nodes. Once you're ready to switch to an external `etcd` cluster, all you need to do is modify the `M3DB` config to remove the `seedNodes` field entirely and then change the `endpoints` under `etcdClusters` to point to your external `etcd` nodes instead of the `M3DB` seed nodes. + +For example this portion of the config + +```yaml +config: + service: + env: default_env + zone: embedded + service: m3db + cacheDir: /var/lib/m3kv + etcdClusters: + - zone: embedded + endpoints: + - http://m3db_seed1:2379 + - http://m3db_seed2:2379 + - http://m3db_seed3:2379 + seedNodes: + initialCluster: + - hostID: m3db_seed1 + endpoint: http://m3db_seed1:2380 + - hostID: m3db_seed2 + endpoint: http://m3db_seed2:2380 + - hostID: m3db_seed3 + endpoint: http://m3db_seed3:2380 +``` + +would become + +```yaml +config: + service: + env: default_env + zone: embedded + service: m3db + cacheDir: /var/lib/m3kv + etcdClusters: + - zone: embedded + endpoints: + - http://external_etcd1:2379 + - http://external_etcd2:2379 + - http://external_etcd3:2379 +``` + +**Note**: `M3DB` placements and namespaces are stored in `etcd` so if you want to switch to an external `etcd` cluster you'll need to recreate all your placements and namespaces. You can do this manually or use `etcdctl`'s [Mirror Maker](https://github.com/etcd-io/etcd/blob/v3.3.11/etcdctl/doc/mirror_maker.md) functionality. + +### M3Coordinator + +`M3Coordinator` does not run embedded `etcd`, so configuring it to use an external `etcd` cluster is simple. Just replace the `endpoints` under `etcdClusters` in the YAML config to point to your external `etcd` nodes instead of the `M3DB` seed nodes. See the `M3DB` example above for a detailed before/after comparison of the YAML config. + +## etcd Operations + +### Embedded etcd + +If you're running `M3DB seed nodes` with embedded `etcd` (which we do not recommend for production workloads) and need to perform a node add/replace/remove then follow our [placement configuration guide](./placement_configuration.md) and pay special attention to follow the special instructions for `seed nodes`. + +### External etcd + +Just follow the instructions in the [etcd docs.](https://github.com/etcd-io/etcd/tree/master/Documentation) \ No newline at end of file diff --git a/docs/operational_guide/placement_configuration.md b/docs/operational_guide/placement_configuration.md index e2a6760da2..9b54441d00 100644 --- a/docs/operational_guide/placement_configuration.md +++ b/docs/operational_guide/placement_configuration.md @@ -139,7 +139,7 @@ After sending the delete command you will need to wait for the M3DB cluster to r #### Adding / Removing Seed Nodes -If you find yourself adding or removing etcd seed nodes then we highly recommend setting up an external etcd cluster, as +If you find yourself adding or removing etcd seed nodes then we highly recommend setting up an [external etcd](../etcd.md) cluster, as the overhead of operating two stateful systems at once is non-trivial. As this is not a recommended production setup, this section is intentionally brief. diff --git a/mkdocs.yml b/mkdocs.yml index 831b4c601a..b6b3b81494 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -71,6 +71,7 @@ pages: - "Namespace Configuration": "operational_guide/namespace_configuration.md" - "Bootstrapping": "operational_guide/bootstrapping.md" - "Kernel Configuration": "operational_guide/kernel_configuration.md" + - "etcd": "operational_guide/etcd.md" - "Integrations": - "Prometheus": "integrations/prometheus.md" - "Graphite": "integrations/graphite.md"