maxwell簡單部署使用


詳細資料可以參考maxwell官網  (mysql + maxwell + kafka + elasticsearch)
說明:本文主要是關於配置maxwell監聽mysql的數據修改並實時將修改內容同步到kafka中。

- 配置mysql啟用binlog

配置/etc/my.cnf,然后重啟mysql服務

[mysqld]
server-id=1
log-bin=master binlog_format=row 

在mysql中給maxwell授予相應的權限並建立maxwell數據庫

MariaDB [(none)]>  GRANT ALL on maxwell.* to 'maxwell'@'%' identified by '123456'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> GRANT SELECT, REPLICATION CLIENT, REPLICATION SLAVE on *.* to 'maxwell'@'%'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec) 

建立一個測試用表,並插入一條數據

MariaDB [(none)]> use hivetest;
Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed MariaDB [hivetest]> insert into test set name = '11111', age = '12313'; Query OK, 1 row affected (0.00 sec) 

- maxwell配置文件

[root@datanode1 ~]# cat /opt/maxwell-1.10.6/config.properties | grep -v ^# | grep -v ^$ log_level=info producer=kafka kafka.bootstrap.servers=192.168.190.11:9092,192.168.190.14:9092,192.168.190.17:9092 host=localhost user=maxwell password=123456 kafka_topic=test kafka.compression.type=snappy kafka.metadata.fetch.timeout.ms=5000 kafka.retries=3 kafka.acks=all kinesis_stream=maxwell 

啟動maxwell測試下是否能正常獲取binglog

[root@datanode1 maxwell-1.10.6]# bin/maxwell --user='maxwell' --password='123456' --host='127.0.0.1' --producer=stdout 14:12:01,700 WARN MaxwellMetrics - Metrics will not be exposed: metricsReportingType not configured. 14:12:01,933 INFO SchemaStoreSchema - Creating maxwell database 14:12:02,004 INFO Maxwell - Maxwell v1.10.6 is booting (StdoutProducer), starting at Position[BinlogPosition[mysql-bin.000001:3997], lastHeartbeat=0] 14:12:02,146 INFO AbstractSchemaStore - Maxwell is capturing initial schema 14:12:02,328 INFO BinlogConnectorReplicator - Setting initial binlog pos to: mysql-bin.000001:3997 14:12:02,383 INFO BinaryLogClient - Connected to 127.0.0.1:3306 at mysql-bin.000001/3997 (sid:6379, cid:7) {"database":"hivetest","table":"test","type":"insert","ts":1506319983,"xid":142,"commit":true,"data":{"id":168,"name":"11111","age":12313,"create_time":"2017-09-25 06:13:03"}} 

ok,測試成功。
后台啟動maxwell,並將數據發送到kafka(需要先在kafka中建好topic)

[root@datanode1 ~]# nohup bin/maxwell --user='maxwell' --password='123456' --host='127.0.0


作者:觀天壞笑
鏈接:https://www.jianshu.com/p/5621e801f142
來源:簡書
簡書著作權歸作者所有,任何形式的轉載都請聯系作者獲得授權並注明出處。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM