WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn) java.net.ConnectException: Connection refused
1、启动kafka的脚本程序报如下所示的错误:
1 [hadoop@slaver1 script_hadoop]$ kafka-start.sh 2 start kafkaServer... 3 [2018-05-22 09:29:08,783] INFO Verifying properties (kafka.utils.VerifiableProperties) 4 [2018-05-22 09:29:08,942] INFO Property broker.id is overridden to 1 (kafka.utils.VerifiableProperties) 5 [2018-05-22 09:29:08,943] INFO Property log.cleaner.enable is overridden to false (kafka.utils.VerifiableProperties) 6 [2018-05-22 09:29:08,945] INFO Property log.dirs is overridden to /tmp/kafka-logs (kafka.utils.VerifiableProperties) 7 [2018-05-22 09:29:08,946] INFO Property log.retention.check.interval.ms is overridden to 60000 (kafka.utils.VerifiableProperties) 8 [2018-05-22 09:29:08,946] INFO Property log.retention.hours is overridden to 168 (kafka.utils.VerifiableProperties) 9 [2018-05-22 09:29:08,947] INFO Property log.segment.bytes is overridden to 536870912 (kafka.utils.VerifiableProperties) 10 [2018-05-22 09:29:08,947] INFO Property num.io.threads is overridden to 8 (kafka.utils.VerifiableProperties) 11 [2018-05-22 09:29:08,949] INFO Property num.network.threads is overridden to 2 (kafka.utils.VerifiableProperties) 12 [2018-05-22 09:29:08,950] INFO Property num.partitions is overridden to 2 (kafka.utils.VerifiableProperties) 13 [2018-05-22 09:29:08,951] INFO Property port is overridden to 9092 (kafka.utils.VerifiableProperties) 14 [2018-05-22 09:29:08,952] INFO Property socket.receive.buffer.bytes is overridden to 1048576 (kafka.utils.VerifiableProperties) 15 [2018-05-22 09:29:08,953] INFO Property socket.request.max.bytes is overridden to 104857600 (kafka.utils.VerifiableProperties) 16 [2018-05-22 09:29:08,953] INFO Property socket.send.buffer.bytes is overridden to 1048576 (kafka.utils.VerifiableProperties) 17 [2018-05-22 09:29:08,954] INFO Property zookeeper.connect is overridden to slaver1:2181,slaver2:2181,slaver3:2181 (kafka.utils.VerifiableProperties) 18 [2018-05-22 09:29:08,955] INFO Property zookeeper.connection.timeout.ms is overridden to 1000000 (kafka.utils.VerifiableProperties) 19 [2018-05-22 09:29:09,031] INFO [Kafka Server 1], starting (kafka.server.KafkaServer) 20 [2018-05-22 09:29:09,034] INFO [Kafka Server 1], Connecting to zookeeper on slaver1:2181,slaver2:2181,slaver3:2181 (kafka.server.KafkaServer) 21 [2018-05-22 09:29:09,153] INFO Starting ZkClient event thread. (org.I0Itec.zkclient.ZkEventThread) 22 [2018-05-22 09:29:09,226] INFO Client environment:zookeeper.version=3.3.3-1203054, built on 11/17/2011 05:47 GMT (org.apache.zookeeper.ZooKeeper) 23 [2018-05-22 09:29:09,226] INFO Client environment:host.name=slaver1 (org.apache.zookeeper.ZooKeeper) 24 [2018-05-22 09:29:09,226] INFO Client environment:java.version=1.7.0_79 (org.apache.zookeeper.ZooKeeper) 25 [2018-05-22 09:29:09,227] INFO Client environment:java.vendor=Oracle Corporation (org.apache.zookeeper.ZooKeeper) 26 [2018-05-22 09:29:09,227] INFO Client environment:java.home=/home/hadoop/soft/jdk1.7.0_79/jre (org.apache.zookeeper.ZooKeeper) 27 [2018-05-22 09:29:09,227] INFO Client environment:java.class.path=:/home/hadoop/soft/kafka_2.9.2-0.8.1/bin/../core/build/dependant-libs-2.8.0/*.jar:/home/hadoop/soft/kafka_2.9.2-0.8.1/bin/../perf/build/libs//kafka-perf_2.8.0*.jar:/home/hadoop/soft/kafka_2.9.2-0.8.1/bin/../clients/build/libs//kafka-clients*.jar:/home/hadoop/soft/kafka_2.9.2-0.8.1/bin/../examples/build/libs//kafka-examples*.jar:/home/hadoop/soft/kafka_2.9.2-0.8.1/bin/../contrib/hadoop-consumer/build/libs//kafka-hadoop-consumer*.jar:/home/hadoop/soft/kafka_2.9.2-0.8.1/bin/../contrib/hadoop-producer/build/libs//kafka-hadoop-producer*.jar:/home/hadoop/soft/kafka_2.9.2-0.8.1/bin/../libs/jopt-simple-3.2.jar:/home/hadoop/soft/kafka_2.9.2-0.8.1/bin/../libs/kafka_2.9.2-0.8.1.jar:/home/hadoop/soft/kafka_2.9.2-0.8.1/bin/../libs/log4j-1.2.15.jar:/home/hadoop/soft/kafka_2.9.2-0.8.1/bin/../libs/metrics-annotation-2.2.0.jar:/home/hadoop/soft/kafka_2.9.2-0.8.1/bin/../libs/metrics-core-2.2.0.jar:/home/hadoop/soft/kafka_2.9.2-0.8.1/bin/../libs/scala-library-2.9.2.jar:/home/hadoop/soft/kafka_2.9.2-0.8.1/bin/../libs/slf4j-api-1.7.2.jar:/home/hadoop/soft/kafka_2.9.2-0.8.1/bin/../libs/slf4j-nop-1.7.6.jar:/home/hadoop/soft/kafka_2.9.2-0.8.1/bin/../libs/snappy-java-1.0.5.jar:/home/hadoop/soft/kafka_2.9.2-0.8.1/bin/../libs/zkclient-0.3.jar:/home/hadoop/soft/kafka_2.9.2-0.8.1/bin/../libs/zookeeper-3.3.4.jar:/home/hadoop/soft/kafka_2.9.2-0.8.1/bin/../core/build/libs/kafka_2.8.0*.jar (org.apache.zookeeper.ZooKeeper) 28 [2018-05-22 09:29:09,227] INFO Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib (org.apache.zookeeper.ZooKeeper) 29 [2018-05-22 09:29:09,227] INFO Client environment:java.io.tmpdir=/tmp (org.apache.zookeeper.ZooKeeper) 30 [2018-05-22 09:29:09,227] INFO Client environment:java.compiler=<NA> (org.apache.zookeeper.ZooKeeper) 31 [2018-05-22 09:29:09,227] INFO Client environment:os.name=Linux (org.apache.zookeeper.ZooKeeper) 32 [2018-05-22 09:29:09,227] INFO Client environment:os.arch=amd64 (org.apache.zookeeper.ZooKeeper) 33 [2018-05-22 09:29:09,228] INFO Client environment:os.version=2.6.32-358.el6.x86_64 (org.apache.zookeeper.ZooKeeper) 34 [2018-05-22 09:29:09,228] INFO Client environment:user.name=hadoop (org.apache.zookeeper.ZooKeeper) 35 [2018-05-22 09:29:09,228] INFO Client environment:user.home=/home/hadoop (org.apache.zookeeper.ZooKeeper) 36 [2018-05-22 09:29:09,228] INFO Client environment:user.dir=/home/hadoop (org.apache.zookeeper.ZooKeeper) 37 [2018-05-22 09:29:09,230] INFO Initiating client connection, connectString=slaver1:2181,slaver2:2181,slaver3:2181 sessionTimeout=6000 watcher=org.I0Itec.zkclient.ZkClient@458dd138 (org.apache.zookeeper.ZooKeeper) 38 [2018-05-22 09:29:09,377] INFO Opening socket connection to server slaver1/192.168.19.131:2181 (org.apache.zookeeper.ClientCnxn) 39 [2018-05-22 09:29:09,443] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn) 40 java.net.ConnectException: Connection refused 41 at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) 42 at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739) 43 at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1146) 44 [2018-05-22 09:29:10,410] INFO Opening socket connection to server slaver2/192.168.19.132:2181 (org.apache.zookeeper.ClientCnxn) 45 [2018-05-22 09:29:10,415] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn) 46 java.net.ConnectException: Connection refused 47 at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) 48 at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739) 49 at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1146) 50 [2018-05-22 09:29:11,111] INFO Opening socket connection to server slaver3/192.168.19.133:2181 (org.apache.zookeeper.ClientCnxn) 51 [2018-05-22 09:29:11,112] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn) 52 java.net.ConnectException: Connection refused 53 at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) 54 at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739) 55 at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1146) 56 [2018-05-22 09:29:13,211] INFO Opening socket connection to server slaver1/192.168.19.131:2181 (org.apache.zookeeper.ClientCnxn) 57 [2018-05-22 09:29:13,212] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn) 58 java.net.ConnectException: Connection refused 59 at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) 60 at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739) 61 at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1146) 62 [2018-05-22 09:29:14,198] INFO Opening socket connection to server slaver2/192.168.19.132:2181 (org.apache.zookeeper.ClientCnxn) 63 [2018-05-22 09:29:14,199] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn) 64 java.net.ConnectException: Connection refused 65 at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) 66 at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739) 67 at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1146) 68 [2018-05-22 09:29:14,981] INFO Opening socket connection to server slaver3/192.168.19.133:2181 (org.apache.zookeeper.ClientCnxn) 69 [2018-05-22 09:29:14,982] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn) 70 java.net.ConnectException: Connection refused 71 at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) 72 at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739) 73 at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1146) 74 [2018-05-22 09:29:16,581] INFO Opening socket connection to server slaver1/192.168.19.131:2181 (org.apache.zookeeper.ClientCnxn) 75 [2018-05-22 09:29:16,582] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn) 76 java.net.ConnectException: Connection refused 77 at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) 78 at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739) 79 at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1146) 80 [2018-05-22 09:29:16,891] INFO Opening socket connection to server slaver2/192.168.19.132:2181 (org.apache.zookeeper.ClientCnxn) 81 [2018-05-22 09:29:16,893] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn) 82 java.net.ConnectException: Connection refused 83 at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) 84 at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739) 85 at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1146) 86 [2018-05-22 09:29:17,756] INFO Opening socket connection to server slaver3/192.168.19.133:2181 (org.apache.zookeeper.ClientCnxn) 87 [2018-05-22 09:29:17,757] WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn) 88 java.net.ConnectException: Connection refused 89 at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) 90 at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739) 91 at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1146) 92 ^CKilled by signal 2. 93 ^CKilled by signal 2. 94 ^CKilled by signal 2. 95 [hadoop@slaver1 script_hadoop]$ ^C 96 [hadoop@slaver1 script_hadoop]$
2、根据错误分析,说zookeeper的问题,之前我没有启动zookeeper集群,所以先启动zookeeper集群,然后启动kafka解决问题;