title | summary | aliases | |||
---|---|---|---|---|---|
TiDB Binlog Cluster Operations |
Learn how to operate the cluster version of TiDB Binlog. |
|
This document introduces the following TiDB Binlog cluster operations:
- The state of a Pump and Drainer nodes
- Starting or exiting a Pump or Drainer process
- Managing the TiDB Binlog cluster by using the binlogctl tool or by directly performing SQL operations in TiDB
Pump or Drainer state description:
online
: running normallypausing
: in the pausing processpaused
: has been stoppedclosing
: in the offline processoffline
: has been offline
Note:
The state information of a Pump or Drainer node is maintained by the service itself and is regularly updated to the Placement Driver (PD).
- Starting: When started, the Pump node notifies all Drainer nodes in the
online
state. If the notification is successful, the Pump node sets its state toonline
. Otherwise, the Pump node reports an error, sets its state topaused
and exits the process. - Exiting: The Pump node enters the
paused
oroffline
state before the process is exited normally; if the process is exited abnormally (caused by thekill -9
command, process panic, crash), the node is still in theonline
state.- Pause: You can pause a Pump process by using the
kill
command (notkill -9
), pressing Ctrl+C or using thepause-pump
command in the binlogctl tool. After receiving the pause instruction, the Pump node sets its state topausing
, stops receiving binlog write requests and stops providing binlog data to Drainer nodes. After all threads are safely exited, the Pump node updates its state topaused
and exits the process. - Offline: You can close a Pump process only by using the
offline-pump
command in the binlogctl tool. After receiving the offline instruction, the Pump node sets its state toclosing
and stops receiving the binlog write requests. The Pump node continues providing binlog to Drainer nodes until all binlog data is consumed by Drainer nodes. Then, the Pump node sets its state tooffline
and exits the process.
- Pause: You can pause a Pump process by using the
- Starting: When started, the Drainer node sets its state to
online
and tries to pull binlogs from all Pump nodes which are not in theoffline
state. If it fails to get the binlogs, it keeps trying. - Exiting: The Drainer node enters the
paused
oroffline
state before the process is exited normally; if the process is exited abnormally (caused bykill -9
, process panic, crash), the Drainer node is still in theonline
state.- Pause: You can pause a Drainer process by using the
kill
command (notkill -9
), pressing Ctrl+C or using thepause-drainer
command in the binlogctl tool. After receiving the pause instruction, the Drainer node sets its state topausing
and stops pulling binlogs from Pump nodes. After all threads are safely exited, the Drainer node sets its state topaused
and exits the process. - Offline: You can close a Drainer process only by using the
offline-drainer
command in the binlogctl tool. After receiving the offline instruction, the Drainer node sets its state toclosing
and stops pulling binlogs from Pump nodes. After all threads are safely exited, the Drainer node updates its state tooffline
and exits the process.
- Pause: You can pause a Drainer process by using the
For how to pause, close, check, and modify the state of Drainer, see the binlogctl guide.
binlogctl
is an operations tool for TiDB Binlog with the following features:
- Checking the state of Pump or Drainer
- Pausing or closing Pump or Drainer
- Handling the abnormal state of Pump or Drainer
For detailed usage of binlogctl
, refer to binlogctl overview.
To view or modify binlog related states, execute corresponding SQL statements in TiDB.
-
Check whether binlog is enabled:
{{< copyable "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" >}}
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" >}}
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 state of a Pump or Drainer node in abnormal situations
{{< copyable "sql" >}}
change pump to node_state ='paused' for node_id 'pump1';
Query OK, 0 rows affected (0.01 sec)
{{< copyable "sql" >}}
change drainer to node_state ='paused' for node_id 'drainer1';
Query OK, 0 rows affected (0.01 sec)
Executing the above SQL statements works the same as the
update-pump
orupdate-drainer
commands in binlogctl. Use the above SQL statements only when the Pump or Drainer node is in abnormal situations.
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 PD. To pause or close the node, use the
binlogctl
tool.