创建connector报错

来源:9-4 Kafka Connect Source和MySQL集成

weixin_慕仰1047700

2020-05-06

在本机运行:

curl -X POST -H 'Content-Type: application/json' -i 'http://192.168.153.80:8083/connectors' \
--data \
'{"name":"yujia-upload-mysql","config":{
"connector.class":"io.confluent.connect.jdbc.JdbcSourceConnector",
"connection.url":"jdbc:mysql://172.31.157.183:3306/kafka_study?user=root&password=yujia",
"table.whitelist":"users",
"incrementing.column.name": "uuid",
"mode":"incrementing",
"topic.prefix": "yujia-mysql-"}}'

出现报错

{"error_code":400,"message":"Connector configuration is invalid and contains the following 2 error(s):\n
Invalid value com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure\n\n
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. for configuration Couldn't open connection to jdbc:mysql://172.31.157.183:3306/kafka_study?user=root&password=yujia\n
Invalid value com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure\n\nThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. for configuration Couldn't open connection to jdbc:mysql://172.31.157.183:3306/kafka_study?user=root&password=fanyujia1995\nYou can also find the above list of errors at the endpoint `/{connectorType}/config/validate`"}~ fanyuji
写回答

3回答

小葱与奥特曼

2022-09-22

可能是centos7连接不上宿主机的msyql,权限不够导致

可以在宿主机上执行如下msyql命令

1、登录

mysql -u root -p

2、查询mysql用户

select user,host,authentication_string from mysql.user;

3、 切换到mysql库

use mysql;

4、 修改root用户host

update user set host='%' where user='root'。

5、刷新权限

flush privileges;


0
0

Allen

2020-05-06

//img.mukewang.com/szimg/5eb277a40904cc4722610250.jpg

这个错误已经挺明显了, 要么是URL不对, 要么是数据库信息不对, 要么是驱动包版本不匹配

0
2
Allen
回复
weixin_慕仰1047700
可以先用本地的数据库客户端连接一下试试, 然后把配置写回来
2020-05-08
共2条回复

Allen

2020-05-06

数据库URL写的格式不对, 可以检查一下

0
2
weixin_慕仰1047700
我是在mac上用ifconfig命令行查看的ip地址
2020-05-06
共2条回复

Kafka多维度系统精讲,从入门到实战开发

系统讲解Kafka,实战结合,让你成为使用Kafka的高手

896 学习 · 237 问题

查看课程