今天kafka启动之后,刚开始输入jps还有进程,大概几秒钟不一会儿就关闭了,我这边是-daemon守护进程的方式启动的,到kafka下面的logs文件夹查看server.log日志发现了报错
[2019-01-05 11:02:00,473] INFO Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2019-01-05 11:02:01,410] INFO Opening socket connection to server slave2/192.168.116.12:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2019-01-05 11:02:01,412] INFO Socket connection established to slave2/192.168.116.12:2181, initiating session (org.apache.zookeeper.ClientCnxn)
[2019-01-05 11:02:01,423] INFO Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2019-01-05 11:02:02,343] INFO Opening socket connection to server master/192.168.116.10:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2019-01-05 11:02:02,344] INFO Socket connection established to master/192.168.116.10:2181, initiating session (org.apache.zookeeper.ClientCnxn)
[2019-01-05 11:02:02,345] INFO Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2019-01-05 11:02:04,115] INFO Opening socket connection to server slave1/192.168.116.11:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2019-01-05 11:02:04,116] INFO Socket connection established to slave1/192.168.116.11:2181, initiating session (org.apache.zookeeper.ClientCnxn)
[2019-01-05 11:02:04,119] INFO Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2019-01-05 11:02:05,132] INFO Opening socket connection to server slave2/192.168.116.12:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2019-01-05 11:02:05,134] INFO Socket connection established to slave2/192.168.116.12:2181, initiating session (org.apache.zookeeper.ClientCnxn)
[2019-01-05 11:02:05,137] INFO Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2019-01-05 11:02:05,854] INFO Opening socket connection to server master/192.168.116.10:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2019-01-05 11:02:05,855] INFO Socket connection established to master/192.168.116.10:2181, initiating session (org.apache.zookeeper.ClientCnxn)
[2019-01-05 11:02:05,857] INFO Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2019-01-05 11:02:06,460] INFO Terminate ZkClient event thread. (org.I0Itec.zkclient.ZkEventThread)
[2019-01-05 11:02:06,918] INFO EventThread shut down for session: 0x0 (org.apache.zookeeper.ClientCnxn)
[2019-01-05 11:02:06,918] INFO Session: 0x0 closed (org.apache.zookeeper.ZooKeeper)
[2019-01-05 11:02:06,920] FATAL Fatal error during KafkaServer startup. Prepare to shutdown (kafka.server.KafkaServer)
org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server 'master:2181,slave1:2181,slave2:2181' with timeout of 6000 ms
at org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:1233)
at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:157)
at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:131)
at kafka.utils.ZkUtils$.createZkClientAndConnection(ZkUtils.scala:115)
at kafka.utils.ZkUtils$.withMetrics(ZkUtils.scala:92)
at kafka.server.KafkaServer.initZk(KafkaServer.scala:346)
at kafka.server.KafkaServer.startup(KafkaServer.scala:194)
at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:38)
at kafka.Kafka$.main(Kafka.scala:92)
at kafka.Kafka.main(Kafka.scala)
[2019-01-05 11:02:06,928] INFO shutting down (kafka.server.KafkaServer)
我是一共有三台机器,输入jps发现每台机器的zookeeper都有进程在啊。在kafka配置摸索半天也没有结果,百度有人说kafka的server.properties和logs下面的meta.properties里面的broker Id要一样,我就把logs目录清空了,还是一样的问题。后来一想,难道是zookeeper的问题?
我就去看zookeeper的配置,果然发现了问题了。。原来是两台机器的myid配置成一样的数字的,把其中一台机器的myid换个数字(不能是0),结果成功了。