Skip to content

Commit

Permalink
Revert "Merge remote-tracking branch 'upstream/master'"
Browse files Browse the repository at this point in the history
This reverts commit f1844b1, reversing
changes made to 13f7cc8.
  • Loading branch information
TomShawn committed Oct 29, 2019
1 parent 65c0f73 commit 097b78a
Show file tree
Hide file tree
Showing 46 changed files with 798 additions and 1,173 deletions.
17 changes: 8 additions & 9 deletions dev/TOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
- [Overview](/dev/how-to/deploy/geographic-redundancy/overview.md)
- [Configure Location Awareness](/dev/how-to/deploy/geographic-redundancy/location-awareness.md)
- [Data Migration with Ansible](/dev/how-to/deploy/data-migration-with-ansible.md)
+ Deploy and Use TiDB Binlog
- [TiDB Binlog Cluster Deployment](/dev/how-to/deploy/tidb-binlog.md)
- [Binlog Slave Client User Guide](/dev/reference/tools/tidb-binlog/binlog-slave-client.md)
- [Reparo User Guide](/dev/reference/tools/tidb-binlog/reparo.md)
+ Configure
- [Time Zone](/dev/how-to/configure/time-zone.md)
- [Memory Control](/dev/how-to/configure/memory-control.md)
Expand All @@ -73,6 +77,7 @@
+ Monitor
- [Overview](/dev/how-to/monitor/overview.md)
- [Monitor a TiDB Cluster](/dev/how-to/monitor/monitor-a-cluster.md)
- [TiDB Binlog Monitoring](/dev/how-to/monitor/tidb-binlog.md)
+ Migrate
- [Overview](/dev/how-to/migrate/overview.md)
+ Migrate from MySQL
Expand All @@ -84,13 +89,15 @@
- [Common Ansible Operations](/dev/how-to/deploy/orchestrated/ansible-operations.md)
- [Backup and Restore](/dev/how-to/maintain/backup-and-restore.md)
- [Identify Slow Queries](/dev/how-to/maintain/identify-slow-queries.md)
- [TiDB Binlog Cluster Operations](/dev/how-to/maintain/tidb-binlog.md)
+ Scale
- [Scale using Ansible](/dev/how-to/scale/with-ansible.md)
- [Scale a TiDB Cluster](/dev/how-to/scale/horizontally.md)
+ Upgrade
- [Upgrade to TiDB 3.0](/dev/how-to/upgrade/from-previous-version.md)
- [Rolling updates with Ansible](/dev/how-to/upgrade/rolling-updates-with-ansible.md)
- [Upgrade TiDB Data Migration](/dev/reference/tools/data-migration/upgrade.md)
- [Upgrade TiDB Binlog Cluster](/dev/how-to/upgrade/tidb-binlog.md)
- Troubleshoot
- [Troubleshoot Cluster Setup](/dev/how-to/troubleshoot/cluster-setup.md)
- [Troubleshoot TiDB Data Migration](/dev/how-to/troubleshoot/data-migration.md)
Expand Down Expand Up @@ -335,15 +342,7 @@
- [Tune TiKV](/dev/reference/performance/tune-tikv.md)
- [Best Practices](https://pingcap.com/blog/2017-07-24-tidbbestpractice/)
- [TiSpark](/dev/reference/tispark.md)
+ TiDB Binlog
- [Overview](/dev/reference/tools/tidb-binlog/overview.md)
- [Deploy](/dev/reference/tools/tidb-binlog/deploy.md)
- [Maintain](/dev/reference/tools/tidb-binlog/maintain.md)
- [Monitor](/dev/reference/tools/tidb-binlog/monitor.md)
- [Upgrade](/dev/reference/tools/tidb-binlog/upgrade.md)
- [Reparo](/dev/reference/tools/tidb-binlog/reparo.md)
- [Binlog Slave Client](/dev/reference/tools/tidb-binlog/binlog-slave-client.md)
- [FAQ](/dev/reference/tools/tidb-binlog/faq.md)
- [TiDB Binlog Cluster Overview](/dev/reference/tidb-binlog-overview.md)
- [Adopters](/dev/adopters.md)
+ TiDB in Kubernetes
- [About TiDB Operator](/dev/tidb-in-kubernetes/tidb-operator-overview.md)
Expand Down
2 changes: 1 addition & 1 deletion dev/how-to/deploy/orchestrated/ansible.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ You can use the TiDB Ansible configuration file to set up the cluster topology a
- [Modify component configuration](/dev/how-to/upgrade/rolling-updates-with-ansible.md#modify-component-configuration)
- [Scale the TiDB cluster](/dev/how-to/scale/with-ansible.md)
- [Upgrade the component version](/dev/how-to/upgrade/rolling-updates-with-ansible.md#upgrade-the-component-version)
- [Enable the cluster binlog](/dev/reference/tools/tidb-binlog/overview.md)
- [Enable the cluster binlog](/dev/reference/tidb-binlog-overview.md)
- [Clean up data of the TiDB cluster](/dev/how-to/deploy/orchestrated/ansible-operations.md#clean-up-cluster-data)
- [Destroy the TiDB cluster](/dev/how-to/deploy/orchestrated/ansible-operations.md#destroy-a-cluster)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: TiDB Binlog Cluster Deployment
summary: Learn how to deploy TiDB Binlog cluster.
category: reference
aliases: ['/docs/dev/how-to/deploy/tidb-binlog/']
---

# TiDB Binlog Cluster Deployment
Expand Down
4 changes: 2 additions & 2 deletions dev/how-to/get-started/tidb-binlog.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ You can use TiDB Binlog for incremental backups, to replicate data from one TiDB

TiDB Binlog is particularly useful when you migrate data from MySQL or MariaDB to TiDB, in which case you may use the TiDB DM (Data Migration) platform to get data from a MySQL/MariaDB cluster into TiDB, and then use TiDB Binlog to keep a separate, downstream MySQL/MariaDB instance/cluster in sync with your TiDB cluster. TiDB Binlog enables application traffic to TiDB to be pushed to a downstream MySQL or MariaDB instance/cluster, which reduces the risk of a migration to TiDB because you can easily revert the application to MySQL or MariaDB without downtime or data loss.

See [TiDB Binlog Cluster User Guide](/dev/reference/tools/tidb-binlog/overview.md) for more information.
See [TiDB Binlog Cluster User Guide](/dev/reference/tidb-binlog-overview.md) for more information.

## Architecture

Expand Down Expand Up @@ -328,7 +328,7 @@ You should see the same rows that you inserted into TiDB when querying the Maria

## binlogctl

Information about Pumps and Drainers that have joined the cluster is stored in PD. You can use the binlogctl tool query and manipulate information about their states. See [binlogctl guide](/dev/reference/tools/tidb-binlog/maintain.md#binlogctl-guide) for more information.
Information about Pumps and Drainers that have joined the cluster is stored in PD. You can use the binlogctl tool query and manipulate information about their states. See [binlogctl guide](/dev/how-to/maintain/tidb-binlog.md#binlogctl-guide) for more information.

Use `binlogctl` to get a view of the current status of Pumps and Drainers in the cluster:

Expand Down
235 changes: 235 additions & 0 deletions dev/how-to/maintain/tidb-binlog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
---
title: TiDB Binlog Cluster Operations
summary: Learn how to operate the cluster version of TiDB Binlog.
category: reference
---

# TiDB Binlog Cluster Operations

## Pump or Drainer state

Pump or Drainer state description:

* `online`: running normally.
* `pausing`: in the pausing process. It turns into this state after you use `kill` or press Ctrl + C to exit from the process. When Pump or Drainer exits all internal threads in safe, it becomes `paused`.
* `paused`: has been stopped. While Pump is in this state, it rejects the request of writing binlog into it and does not provide the binlog for Drainer any more. When Drainer is in this state, it does not replicate data to the downstream. After Pump and Drainer exit normally from all the threads, they switch the state to `paused` and then exits from the process.
* `closing`: in the offline process. The `binlogctl` is used to get Pump or Drainer offline and Pump or Drainer is in this state before the process exits. In this state, Pump does not accept new requests of writing binlog into it and waits for all the binlog data to be used up by Drainer.
* `offline`: becomes offline. After Pump sends all the binlog data that it saves to Drainer, its state is switched to `offline`.

> **Note:**
>
> * When Pump or Drainer is `pausing` or `paused`, the data replication is interrupted.
> * Pump and Drainer have several states, including `online`, `paused`, and `offline`. If you press Ctrl + C or `kill` the process, both Pump and Drainer become `pausing` then finally turn to `paused` . There is no need for Pump to send all the binlog data to Drainer before it become `paused` while Pump need to send all the binlog data to Drainer before it become `offline` . If you need to exit from Pump for a long period of time (or are permanently removing Pump from the cluster), use `binlogctl` to make Pump offline. The same goes for Drainer.
> * When Pump is `closing`, you need to guarantee that all the data has been consumed by all the Drainers that are not `offline`. So before making Pump offline, you need to guarantee all the Drainers are `online`. Otherwise, Pump cannot get offline normally.
> * The binlog data that Pump saves is processed by GC only when it has been consumed by all the Drainers that are not `offline`.
> * Close Drainer only when it will not be used any more.
For how to pause, close, check, and modify the state of Drainer, see the [binlogctl guide](#binlogctl-guide) as follows.

## `binlogctl` guide

[`binlogctl`](https://github.com/pingcap/tidb-binlog/tree/master/binlogctl) is an operations tool for TiDB Binlog with the following features:

* Obtaining the current `tso` of TiDB cluster
* Checking the state of Pump or Drainer
* Modifying the state of Pump or Drainer
* Pausing or closing Pump or Drainer

### Usage scenarios of `binlogctl`

* It is the first time you run Drainer and you need to obtain the current `tso` of TiDB cluster.
* When Pump or Drainer exits abnormally, its state is not updated and the service is affected. You can use this tool to modify the state.
* An error occurs during data replication and you need to check the running status and state of Pump or Drainer.
* While maintaining the cluster, you need to pause or close Pump or Drainer.

### Download `binlogctl`

Your distribution of TiDB or TiDB Binlog might already include binlogctl. If not, download `binlogctl`:

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

```bash
wget https://download.pingcap.org/tidb-{version}-linux-amd64.tar.gz
wget https://download.pingcap.org/tidb-{version}-linux-amd64.sha256
```

The following command checks the file integrity. If the result is OK, the file is correct.

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

```bash
sha256sum -c tidb-{version}-linux-amd64.sha256
```

### `binlogctl` usage description

Command line parameters:

```
Usage of binlogctl:
-V
Outputs the binlogctl version information
-cmd string
the command mode, including "generate_meta", "pumps", "drainers", "update-pump" ,"update-drainer", "pause-pump", "pause-drainer", "offline-pump", and "offline-drainer"
-data-dir string
the file path where the checkpoint file of Drainer is stored ("binlog_position" by default)
-node-id string
ID of Pump or Drainer
-pd-urls string
the address of PD. If multiple addresses exist, use "," to separate each ("http://127.0.0.1:2379" by default)
-ssl-ca string
the file path of SSL CAs
-ssl-cert string
the file path of the X509 certificate file in the PEM format
-ssl-key string
the file path of X509 key file of the PEM format
-time-zone string
If a time zone is set, the corresponding time of the obtained `tso` is printed in the "generate_meta" mode. For example, "Asia/Shanghai" is the CST time zone and "Local" is the local time zone
```

Command example:

- Check the state of all the Pump or Drainer nodes:

Set `cmd` as `pumps` or `drainers` to check the state of all the Pump or Drainer nodes. For example,

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

```bash
bin/binlogctl -pd-urls=http://127.0.0.1:2379 -cmd pumps
```

```
INFO[0000] pump: {NodeID: ip-172-16-30-67:8250, Addr: 172.16.30.192:8250, State: online, MaxCommitTS: 405197570529820673, UpdateTime: 2018-12-25 14:23:37 +0800 CST}
```

- Modify the state of Pump or Drainer:

Set `cmd` as `update-pump` or `update-drainer` to modify the states of Pump or Drainer, which can be `online`, `pausing`, `paused`, `closing` or `offline`.

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

```bash
bin/binlogctl -pd-urls=http://127.0.0.1:2379 -cmd update-pump -node-id ip-127-0-0-1:8250 -state paused
```

> **Note:**
>
> - This command modifies the state of Pump or Drainer saved in the Placement Driver (PD).
> - Use this command **only** when the Pump or Drainer service fails to function properly.

- Pause or close Pump or Drainer:

- Set `cmd` as `pause-pump` or `pause-drainer` to pause Pump or Drainer.

- Set `cmd` as `offline-pump` or `offline-drainer` to close Pump or Drainer.

For example,

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

```bash
bin/binlogctl -pd-urls=http://127.0.0.1:2379 -cmd pause-pump -node-id ip-127-0-0-1:8250
```

`binlogctl` sends the HTTP request to Pump or Drainer, and Pump or Drainer exits from the process after receiving the command and sets its state to `paused`/`offline`.

- Generate the meta file that Drainer needs to start:

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

```bash
bin/binlogctl -pd-urls=http://127.0.0.1:2379 -cmd generate_meta
```

```
INFO[0000] [pd] create pd client with endpoints [http://192.168.199.118:32379]
INFO[0000] [pd] leader switches to: http://192.168.199.118:32379, previous:
INFO[0000] [pd] init cluster id 6569368151110378289
2018/06/21 11:24:47 meta.go:117: [info] meta: &{CommitTS:400962745252184065}
```

This command generates a `{data-dir}/savepoint` file. This file stores the `tso` information which is needed for the initial start of Drainer.

## Use SQL statements to manage Pump or Drainer

To view or modify binlog related states, execute corresponding SQL statements in TiDB.

- Check whether binlog is enabled:

{{< copyable "sql" >}}

```sql
show variables like "log_bin";
```

```
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin | ON |
+---------------+-------+
```

When the Value is `ON`, it means that the binlog is enabled.

- Check the status of all the Pump or Drainer nodes:

{{< copyable "sql" >}}

```sql
show pump status;
```

```
+--------|----------------|--------|--------------------|---------------------|
| NodeID | Address | State | Max_Commit_Ts | Update_Time |
+--------|----------------|--------|--------------------|---------------------|
| pump1 | 127.0.0.1:8250 | Online | 408553768673342237 | 2019-05-01 00:00:01 |
+--------|----------------|--------|--------------------|---------------------|
| pump2 | 127.0.0.2:8250 | Online | 408553768673342335 | 2019-05-01 00:00:02 |
+--------|----------------|--------|--------------------|---------------------|
```

{{< copyable "sql" >}}

```sql
show drainer status;
```

```
+----------|----------------|--------|--------------------|---------------------|
| NodeID | Address | State | Max_Commit_Ts | Update_Time |
+----------|----------------|--------|--------------------|---------------------|
| drainer1 | 127.0.0.3:8249 | Online | 408553768673342532 | 2019-05-01 00:00:03 |
+----------|----------------|--------|--------------------|---------------------|
| drainer2 | 127.0.0.4:8249 | Online | 408553768673345531 | 2019-05-01 00:00:04 |
+----------|----------------|--------|--------------------|---------------------|
```

- Modify the states of a Pump or Drainer node:

{{< copyable "sql" >}}

```sql
change pump to node_state ='paused' for node_id 'pump1';
```

```
Query OK, 0 rows affected (0.01 sec)
```

{{< copyable "sql" >}}

```sql
change drainer to node_state ='paused' for node_id 'drainer1';
```

```
Query OK, 0 rows affected (0.01 sec)
```

> **Note:**
>
> - Checking whether binlog is enabled and the running status of Pump or Drainer is supported in TiDB v2.1.7 and later versions.
> - Modifying the status of Pump or Drainer is supported in TiDB v3.0.0-rc.1 and later versions. This feature only supports modifying the status of Pump or Drainer nodes stored in the Placement Driver (PD). To pause or close the node, use the `binlogctl` tool.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: TiDB Binlog Monitoring
summary: Learn how to monitor the cluster version of TiDB Binlog.
category: reference
aliases: ['/docs/dev/how-to/monitor/tidb-binlog/']
---

# TiDB Binlog Monitoring
Expand Down
2 changes: 1 addition & 1 deletion dev/how-to/upgrade/from-previous-version.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ category: how-to

# TiDB 3.0 Upgrade Guide

This document is targeted for users who want to upgrade from TiDB 2.0 (above V2.0.1) or TiDB 2.1 RC to TiDB 3.0. TiDB 3.0 is compatible with [TiDB Binlog of Kafka Version](/dev/reference/tools/tidb-binlog/tidb-binlog-kafka.md) and [TiDB Binlog of Cluster Version](/dev/reference/tools/tidb-binlog/overview.md).
This document is targeted for users who want to upgrade from TiDB 2.0 (above V2.0.1) or TiDB 2.1 RC to TiDB 3.0. TiDB 3.0 is compatible with [TiDB Binlog of Kafka Version](/dev/reference/tools/tidb-binlog/tidb-binlog-kafka.md) and [TiDB Binlog of Cluster Version](/dev/reference/tidb-binlog-overview.md).

## Upgrade caveat

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: Upgrade TiDB Binlog Cluster
summary: Learn how to upgrade the cluster version of TiDB Binlog.
category: reference
aliases: ['/docs/dev/how-to/upgrade/tidb-binlog/']
---

# Upgrade TiDB Binlog Cluster
Expand All @@ -21,7 +20,7 @@ The corresponding relationship between TiDB Binlog versions and TiDB versions is

> **Note:**
>
> If importing the full data is acceptable, you can abandon the old version and deploy TiDB Binlog following [TiDB Binlog Cluster Deployment](/dev/reference/tools/tidb-binlog/deploy.md).
> If importing the full data is acceptable, you can abandon the old version and deploy TiDB Binlog following [TiDB Binlog Cluster Deployment](/dev/how-to/deploy/tidb-binlog.md).
If you want to resume replication from the original checkpoint, perform the following steps to upgrade TiDB Binlog:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: TiDB Binlog Overview
summary: Learn overview of the cluster version of TiDB Binlog.
category: reference
aliases: ['/docs/dev/reference/tidb-binlog-overview/']
---

# TiDB Binlog Cluster Overview
Expand Down Expand Up @@ -62,3 +61,13 @@ The TiDB Binlog cluster is composed of Pump and Drainer.
- If your TiDB version is 2.1.9 or later, set `db-type="file"` or `db-type="pb"`.

* If the downstream is MySQL, MariaDB, or another TiDB cluster, you can use [sync-diff-inspector](/dev/reference/tools/sync-diff-inspector/overview.md) to verify the data after data replication.

## TiDB Binlog Instructions

Once you grasp the basics from the above, you can refer to the following documents to use TiDB Binlog:

- [TiDB Binlog Tutorial](/dev/how-to/get-started/tidb-binlog.md)
- [TiDB Binlog Cluster Deployment](/dev/how-to/deploy/tidb-binlog.md)
- [TiDB Binlog Monitoring](/dev/how-to/monitor/tidb-binlog.md)
- [TiDB Binlog Cluster Operations](/dev/how-to/maintain/tidb-binlog.md)
- [Upgrade TiDB Binlog Cluster](/dev/how-to/upgrade/tidb-binlog.md)
4 changes: 2 additions & 2 deletions dev/reference/tools/download.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This document collects the available downloads for most officially maintained ve

## TiDB Binlog

If you want to download the latest version of [TiDB Binlog](/dev/reference/tools/tidb-binlog/overview.md), directly download the TiDB package, because TiDB Binlog is included in the TiDB package.
If you want to download the latest version of [TiDB Binlog](/dev/reference/tidb-binlog-overview.md), directly download the TiDB package, because TiDB Binlog is included in the TiDB package.

In addition, the Kafka version of TiDB Binlog is also provided.

Expand Down Expand Up @@ -54,5 +54,5 @@ This enterprise tools package includes all the following tools:
- Syncer
- Loader
- Mydumper
- [binlogctl](/dev/reference/tools/tidb-binlog/overview.md#binlogctl-guide)
- [binlogctl](/dev/reference/tidb-binlog-overview.md#binlogctl-guide)
- [sync_diff_inspector](/dev/reference/tools/sync-diff-inspector/overview.md)
Loading

0 comments on commit 097b78a

Please sign in to comment.