下载以下文件,解压,放置到kafka的libs目录
从这里选择适合的mysql connector
https://dev.mysql.com/downloads/connector/j/
将里面的jar文件提取出来,也放到kafka的libs目录
在config目录下创建 connect-mysql-source.properties
内容为
name=mysql-jdbc-autoincrement
connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
tasks.max=1
connection.url=jdbc:mysql://192.168.101.3:3306/tablename?user=xxx&password=xxx
mode=incrementing
incrementing.column.name=HeatMapId
topic.prefix=mysql-jdbc-
注意更改jdbc的表名,用户名 密码
./kafka-server-start.sh ../config/server.properties &
bin/connect-standalone.sh config/connect-standalone.properties config/connect-mysql-source.properties &
如果报
The server time zone value ” is unrecognized or represents more than one time 。。。
以命令行进入mysql
mysql> show variables like ‘%time_zone%‘;
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| system_time_zone | |
| time_zone | SYSTEM |
+------------------+--------+
2 rows in set
如果输出结果是system
设置time_zone
即可
mysql> set global time_zone=‘+8:00‘;
Query OK, 0 rows affected
原文:https://www.cnblogs.com/zgzf/p/10883010.html