diff --git a/en/handle-alerts.md b/en/handle-alerts.md index f966e3431..e095e7538 100644 --- a/en/handle-alerts.md +++ b/en/handle-alerts.md @@ -57,10 +57,6 @@ This document introduces how to deal with the alert information in DM. ## Alert rules related to relay log -> **Note:** -> -> Currently, DM v2.0 does not support enabling the relay log feature. - ### `DM_relay_process_exits_with_error` - Description: diff --git a/en/monitor-a-dm-cluster.md b/en/monitor-a-dm-cluster.md index c32d0fd8c..265802e1d 100644 --- a/en/monitor-a-dm-cluster.md +++ b/en/monitor-a-dm-cluster.md @@ -41,10 +41,6 @@ In the Grafana dashboard, the default name of DM is `DM-task`. ### High availability -> **Note:** -> -> In DM v2.0, the relay log feature is not supported. - | Metric name | Description | Alert | Severity level | |:----|:------------|:----|:----| | number of dm-masters start leader components per minute | The number of DM-master attempts to enable leader related components per minute | N/A | N/A | @@ -130,10 +126,6 @@ In the Grafana dashboard, the default name of an instance is `DM-instance`. ### Relay log -> **Note:** -> -> Currently, DM v2.0 does not support enabling the relay log feature. - | Metric name | Description | Alert | Severity level | |:----|:------------|:----|:----| | storage capacity | The total storage capacity of the disk occupied by the relay log | N/A | N/A | diff --git a/en/relay-log.md b/en/relay-log.md index 409d96111..7fcef9fb0 100644 --- a/en/relay-log.md +++ b/en/relay-log.md @@ -5,10 +5,6 @@ summary: Learn the directory structure, initial migration rules and data purge o # Data Migration Relay Log -> **Note:** -> -> In DM v2.0, the relay log feature is not supported. - The Data Migration (DM) relay log consists of a set of numbered files containing events that describe database changes, and an index file that contains the names of all used relay log files. After DM-worker is started, it automatically migrates the upstream binlog to the local configuration directory (the default migration directory is `/relay_log` if DM is deployed using TiUP). When DM-worker is running, it migrates the upstream binlog to the local file in real time. The sync processing unit of DM-worker, reads the binlog events of the local relay log in real time, transforms these events to SQL statements, and then migrates these statements to the downstream database. @@ -88,32 +84,28 @@ The data purge methods for the relay log include automatic purge and manual purg ### Automatic data purge -You can configure the automatic data purge strategy of DM-worker using the following two methods: +You can enable automatic data purge and configure its strategy in the source configuration file. See the following example: -Method 1: Use the command-line options. +```yaml +# relay log purge strategy +purge: + interval: 3600 + expires: 24 + remain-space: 15 +``` -+ `purge-interval` ++ `purge.interval` - The interval of automatic purge in the background, in seconds. - "3600" by default, indicating a background purge task is performed every 3600 seconds. -+ `purge-expires` ++ `purge.expires` - The number of hours for which the relay log (that has been previously written to the relay processing unit, and that is not being used or will not be read later by the currently running data migration task) can be retained before being purged in the automatic background purge. - "0" by default, indicating data purge is not performed according to the update time of the relay log. -+ `purge-remain-space` ++ `purge.remain-space` - The amount of remaining disk space in GB less than which the specified DM-worker machine tries to purge the relay log that can be purged securely in the automatic background purge. If it is set to `0`, data purge is not performed according to the remaining disk space. - "15" by default, indicating when the available disk space is less than 15GB, DM-master tries to purge the relay log securely. -Method 2: Add the `[purge]` section in the configuration file of DM-worker. - -```toml -# relay log purge strategy -[purge] -interval = 3600 -expires = 24 -remain-space = 15 -``` - ### Manual data purge Manual data purge means using the `purge-relay` command provided by dmctl to specify `subdir` and the binlog name thus to purge all the relay logs **before** the specified binlog. If the `-subdir` option in the command is not specified, all relay logs **before** the current relay log sub-directory are purged. @@ -147,7 +139,7 @@ deb76a2b-09cc-11e9-9129-5242cf3bb246.000003 {{< copyable "" >}} ```bash - » purge-relay -w 10.128.16.223:10081 --filename mysql-bin.000001 --sub-dir e4e0e8ab-09cc-11e9-9220-82cc35207219.000002 + » purge-relay -s mysql-replica-01 --filename mysql-bin.000001 --sub-dir e4e0e8ab-09cc-11e9-9220-82cc35207219.000002 ``` + Executing the following `purge-relay` command in dmctl purges all relay log file **before the current** (`deb76a2b-09cc-11e9-9129-5242cf3bb246.000003`) directory's `mysql-bin.000001`, which is all relay log files in `deb76a2b-09cc-11e9-9129-5242cf3bb246.000001` and `e4e0e8ab-09cc-11e9-9220-82cc35207219.000002`. @@ -155,5 +147,5 @@ deb76a2b-09cc-11e9-9129-5242cf3bb246.000003 {{< copyable "" >}} ```bash - » purge-relay -w 10.128.16.223:10081 --filename mysql-bin.000001 + » purge-relay -s mysql-replica-01 --filename mysql-bin.000001 ``` diff --git a/en/source-configuration-file.md b/en/source-configuration-file.md index b968bb8ee..42cf8c9f8 100644 --- a/en/source-configuration-file.md +++ b/en/source-configuration-file.md @@ -17,6 +17,11 @@ source-id: "mysql-replica-01" # Whether to enable GTID. enable-gtid: false +# Whether to enable relay log. +enable-relay: false +relay-binlog-name = "" # The file name from which DM-worker starts to pull the binlog. +relay-binlog-gtid = "" # The GTID from which DM-worker starts to pull the binlog. + from: host: "127.0.0.1" port: 3306 @@ -26,6 +31,11 @@ from: ssl-ca: "/path/to/ca.pem" ssl-cert: "/path/to/cert.pem" ssl-key: "/path/to/key.pem" + +# purge: +# interval: 3600 +# expires: 0 +# remain-space: 15 ``` ## Configuration parameters @@ -38,8 +48,25 @@ This section describes each configuration parameter in the configuration file. | :------------ | :--------------------------------------- | | `source-id` | Represents a MySQL instance ID. | | `enable-gtid` | Determines whether to pull binlog from the upstream using GTID. The default value is `false`. In general, you do not need to configure `enable-gtid` manually. However, if GTID is enabled in the upstream database, and the primary/secondary switch is required, you need to set `enable-gtid` to `true`. | +| `enable-relay` | Determines whether to enable the relay log feature. The default value is `false`. | +| `relay-binlog-name` | Specifies the file name from which DM-worker starts to pull the binlog. For example, `"mysql-bin.000002"`. It only works when `enable_gtid` is `false`. If this parameter is not specified, DM-worker will pull the binlogs starting from the latest one. | +| `relay-binlog-gtid` | Specifies the GTID from which DM-worker starts to pull the binlog. For example, `"e9a1fc22-ec08-11e9-b2ac-0242ac110003:1-7849"`. It only works when `enable_gtid` is `true`. If this parameter is not specified, DM-worker will pull the binlogs starting from the latest GTID. | | `host` | Specifies the host of the upstream database. | | `port` | Specifies the port of the upstream database. | | `user` | Specifies the username of the upstream database. | | `password` | Specifies the user password of the upstream database. It is recommended to use the password encrypted with dmctl. | | `security` | Specifies the TLS config of the upstream database. | + +### Relay log cleanup strategy configuration (`purge`) + +Generally, there is no need to manually configure these parameters unless there is a large amount of relay logs and disk capacity is insufficient. + +| Parameter | Description | Default value | +| :------------ | :--------------------------------------- | :-------------| +| `interval` | Sets the time interval at which relay logs are regularly checked for expiration, in seconds. | `3600` | +| `expires` | Sets the expiration time for relay logs, in hours. The relay log that is not written by the relay processing unit, or does not need to be read by the existing data migration task will be deleted by DM if it exceeds the expiration time. If this parameter is not specified, the automatic purge is not performed. | `0` | +| `remain-space` | Sets the minimum amount of free disk space, in gigabytes. When the available disk space is smaller than this value, DM-worker tries to delete relay logs. | `15` | + +> **Note:** +> +> The automatic data purge strategy only takes effect when `interval` is not 0 and at least one of the two configuration items `expires` and `remain-space` is not 0. diff --git a/zh/handle-alerts.md b/zh/handle-alerts.md index b63eca4c3..2c83f2e34 100644 --- a/zh/handle-alerts.md +++ b/zh/handle-alerts.md @@ -29,10 +29,6 @@ summary: 了解 DM 中各主要告警信息的处理方法。 ## relay log 告警 -> **注意:** -> -> 当前 DM v2.0 版本暂不支持开启 relay log 功能。 - ### `DM_relay_process_exits_with_error` 当 relay log 处理单元遇到错误时,会转为 `Paused` 状态并立即触发该告警,此时需要参考 [DM 故障诊断](error-handling.md#dm-故障诊断)进行处理。 diff --git a/zh/monitor-a-dm-cluster.md b/zh/monitor-a-dm-cluster.md index fe1567298..e1a2ca98c 100644 --- a/zh/monitor-a-dm-cluster.md +++ b/zh/monitor-a-dm-cluster.md @@ -100,10 +100,6 @@ overview 下包含运行当前选定 task 的所有 DM-worker/master instance/so ### Relay log -> **注意:** -> -> 当前 DM v2.0 版本暂不支持开启 relay log 功能。 - | metric 名称 | 说明 | 告警说明 | 告警级别 | |:----|:------------|:----|:----| | storage capacity | relay log 占有的磁盘的总容量 | N/A | N/A | @@ -125,10 +121,6 @@ overview 下包含运行当前选定 task 的所有 DM-worker/master instance/so ### Relay log -> **注意:** -> -> 当前 DM v2.0 版本暂不支持开启 relay log 功能。 - | metric 名称 | 说明 | 告警说明 | 告警级别 | |:----|:------------|:----|:----| | storage capacity | relay log 占有的磁盘的总容量 | N/A | N/A | diff --git a/zh/relay-log.md b/zh/relay-log.md index 5dae055cc..cefd5486c 100644 --- a/zh/relay-log.md +++ b/zh/relay-log.md @@ -5,10 +5,6 @@ summary: 了解目录结构、初始迁移规则和 DM relay log 的数据清理 # DM Relay Log -> **注意:** -> -> 当前 DM v2.0 版本暂不支持开启 relay log 功能。 - DM (Data Migration) 工具的 relay log 由一组有编号的文件和一个索引文件组成。这些有编号的文件包含了描述数据库更改的事件。索引文件包含所有使用过的 relay log 的文件名。 DM-worker 在启动后,会自动将上游 binlog 迁移到本地配置目录(若使用 TiUP 部署 DM,则迁移目录默认为 ` / relay_log` )。DM-worker 在运行过程中,会将上游 binlog 实时迁移到本地文件。DM-worker 的 sync 处理单元会实时读取本地 relay log 的 binlog 事件,将这些事件转换为 SQL 语句,再将 SQL 语句迁移到下游数据库。 @@ -96,30 +92,28 @@ Relay log 的数据清理包括自动清理和手动清理这两种方法。 ### 自动数据清理 -自动数据清理需对 DM-worker 命令行配置中的以下三项进行配置: +启用自动数据清理需在 source 配置文件中进行以下配置: + +```yaml +# relay log purge strategy +purge: + interval: 3600 + expires: 24 + remain-space: 15 +``` -- `purge-interval` +- `purge.interval` - 后台自动清理的时间间隔,以秒为单位。 - 默认为 "3600",表示每 3600 秒执行一次后台清理任务。 -- `purge-expires` +- `purge.expires` - 当前 relay 处理单元没有写入、或已有数据迁移任务当前或未来不需要读取的 relay log 在被后台清理前可保留的小时数。 - 默认为 "0",表示不按 relay log 的更新时间执行数据清理。 -- `purge-remain-space` +- `purge.remain-space` - 剩余磁盘空间,单位为 GB。若剩余磁盘空间小于该配置,则指定的 DM-worker 机器会在后台尝试自动清理可被安全清理的 relay-log。若这一数字被设为 "0",则表示不按剩余磁盘空间来清理数据。 - 默认为 "15",表示可用磁盘空间小于 15GB 时,DM-master 会尝试安全地清理 relay log。 -或者在 DM-woker 的配置文件中加入 purge 配置: - -```toml -# relay log purge strategy -[purge] -interval = 3600 -expires = 24 -remain-space = 15 -``` - ### 手动数据清理 手动数据清理是指使用 dmctl 提供的 `purge-relay` 命令,通过指定 `subdir` 和 binlog 文件名,来清理掉**指定 binlog 之前**的所有 relay log。若在命令中不填 `-subdir` 选项,则默认清理**最新 relay log 子目录之前**的所有 relay log。 @@ -167,7 +161,7 @@ deb76a2b-09cc-11e9-9129-5242cf3bb246.000003 {{< copyable "" >}} ```bash - » purge-relay -w 10.128.16.223:10081 --filename mysql-bin.000001 --sub-dir e4e0e8ab-09cc-11e9-9220-82cc35207219.000002 + » purge-relay -s mysql-replica-01 --filename mysql-bin.000001 --sub-dir e4e0e8ab-09cc-11e9-9220-82cc35207219.000002 ``` + 以下命令默认 `--sub-dir` 为最新的 `deb76a2b-09cc-11e9-9129-5242cf3bb246.000003` 子目录。该目录之前的 relay log 子目录为 `deb76a2b-09cc-11e9-9129-5242cf3bb246.000001` 和 `e4e0e8ab-09cc-11e9-9220-82cc35207219.000002`,所以该命令实际清空了这两个子目录,保留了 `deb76a2b-09cc-11e9-9129-5242cf3bb246.000003`。 @@ -175,5 +169,5 @@ deb76a2b-09cc-11e9-9129-5242cf3bb246.000003 {{< copyable "" >}} ```bash - » purge-relay -w 10.128.16.223:10081 --filename mysql-bin.000001 + » purge-relay -s mysql-replica-01 --filename mysql-bin.000001 ``` diff --git a/zh/source-configuration-file.md b/zh/source-configuration-file.md index 686a7364b..71dde24cb 100644 --- a/zh/source-configuration-file.md +++ b/zh/source-configuration-file.md @@ -16,6 +16,11 @@ source-id: "mysql-replica-01" # 是否开启 GTID enable-gtid: false +# 是否开启 relay log +enable-relay: false +relay-binlog-name: '' # 拉取上游 binlog 的起始文件名 +relay-binlog-gtid: '' # 拉取上游 binlog 的起始 GTID + from: host: "127.0.0.1" port: 3306 @@ -25,6 +30,11 @@ from: ssl-ca: "/path/to/ca.pem" ssl-cert: "/path/to/cert.pem" ssl-key: "/path/to/key.pem" + +# purge: +# interval: 3600 +# expires: 0 +# remain-space: 15 ``` ## 配置项说明 @@ -35,8 +45,25 @@ from: | :------------ | :--------------------------------------- | | `source-id` | 标识一个 MySQL 实例。| | `enable-gtid` | 是否使用 GTID 方式从上游拉取 binlog,默认值为 false。一般情况下不需要手动配置,如果上游数据库启用了 GTID 支持,且需要做主从切换,则将该配置项设置为 true。 | +| `enable-relay` | 是否开启 relay log,默认值为 false。 | +| `relay-binlog-name` | 拉取上游 binlog 的起始文件名,例如 "mysql-bin.000002",该配置在 `enable-gtid` 为 false 的情况下生效。如果不配置该项,DM-worker 将从最新时间点的 binlog 文件开始拉取 binlog,一般情况下不需要手动配置。 | +| `relay-binlog-gtid` | 拉取上游 binlog 的起始 GTID,例如 "e9a1fc22-ec08-11e9-b2ac-0242ac110003:1-7849",该配置在 `enable-gtid` 为 true 的情况下生效。如果不配置该项,DM-worker 将从最新时间点的 binlog GTID 开始拉取 binlog,一般情况下不需要手动配置。 | | `host` | 上游数据库的 host。| | `port` | 上游数据库的端口。| | `user` | 上游数据库使用的用户名。| | `password` | 上游数据库的用户密码。注意:推荐使用 dmctl 加密后的密码。| | `security` | 上游数据库 TLS 相关配置。| + +### relay log 清理策略配置(purge 配置项) + +一般情况下不需要手动配置,如果 relay log 数据量较大,磁盘空间不足,则可以通过设置该配置项来避免 relay log 写满磁盘。 + +| 配置项 | 说明 | +| :------------ | :--------------------------------------- | +| `interval` | 定期检查 relay log 是否过期的间隔时间,默认值:3600,单位:秒。 | +| `expires` | relay log 的过期时间,默认值为 0,单位:小时。未由 relay 处理单元进行写入、或已有数据迁移任务当前或未来不需要读取的 relay log 在超过过期时间后会被 DM 删除。如果不设置则 DM 不会自动清理过期的 relay log。 | +| `remain-space` | 设置最小的可用磁盘空间。当磁盘可用空间小于这个值时,DM-worker 会尝试删除 relay log,默认值:15,单位:GB。 | + +> **注意:** +> +> 仅在 `interval` 不为 0 且 `expires` 和 `remain-space` 两个配置项中至少有一个不为 0 的情况下 DM 的自动清理策略才会生效。