kafka客戶端訪問broker報錯的應對方法
阿新 • • 發佈:2019-02-19
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都連不上,後來只好設定更大,無奈之舉。