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都連不上,後來只好設置更大,無奈之舉。