kafka客户端访问broker报错的应对方法

1、kafka客户端访问broker报错

"kafka Failed to send messages after 3 tries”,异常堆栈在此略去,因为也没有更多信息。

官方例子的问答中有人解答:将config/server.properties中的host.name修改为ip即可。试了,确实如此。没阅读源码,原因还未分析。

参考:https://cwiki.apache.org/confluence/display/KAFKA/0.8.0+Producer+Example的问答


2、consumer连接broker报错

ExceptiException in thread "main" org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within timeout: 400

网友答复:props.put("zookeeper.session.timeout.ms", "4000");将timeout数值调大。

"zookeeper.session.timeout.ms"的功能是“If the server fails to heartbeat to zookeeper within this period of time it is considered dead.”也就是broker和zk之间心跳,如果超过这个时间,则认为服务器已经挂掉。

问题是,我这里服务器配置和网络太差,以至于我把这个数值设为4000ms都连不上,后来只好设置更大,无奈之举。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章