Skip to content

Commit

Permalink
TiDB Binlog in k8s management documentation (pingcap#1440)
Browse files Browse the repository at this point in the history
* Add maintain TiDB Binlog documentations to facilitate the Binlog management in k8s

Signed-off-by: Aylei <rayingecho@gmail.com>

* Update toc

Signed-off-by: Aylei <rayingecho@gmail.com>

* Fix broken link

Signed-off-by: Aylei <rayingecho@gmail.com>

* Apply suggestions from code review

Co-Authored-By: Calvin Weng <wenghao@pingcap.com>

* Address review comments

Signed-off-by: Aylei <rayingecho@gmail.com>

* Apply suggestions from code review

Co-Authored-By: Calvin Weng <wenghao@pingcap.com>

* Apply changes to dev folder

Signed-off-by: Aylei <rayingecho@gmail.com>

* Apply changes

Signed-off-by: Aylei <rayingecho@gmail.com>

* Apply suggestions from code review

Co-Authored-By: Tennix <tennix@users.noreply.github.com>

* Apply review comments to 3.0

* Update default configuration of drainer

Signed-off-by: Aylei <rayingecho@gmail.com>
  • Loading branch information
aylei authored and tennix committed Aug 25, 2019
1 parent 1399b1c commit 2b7d600
Show file tree
Hide file tree
Showing 10 changed files with 324 additions and 26 deletions.
2 changes: 2 additions & 0 deletions dev/TOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@
- [Backup and Restore](tidb-in-kubernetes/maintain/backup-and-restore.md)
- [Collect Logs](tidb-in-kubernetes/maintain/log-collecting.md)
- [Automatic Failover](tidb-in-kubernetes/maintain/auto-failover.md)
- [TiDB Binlog](tidb-in-kubernetes/maintain/tidb-binlog.md)
- [Scale](tidb-in-kubernetes/scale-in-kubernetes.md)
+ Upgrade
- [TiDB Cluster](tidb-in-kubernetes/upgrade/tidb-cluster.md)
Expand All @@ -360,6 +361,7 @@
- [TiDB Cluster](tidb-in-kubernetes/reference/configuration/tidb-cluster.md)
- [Backup](tidb-in-kubernetes/reference/configuration/backup.md)
- [Local PV](tidb-in-kubernetes/reference/configuration/local-pv.md)
- [TiDB Drainer](tidb-in-kubernetes/reference/configuration/tidb-drainer.md)
+ Tools
- [tkctl](tidb-in-kubernetes/reference/tools/tkctl.md)
- [Tools in Kubernetes](tidb-in-kubernetes/reference/tools/in-kubernetes.md)
Expand Down
2 changes: 1 addition & 1 deletion dev/tidb-in-kubernetes/deploy/general-kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This document describes how to deploy a TiDB cluster on general Kubernetes.
## Prerequisites

- [Deploy TiDB Operator](tidb-in-kubernetes/deploy/tidb-operator.md);
- [Install Helm](tidb-in-kubernetes/reference/tools/in-kubernetes.md) and configure it with the official PingCAP chart.
- [Install Helm](tidb-in-kubernetes/reference/tools/in-kubernetes.md#use-helm) and configure it with the official PingCAP chart.

## Configure TiDB cluster

Expand Down
13 changes: 1 addition & 12 deletions dev/tidb-in-kubernetes/maintain/backup-and-restore.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,4 @@ The `pingcap/tidb-backup` helm chart helps restore a TiDB cluster using backup d
Incremental backup uses [TiDB Binlog](/reference/tidb-binlog-overview.md) to collect binlog data from TiDB and provide real-time backup and replication to downstream platforms.
Incremental backup is disabled in the TiDB cluster by default. To create a TiDB cluster with incremental backup enabled or enable incremental backup in existing TiDB cluster, modify the `values.yaml` file:
* Set `binlog.pump.create` to `true`.
* Set `binlog.drainer.create` to `true`.
* Set `binlog.pump.storageClassName` and `binlog.drainer.storageClassName` to an available `storageClass` in your Kubernetes cluster.
* Set `binlog.drainer.destDBType` to your desired downstream storage as needed, which is explained in details below.
Incremental backup supports three types of downstream storage:
* PersistenceVolume: the default downstream storage. You can consider configuring a large PV for `drainer` (by modifying `binlog.drainer.storage`) in this case.
* MySQL compatible databases: enabled by setting `binlog.drainer.destDBType` to `mysql`. Meanwhile, you must configure the address and credential of the target database in `binlog.drainer.mysql`.
* Apache Kafka: enabled by setting `binlog.drainer.destDBType` to `kafka`. Meanwhile, you must configure the zookeeper address and Kafka address of the target cluster in `binlog.drainer.kafka`.
For the detailed guide of maintaining TiDB Binlog in Kubernetes, refer to [TiDB Binlog](/tidb-in-kubernetes/maintain/tidb-binlog.md).
112 changes: 112 additions & 0 deletions dev/tidb-in-kubernetes/maintain/tidb-binlog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
title: Maintain TiDB Binlog
summary: Learn how to maintain TiDB Binlog of a TiDB cluster in Kubernetes.
category: how-to
---

# Maintain TiDB Binlog

This document describes how to maintain [TiDB Binlog](reference/tidb-binlog-overview.md) of a TiDB cluster in Kubernetes.

## Prerequisites

- [Deploy TiDB Operator](tidb-in-kubernetes/deploy/tidb-operator.md);
- [Install Helm](tidb-in-kubernetes/reference/tools/in-kubernetes.md#use-helm) and configure it with the official PingCAP chart.

## Enable TiDB Binlog of a TiDB cluster

TiDB Binlog is disabled in the TiDB cluster by default. To create a TiDB cluster with TiDB Binlog enabled, or enable TiDB Binlog in an existing TiDB cluster:

1. Modify the `values.yaml` file as described below:

* Set `binlog.pump.create` to `true`.
* Set `binlog.drainer.create` to `true`.
* Set `binlog.pump.storageClassName` and `binlog.drainer.storageClassName` to an available `storageClass` in your Kubernetes cluster.
* Set `binlog.drainer.destDBType` to your desired downstream storage as needed, which is explained in details below.

TiDB Binlog supports three types of downstream storage:

* PersistenceVolume: the default downstream storage. You can configure a large PV for `drainer` (by modifying `binlog.drainer.storage`) in this case.
* MySQL compatible databases: enabled by setting `binlog.drainer.destDBType` to `mysql`. Meanwhile, you must configure the address and credential of the target database in `binlog.drainer.mysql`.
* Apache Kafka: enabled by setting `binlog.drainer.destDBType` to `kafka`. Meanwhile, you must configure the zookeeper address and Kafka address of the target cluster in `binlog.drainer.kafka`.

2. Create a new TiDB cluster or update an existing cluster:

* Create a new TiDB cluster with TiDB Binlog enabled:

{{< copyable "shell-regular" >}}

```shell
helm install pingcap/tidb-cluster --name=<release-name> --namespace=<namespace> --version=<chart-version> -f <values-file>
```

* Update an existing TiDB cluster to enable TiDB Binlog:

{{< copyable "shell-regular" >}}

```shell
helm upgrade <release-name> pingcap/tidb-cluster --version=<chart-version> -f <values-file>
```

## Deploy multiple drainers

By default, only one downstream drainer is created. You can install the `tidb-drainer` Helm chart to deploy more drainers for a TiDB cluster, as described below:

1. Make sure that the PingCAP Helm repository is up to date:

{{< copyable "shell-regular" >}}

```shell
helm repo update
```

{{< copyable "shell-regular" >}}

```shell
helm search tidb-drainer -l
```

2. Get the default `values.yaml` file to facilitate customization:

```shell
helm inspect values pingcap/tidb-drainer --version=<chart-version> > values.yaml
```

3. Modify the `values.yaml` file to specify the source TiDB cluster and the downstream database of the drainer. Here is an example:

```yaml
clusterName: example-tidb
clusterVersion: v3.0.0
storageClassName: local-storage
storage: 10Gi
config: |
detect-interval = 10
[syncer]
worker-count = 16
txn-batch = 20
disable-dispatch = false
ignore-schemas = "INFORMATION_SCHEMA,PERFORMANCE_SCHEMA,mysql"
safe-mode = false
db-type = "tidb"
[syncer.to]
host = "slave-tidb"
user = "root"
password = ""
port = 4000
```

The `clusterName` and `clusterVersion` must match the desired source TiDB cluster.

For complete configuration details, refer to [TiDB Binlog Drainer Configurations in Kubernetes](tidb-in-kubernetes/reference/configuration/tidb-drainer.md).

4. Deploy the drainer:

{{< copyable "shell-regular" >}}

```shell
helm install pingcap/tidb-drainer --name=<release-name> --namespace=<namespace> --version=<chart-version> -f values.yaml
```

> **Note:**
>
> This chart must be installed to the same namespace as the source TiDB cluster.
46 changes: 46 additions & 0 deletions dev/tidb-in-kubernetes/reference/configuration/tidb-drainer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: TiDB Binlog Drainer Configurations in Kubernetes
summary: Learn the configurations of a TiDB Binlog Drainer in Kubernetes.
category: reference
---

# TiDB Binlog Drainer Configurations in Kubernetes

This document introduces the configuration parameters for a TiDB Binlog drainer in Kubernetes.

## Configuration parameters

The following table contains all configuration parameters available for the `tidb-drainer` chart. Refer to [Use Helm](tidb-in-kubernetes/reference/tools/in-kubernetes.md#use-helm) to learn how to configure these parameters.

| Parameter | Description | Default Value |
| :----- | :---- | :----- |
| `clusterName` | The name of the source TiDB cluster | `demo` |
| `clusterVersion` | The version of the source TiDB cluster | `v3.0.1` |
| `baseImage` | The base image of TiDB Binlog | `pingcap/tidb-binlog` |
| `imagePullPolicy` | The pulling policy of the image | `IfNotPresent` |
| `logLevel` | The log level of the drainer process | `info` |
| `storageClassName` | `storageClass` used by the drainer. `storageClassName` refers to a type of storage provided by the Kubernetes cluster, which might map to a level of service quality, a backup policy, or to any policy determined by the cluster administrator. Detailed reference: [storage-classes](https://kubernetes.io/docs/concepts/storage/storage-classes) | `local-storage` |
| `storage` | The storage limit of the drainer Pod. Note that you should set a larger size if `db-type` is set to `pb` | `10Gi` |
| `disableDetect` | Determines whether to disable casualty detection | `false` |
| `initialCommitTs` | Used to initialize a checkpoint if the drainer does not have one | `0` |
| `config` | The configuration file passed to the drainer. Detailed reference: [drainer.toml](https://github.com/pingcap/tidb-binlog/blob/master/cmd/drainer/drainer.toml) | (see below) |
| `resources` | The resource limits and requests of the drainer Pod | `{}` |
| `nodeSelector` | Ensures that the drainer Pod is only scheduled to the node with the specific key-value pair as the label. Detailed reference: [nodeselector](https://kubernetes.io/docs/concepts/configuration/assign-Pod-node/#nodeselector) | `{}` |
| `tolerations` | Applies to drainer Pods, allowing the Pods to be scheduled to the nodes with specified taints. Detailed reference: [taint-and-toleration](https://kubernetes.io/docs/concepts/configuration/taint-and-toleration) | `{}` |
| `affinity` | Defines scheduling policies and preferences of the drainer Pod. Detailed reference:[affinity-and-anti-affinity](https://kubernetes.io/docs/concepts/configuration/assign-Pod-node/#affinity-and-anti-baffinity) | `{}` |

The default value of `config` is:

```toml
detect-interval = 10
compressor = ""
[syncer]
worker-count = 16
disable-dispatch = false
ignore-schemas = "INFORMATION_SCHEMA,PERFORMANCE_SCHEMA,mysql"
safe-mode = false
txn-batch = 20
db-type = "file"
[syncer.to]
dir = "/data/pb"
```
2 changes: 2 additions & 0 deletions v3.0/TOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@
- [Backup and Restore](tidb-in-kubernetes/maintain/backup-and-restore.md)
- [Collect Logs](tidb-in-kubernetes/maintain/log-collecting.md)
- [Automatic Failover](tidb-in-kubernetes/maintain/auto-failover.md)
- [TiDB Binlog](tidb-in-kubernetes/maintain/tidb-binlog.md)
- [Scale](tidb-in-kubernetes/scale-in-kubernetes.md)
+ Upgrade
- [TiDB Cluster](tidb-in-kubernetes/upgrade/tidb-cluster.md)
Expand All @@ -359,6 +360,7 @@
- [TiDB Cluster](tidb-in-kubernetes/reference/configuration/tidb-cluster.md)
- [Backup](tidb-in-kubernetes/reference/configuration/backup.md)
- [Local PV](tidb-in-kubernetes/reference/configuration/local-pv.md)
- [TiDB Drainer](tidb-in-kubernetes/reference/configuration/tidb-drainer.md)
+ Tools
- [tkctl](tidb-in-kubernetes/reference/tools/tkctl.md)
- [Tools in Kubernetes](tidb-in-kubernetes/reference/tools/in-kubernetes.md)
Expand Down
2 changes: 1 addition & 1 deletion v3.0/tidb-in-kubernetes/deploy/general-kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This document describes how to deploy a TiDB cluster on general Kubernetes.
## Prerequisites

- [Deploy TiDB Operator](tidb-in-kubernetes/deploy/tidb-operator.md);
- [Install Helm](tidb-in-kubernetes/reference/tools/in-kubernetes.md) and configure it with the official PingCAP chart.
- [Install Helm](tidb-in-kubernetes/reference/tools/in-kubernetes.md#use-helm) and configure it with the official PingCAP chart.

## Configure TiDB cluster

Expand Down
13 changes: 1 addition & 12 deletions v3.0/tidb-in-kubernetes/maintain/backup-and-restore.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,4 @@ The `pingcap/tidb-backup` helm chart helps restore a TiDB cluster using backup d
Incremental backup uses [TiDB Binlog](/reference/tidb-binlog-overview.md) to collect binlog data from TiDB and provide real-time backup and replication to downstream platforms.
Incremental backup is disabled in the TiDB cluster by default. To create a TiDB cluster with incremental backup enabled or enable incremental backup in existing TiDB cluster, modify the `values.yaml` file:
* Set `binlog.pump.create` to `true`.
* Set `binlog.drainer.create` to `true`.
* Set `binlog.pump.storageClassName` and `binlog.drainer.storageClassName` to an available `storageClass` in your Kubernetes cluster.
* Set `binlog.drainer.destDBType` to your desired downstream storage as needed, which is explained in details below.
Incremental backup supports three types of downstream storage:
* PersistenceVolume: the default downstream storage. You can consider configuring a large PV for `drainer` (by modifying `binlog.drainer.storage`) in this case.
* MySQL compatible databases: enabled by setting `binlog.drainer.destDBType` to `mysql`. Meanwhile, you must configure the address and credential of the target database in `binlog.drainer.mysql`.
* Apache Kafka: enabled by setting `binlog.drainer.destDBType` to `kafka`. Meanwhile, you must configure the zookeeper address and Kafka address of the target cluster in `binlog.drainer.kafka`.
For the detailed guide of maintaining TiDB Binlog in Kubernetes, refer to [TiDB Binlog](/tidb-in-kubernetes/maintain/tidb-binlog.md).
112 changes: 112 additions & 0 deletions v3.0/tidb-in-kubernetes/maintain/tidb-binlog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
title: Maintain TiDB Binlog
summary: Learn how to maintain TiDB Binlog of a TiDB cluster in Kubernetes.
category: how-to
---

# Maintain TiDB Binlog

This document describes how to maintain [TiDB Binlog](reference/tidb-binlog-overview.md) of a TiDB cluster in Kubernetes.

## Prerequisites

- [Deploy TiDB Operator](tidb-in-kubernetes/deploy/tidb-operator.md);
- [Install Helm](tidb-in-kubernetes/reference/tools/in-kubernetes.md#use-helm) and configure it with the official PingCAP chart.

## Enable TiDB Binlog of a TiDB cluster

TiDB Binlog is disabled in the TiDB cluster by default. To create a TiDB cluster with TiDB Binlog enabled, or enable TiDB Binlog in an existing TiDB cluster:

1. Modify the `values.yaml` file as described below:

* Set `binlog.pump.create` to `true`.
* Set `binlog.drainer.create` to `true`.
* Set `binlog.pump.storageClassName` and `binlog.drainer.storageClassName` to an available `storageClass` in your Kubernetes cluster.
* Set `binlog.drainer.destDBType` to your desired downstream storage as needed, which is explained in details below.

TiDB Binlog supports three types of downstream storage:

* PersistenceVolume: the default downstream storage. You can configure a large PV for `drainer` (by modifying `binlog.drainer.storage`) in this case.
* MySQL compatible databases: enabled by setting `binlog.drainer.destDBType` to `mysql`. Meanwhile, you must configure the address and credential of the target database in `binlog.drainer.mysql`.
* Apache Kafka: enabled by setting `binlog.drainer.destDBType` to `kafka`. Meanwhile, you must configure the zookeeper address and Kafka address of the target cluster in `binlog.drainer.kafka`.

2. Create a new TiDB cluster or update an existing cluster:

* Create a new TiDB cluster with TiDB Binlog enabled:

{{< copyable "shell-regular" >}}

```shell
helm install pingcap/tidb-cluster --name=<release-name> --namespace=<namespace> --version=<chart-version> -f <values-file>
```

* Update an existing TiDB cluster to enable TiDB Binlog:

{{< copyable "shell-regular" >}}

```shell
helm upgrade <release-name> pingcap/tidb-cluster --version=<chart-version> -f <values-file>
```

## Deploy multiple drainers

By default, only one downstream drainer is created. You can install the `tidb-drainer` Helm chart to deploy more drainers for a TiDB cluster, as described below:

1. Make sure that the PingCAP Helm repository is up to date:

{{< copyable "shell-regular" >}}

```shell
helm repo update
```

{{< copyable "shell-regular" >}}

```shell
helm search tidb-drainer -l
```

2. Get the default `values.yaml` file to facilitate customization:

```shell
helm inspect values pingcap/tidb-drainer --version=<chart-version> > values.yaml
```

3. Modify the `values.yaml` file to specify the source TiDB cluster and the downstream database of the drainer. Here is an example:

```yaml
clusterName: example-tidb
clusterVersion: v3.0.0
storageClassName: local-storage
storage: 10Gi
config: |
detect-interval = 10
[syncer]
worker-count = 16
txn-batch = 20
disable-dispatch = false
ignore-schemas = "INFORMATION_SCHEMA,PERFORMANCE_SCHEMA,mysql"
safe-mode = false
db-type = "tidb"
[syncer.to]
host = "slave-tidb"
user = "root"
password = ""
port = 4000
```

The `clusterName` and `clusterVersion` must match the desired source TiDB cluster.

For complete configuration details, refer to [TiDB Binlog Drainer Configurations in Kubernetes](tidb-in-kubernetes/reference/configuration/tidb-drainer.md).

4. Deploy the drainer:

{{< copyable "shell-regular" >}}

```shell
helm install pingcap/tidb-drainer --name=<release-name> --namespace=<namespace> --version=<chart-version> -f values.yaml
```

> **Note:**
>
> This chart must be installed to the same namespace as the source TiDB cluster.
Loading

0 comments on commit 2b7d600

Please sign in to comment.