MapReduce服务 MRS-基于binlog的MySQL数据同步到MRS集群中:验证Maxwell

时间:2025-02-12 14:58:21

验证Maxwell

  1. 登录Maxwell所在的服务器。
  2. 查看日志。如果日志里面没有ERROR日志,且有打印如下日志,表示与MySQL连接正常。

    BinlogConnectorLifecycleListener - Binlog connected.

  3. 登录MySQL数据库,对测试数据进行更新/创建/删除等操作。操作语句可以参考如下示例。

    -- 创建库create database test;-- 创建表create table test.e (  id int(10) not null primary key auto_increment,  m double,  c timestamp(6),  comment varchar(255) charset 'latin1');-- 增加记录insert into test.e set m = 4.2341, c = now(3), comment = 'I am a creature of light.';-- 更新记录update test.e set m = 5.444, c = now(3) where id = 1;-- 删除记录delete from test.e where id = 1;-- 修改表alter table test.e add column torvalds bigint unsigned after m;-- 删除表drop table test.e;-- 删除库drop database test;

  4. 观察Maxwell的日志输出,如果没有WARN/ERROR打印,则表示Maxwell安装配置正常。

    若要确定数据是否成功上传,可设置config.properties中的log_level为debug,则数据上传成功时会立刻打印如下JSON格式数据,具体字段含义请参考Maxwell生成的数据格式及常见字段含义
    {"database":"test","table":"e","type":"insert","ts":1541150929,"xid":60556,"commit":true,"data":{"id":1,"m":4.2341,"c":"2018-11-02 09:28:49.297000","comment":"I am a creature of light."}}……

    当整个流程调试通过之后,可以把config.properties文件中的配置项log_level修改为info,减少日志打印量,并重启Maxwell。

    # log level [debug | info | warn | error]log_level=info

support.huaweicloud.com/cmpntguide-mrs/mrs_01_0441.html