logo资料库

Maxwell 安装、配置和使用说明书.docx

第1页 / 共3页
第2页 / 共3页
第3页 / 共3页
资料共3页,全文预览结束
Maxwell 安装、配置和使用说明书 官方网站: http://maxwells-daemon.io/ 一、环境要求 1、 JRE 7 or above 2、 mysql 5.1, 5.5, 5.6, 5.7, 8 3、 kafka 0.8.2 or greater 二、安装准备 1、 Maxwell Maxwell 目前最新版的下载地址: https://github.com/zendesk/maxwell/releases/download/v1.22.3/maxwell-1.22.3.tar. gz 源码地址: https://github.com/zendesk/maxwell 2、 安装 wget yum -y install wget 3、 Kafka 下载地址:https://archive.apache.org/dist/kafka/0.10.2.1/kafka_2.11-0.10.2.1.tgz 解压安装包:tar -zxvf kafka_2.11-0.10.2.1.tgz 4、 MySQL 下载、安装与配置 下载 rpm 包: wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm 安装: yum -y install mysql57-community-release-el7-10.noarch.rpm yum -y install mysql-community-server MySQL 安装完成以后,需要修改 MySQL 的配置文件: vi /etc/my.cnf 在[mysqld]下添加如下几行配置: #重要,重新搭建复制关系的时候一定要注意 server-id 的配置,需要重新配置 server-id = 1 #对一致性要求较高的情况下,使用 ROW,如果是 mixed, 不会触发错误,所以不 容#易发现错误 binlog_format = ROW #binlog 的存储名,默认在/var/lib/mysql 目录下面,生成的 binlog 日志名如: #master.000001
log-bin=master 配置完以后需要重新启动 MySQL。 启动 mysql:service mysqld start; 重启 mysql:service mysqld restart; 查看 mysql 状态:service mysqld status; 停止 mysql:service mysqld stop; 创建 maxwell 用户,也可以不创建,使用 root 用户。 create user 'maxwell'@'%' identified by '12345678'; 如果报错如下: Your password does not satisfy the current policy requirements 说明是不满足密码策略需要,可以执行下面的语句: #修改密码策略为 low,只需要验证 8 位 set global validate_password_policy=LOW; 然后重新创建,创建成功后,给创建的用户进行赋权操作: GRANT ALL ON maxwell.* TO 'maxwell'@'%'; GRANT SELECT, REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO 'maxwell'@'%'; flush privileges; 登录 MySQL,创建测试数据库,创建表。 mysql -umaxwell -p12345678 create database testbinlog; use testbinlog; create table testbinlog(id int not null primary key,name varchar(20)); 三、安装 解压 tar -zxvf maxwell-1.22.3.tar.gz 到 home 文件夹下,解压完成以后,在 maxwell 的安装目录下面可以看到一个 config.properties.example 配置模板文档,将.example 后缀删除,并对文档进行一些配置。 如日志级别: # set the log level. note that you can configure things further in log4j2.xml #log_level=DEBUG # [DEBUG, INFO, WARN, ERROR] MySQL 登录信息: # mysql login info host=localhost user=root password=root 控制 maxwell 是否输出包含 DDL 的 json 信息,如果开启会将建表的日志也发送到 kafka: # This controls whether maxwell will output JSON information containing # DDL (ALTER/CREATE TABLE/ETC) infromation. (default: false)
# See also: ddl_kafka_topic output_ddl=true 指定 producer producer=kafka kafka.bootstrap.servers=localhost:9092 或者 producer=stdout,可以讲 binlog 打印在控制台,等等。详细的配置可以访问如下 官网链接进行查看: http://maxwells-daemon.io/config/ 启 用 config.properties 配 置 , 可 以 在 开 启 maxwell 的 命 令 行 后 面 加 上 --config=config.properties,即可生效 config.properties 的配置。 四、使用 以上都准备好以后,就可以使用 maxwell 对 MySQL 插入、删除和修改数据时生成 的 binlog 日志的操作了。 开启 maxwell,将 binlog 打印到控制台, [root@localhost maxwell-1.22.3]# bin/maxwell --config=config.properties --producer= stdout 开 启 maxwell , 将 binlog 发 送 到 kafka , 需 要 在 config.properties 中 配 置 producer=kafka 和 kafka.bootstrap.servers=localhost:9092 bin/maxwell [root@localhost maxwell-1.22.3]# --config=config.properties --producer= kafka 在 MySQL 中对 testbinlog 表插入一条语句: insert into testbinlog values(1,'aa'); 可以看到控制台或者 kafka 的客户端收到一条 json 格式的日志消息,如下: {"database":"test","table":"testbinlog","type":"insert","ts":1565792343,"xid":16866,"c ommit":true,"data":{"id":1,"name":"aa"}}
分享到:
收藏