kafka:启动停止方式

kafka 专栏收录该内容
30 篇文章 4 订阅

本人环境:

3台虚拟机分别为

sparkproject1   192.168.124.110

sparkproject2   192.168.124.111 

sparkproject3   192.168.124.112

参考:

https://blog.csdn.net/weixin_38750084/article/details/90650015

 

首先我们先看下没有启动zk时,先启动kafka会怎样:


Connecting to 192.168.124.110:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Last login: Tue Oct 23 00:02:10 2018 from 192.168.124.12
[root@sparkproject1 ~]# jps
30452 NameNode
29898 ResourceManager
30619 SecondaryNameNode
31002 Jps
30762 DataNode
[root@sparkproject1 ~]# cd /usr/local/kafka/
You have new mail in /var/spool/mail/root
[root@sparkproject1 kafka]# ll
total 32
drwxr-xr-x 3 root root  4096 Aug 18 15:29 bin
drwxr-xr-x 2 root root  4096 Oct  7 20:39 config
drwxr-xr-x 2 root root  4096 Aug 18 15:22 libs
-rw-rw-r-- 1 root root 11358 Mar  5  2014 LICENSE
-rw-r--r-- 1 root root     0 Aug 18 15:32 log-cleaner.log
drwxr-xr-x 2 root root  4096 Oct 22 03:45 logs
-rw-rw-r-- 1 root root   162 Mar  5  2014 NOTICE
[root@sparkproject1 kafka]# cd bin/
[root@sparkproject1 bin]# pwd
/usr/local/kafka/bin
[root@sparkproject1 bin]# zookeeper-server-start.sh /usr/local/kafka/config/zookeeper.properties &
[1] 31246
You have new mail in /var/spool/mail/root
[root@sparkproject1 bin]# -bash: zookeeper-server-start.sh: command not found

[1]+  Exit 127                zookeeper-server-start.sh /usr/local/kafka/config/zookeeper.properties
[root@sparkproject1 bin]# 
[root@sparkproject1 bin]# 
[root@sparkproject1 bin]# 
[root@sparkproject1 bin]# 
[root@sparkproject1 bin]# 
[root@sparkproject1 bin]# 
[root@sparkproject1 bin]# 
[root@sparkproject1 bin]# 
[root@sparkproject1 bin]# 
[root@sparkproject1 bin]# ll
total 72
-rwxrwxr-x 1 root root  901 Mar  5  2014 kafka-console-consumer.sh
-rwxrwxr-x 1 root root  901 Mar  5  2014 kafka-console-producer.sh
-rwxrwxr-x 1 root root  901 Mar  5  2014 kafka-consumer-perf-test.sh
-rwxrwxr-x 1 root root  884 Mar  5  2014 kafka-preferred-replica-election.sh
-rwxrwxr-x 1 root root  901 Mar  5  2014 kafka-producer-perf-test.sh
-rwxrwxr-x 1 root root  872 Mar  5  2014 kafka-reassign-partitions.sh
-rwxrwxr-x 1 root root  866 Mar  5  2014 kafka-replay-log-producer.sh
-rwxrwxr-x 1 root root 4171 Aug 18 15:29 kafka-run-class.sh
-rwxrwxr-x 1 root root 1238 Mar  5  2014 kafka-server-start.sh
-rwxrwxr-x 1 root root  890 Mar  5  2014 kafka-server-stop.sh
-rwxrwxr-x 1 root root  907 Mar  5  2014 kafka-simple-consumer-perf-test.sh
-rwxrwxr-x 1 root root  868 Mar  5  2014 kafka-simple-consumer-shell.sh
-rwxrwxr-x 1 root root  861 Mar  5  2014 kafka-topics.sh
drwxrwxr-x 2 root root 4096 Mar  5  2014 windows
-rwxrwxr-x 1 root root 1275 Mar  5  2014 zookeeper-server-start.sh
-rwxrwxr-x 1 root root  875 Mar  5  2014 zookeeper-server-stop.sh
-rwxrwxr-x 1 root root  968 Mar  5  2014 zookeeper-shell.sh
[root@sparkproject1 bin]# zookeeper-server-start.sh /usr/local/kafka/config/zookeeper.properties &^C
[root@sparkproject1 bin]# cd ..
[root@sparkproject1 kafka]# cd ..
[root@sparkproject1 local]# zookeeper-server-start.sh /usr/local/kafka/config/zookeeper.properties &
[1] 31262
[root@sparkproject1 local]# -bash: zookeeper-server-start.sh: command not found
^C
[1]+  Exit 127                zookeeper-server-start.sh /usr/local/kafka/config/zookeeper.properties
[root@sparkproject1 local]# bin/zookeeper-server-start.sh /usr/local/kafka/config/zookeeper.properties &
[1] 31263
[root@sparkproject1 local]# -bash: bin/zookeeper-server-start.sh: No such file or directory
^C
You have new mail in /var/spool/mail/root
[1]+  Exit 127                bin/zookeeper-server-start.sh /usr/local/kafka/config/zookeeper.properties
[root@sparkproject1 local]# bin/zookeeper-server-start.sh config/zookeeper.properties &
[1] 31264
[root@sparkproject1 local]# -bash: bin/zookeeper-server-start.sh: No such file or directory
^C
[1]+  Exit 127                bin/zookeeper-server-start.sh config/zookeeper.properties
[root@sparkproject1 local]# cd kafka/
[root@sparkproject1 kafka]# bin/zookeeper-server-start.sh config/zookeeper.properties &
[1] 31276
[root@sparkproject1 kafka]# [2018-10-23 03:03:14,355] INFO Reading configuration from: config/zookeeper.properties (org.apache.zookeeper.server.quorum.QuorumPeerConfig)
[2018-10-23 03:03:14,358] WARN Either no config or no quorum defined in config, running  in standalone mode (org.apache.zookeeper.server.quorum.QuorumPeerMain)
[2018-10-23 03:03:14,430] INFO Reading configuration from: config/zookeeper.properties (org.apache.zookeeper.server.quorum.QuorumPeerConfig)
[2018-10-23 03:03:14,437] INFO Starting server (org.apache.zookeeper.server.ZooKeeperServerMain)
[2018-10-23 03:03:14,475] INFO Server environment:zookeeper.version=3.3.3-1203054, built on 11/17/2011 05:47 GMT (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,476] INFO Server environment:host.name=sparkproject1 (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,476] INFO Server environment:java.version=1.7.0_65 (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,476] INFO Server environment:java.vendor=Oracle Corporation (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,478] INFO Server environment:java.home=/usr/java/jdk1.7.0_65/jre (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,479] INFO Server environment:java.class.path=.::/usr/java/latest/lib:/usr/java/latest/jre/lib:/usr/local/kafka/bin/../core/build/dependant-libs-2.8.0/*.jar:/usr/local/kafka/bin/../perf/build/libs//kafka-perf_2.8.0*.jar:/usr/local/kafka/bin/../clients/build/libs//kafka-clients*.jar:/usr/local/kafka/bin/../examples/build/libs//kafka-examples*.jar:/usr/local/kafka/bin/../contrib/hadoop-consumer/build/libs//kafka-hadoop-consumer*.jar:/usr/local/kafka/bin/../contrib/hadoop-producer/build/libs//kafka-hadoop-producer*.jar:/usr/local/kafka/bin/../libs/jopt-simple-3.2.jar:/usr/local/kafka/bin/../libs/kafka_2.9.2-0.8.1.jar:/usr/local/kafka/bin/../libs/log4j-1.2.15.jar:/usr/local/kafka/bin/../libs/metrics-annotation-2.2.0.jar:/usr/local/kafka/bin/../libs/metrics-core-2.2.0.jar:/usr/local/kafka/bin/../libs/scala-library-2.9.2.jar:/usr/local/kafka/bin/../libs/slf4j-api-1.7.2.jar:/usr/local/kafka/bin/../libs/slf4j-nop-1.7.6.jar:/usr/local/kafka/bin/../libs/snappy-java-1.0.5.jar:/usr/local/kafka/bin/../libs/zkclient-0.3.jar:/usr/local/kafka/bin/../libs/zookeeper-3.3.4.jar:/usr/local/kafka/bin/../core/build/libs/kafka_2.8.0*.jar (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,479] INFO Server environment:java.library.path=/usr/java/packages/lib/i386:/lib:/usr/lib (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,479] INFO Server environment:java.io.tmpdir=/tmp (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,479] INFO Server environment:java.compiler=<NA> (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,479] INFO Server environment:os.name=Linux (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,480] INFO Server environment:os.arch=i386 (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,480] INFO Server environment:os.version=2.6.32-358.el6.i686 (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,480] INFO Server environment:user.name=root (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,484] INFO Server environment:user.home=/root (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,485] INFO Server environment:user.dir=/usr/local/kafka (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,511] INFO tickTime set to 3000 (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,511] INFO minSessionTimeout set to -1 (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,511] INFO maxSessionTimeout set to -1 (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,573] INFO binding to port 0.0.0.0/0.0.0.0:2181 (org.apache.zookeeper.server.NIOServerCnxn)
[2018-10-23 03:03:14,610] INFO Snapshotting: 0 (org.apache.zookeeper.server.persistence.FileTxnSnapLog)

[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# jps
30452 NameNode
29898 ResourceManager
30619 SecondaryNameNode
31276 QuorumPeerMain
30762 DataNode
31295 Jps
[root@sparkproject1 kafka]# kill -9 31276
You have new mail in /var/spool/mail/root
[root@sparkproject1 kafka]# 
[1]+  Killed                  bin/zookeeper-server-start.sh config/zookeeper.properties
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# jps
30452 NameNode
29898 ResourceManager
30619 SecondaryNameNode
30762 DataNode
31304 Jps
[root@sparkproject1 kafka]# 
You have new mail in /var/spool/mail/root
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# clear
[root@sparkproject1 kafka]# 31276 QuorumPeerMain^C
[root@sparkproject1 kafka]# bin/kafka-server-start.sh config/server.properties &
[1] 31362
[root@sparkproject1 kafka]# [2018-10-23 03:07:34,518] INFO Verifying properties (kafka.utils.VerifiableProperties)
[2018-10-23 03:07:34,629] INFO Property broker.id is overridden to 0 (kafka.utils.VerifiableProperties)
[2018-10-23 03:07:34,630] INFO Property log.cleaner.enable is overridden to false (kafka.utils.VerifiableProperties)
[2018-10-23 03:07:34,630] INFO Property log.dirs is overridden to /tmp/kafka-logs (kafka.utils.VerifiableProperties)
[2018-10-23 03:07:34,631] INFO Property log.retention.check.interval.ms is overridden to 60000 (kafka.utils.VerifiableProperties)
[2018-10-23 03:07:34,632] INFO Property log.retention.hours is overridden to 168 (kafka.utils.VerifiableProperties)
[2018-10-23 03:07:34,633] INFO Property log.segment.bytes is overridden to 536870912 (kafka.utils.VerifiableProperties)
[2018-10-23 03:07:34,634] INFO Property num.io.threads is overridden to 8 (kafka.utils.VerifiableProperties)
[2018-10-23 03:07:34,635] INFO Property num.network.threads is overridden to 2 (kafka.utils.VerifiableProperties)
[2018-10-23 03:07:34,636] INFO Property num.partitions is overridden to 2 (kafka.utils.VerifiableProperties)
[2018-10-23 03:07:34,636] INFO Property port is overridden to 9092 (kafka.utils.VerifiableProperties)
[2018-10-23 03:07:34,637] INFO Property socket.receive.buffer.bytes is overridden to 1048576 (kafka.utils.VerifiableProperties)
[2018-10-23 03:07:34,638] INFO Property socket.request.max.bytes is overridden to 104857600 (kafka.utils.VerifiableProperties)
[2018-10-23 03:07:34,639] INFO Property socket.send.buffer.bytes is overridden to 1048576 (kafka.utils.VerifiableProperties)
[2018-10-23 03:07:34,639] INFO Property zookeeper.connect is overridden to 192.168.1.28:2181,192.168.1.31:2181,192.168.1.32:2181 (kafka.utils.VerifiableProperties)
[2018-10-23 03:07:34,641] INFO Property zookeeper.connection.timeout.ms is overridden to 1000000 (kafka.utils.VerifiableProperties)
[2018-10-23 03:07:34,724] INFO [Kafka Server 0], starting (kafka.server.KafkaServer)
[2018-10-23 03:07:34,729] INFO [Kafka Server 0], Connecting to zookeeper on 192.168.1.28:2181,192.168.1.31:2181,192.168.1.32:2181 (kafka.server.KafkaServer)
[2018-10-23 03:07:34,764] INFO Starting ZkClient event thread. (org.I0Itec.zkclient.ZkEventThread)
[2018-10-23 03:07:34,793] INFO Client environment:zookeeper.version=3.3.3-1203054, built on 11/17/2011 05:47 GMT (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:07:34,793] INFO Client environment:host.name=sparkproject1 (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:07:34,793] INFO Client environment:java.version=1.7.0_65 (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:07:34,793] INFO Client environment:java.vendor=Oracle Corporation (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:07:34,793] INFO Client environment:java.home=/usr/java/jdk1.7.0_65/jre (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:07:34,793] INFO Client environment:java.class.path=.::/usr/java/latest/lib:/usr/java/latest/jre/lib:/usr/local/kafka/bin/../core/build/dependant-libs-2.8.0/*.jar:/usr/local/kafka/bin/../perf/build/libs//kafka-perf_2.8.0*.jar:/usr/local/kafka/bin/../clients/build/libs//kafka-clients*.jar:/usr/local/kafka/bin/../examples/build/libs//kafka-examples*.jar:/usr/local/kafka/bin/../contrib/hadoop-consumer/build/libs//kafka-hadoop-consumer*.jar:/usr/local/kafka/bin/../contrib/hadoop-producer/build/libs//kafka-hadoop-producer*.jar:/usr/local/kafka/bin/../libs/jopt-simple-3.2.jar:/usr/local/kafka/bin/../libs/kafka_2.9.2-0.8.1.jar:/usr/local/kafka/bin/../libs/log4j-1.2.15.jar:/usr/local/kafka/bin/../libs/metrics-annotation-2.2.0.jar:/usr/local/kafka/bin/../libs/metrics-core-2.2.0.jar:/usr/local/kafka/bin/../libs/scala-library-2.9.2.jar:/usr/local/kafka/bin/../libs/slf4j-api-1.7.2.jar:/usr/local/kafka/bin/../libs/slf4j-nop-1.7.6.jar:/usr/local/kafka/bin/../libs/snappy-java-1.0.5.jar:/usr/local/kafka/bin/../libs/zkclient-0.3.jar:/usr/local/kafka/bin/../libs/zookeeper-3.3.4.jar:/usr/local/kafka/bin/../core/build/libs/kafka_2.8.0*.jar (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:07:34,794] INFO Client environment:java.library.path=/usr/java/packages/lib/i386:/lib:/usr/lib (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:07:34,794] INFO Client environment:java.io.tmpdir=/tmp (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:07:34,794] INFO Client environment:java.compiler=<NA> (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:07:34,795] INFO Client environment:os.name=Linux (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:07:34,795] INFO Client environment:os.arch=i386 (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:07:34,795] INFO Client environment:os.version=2.6.32-358.el6.i686 (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:07:34,795] INFO Client environment:user.name=root (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:07:34,795] INFO Client environment:user.home=/root (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:07:34,795] INFO Client environment:user.dir=/usr/local/kafka (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:07:34,798] INFO Initiating client connection, connectString=192.168.1.28:2181,192.168.1.31:2181,192.168.1.32:2181 sessionTimeout=6000 watcher=org.I0Itec.zkclient.ZkClient@d20835 (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:07:34,888] INFO Opening socket connection to server /192.168.1.31:2181 (org.apache.zookeeper.ClientCnxn)

[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# jps
30452 NameNode
31362 Kafka
29898 ResourceManager
30619 SecondaryNameNode
30762 DataNode
31380 Jps
[root@sparkproject1 kafka]# [2018-10-23 03:07:51,988] INFO Client session timed out, have not heard from server in 17100ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:07:52,495] INFO Opening socket connection to server /192.168.1.28:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:07:54,557] INFO Client session timed out, have not heard from server in 2464ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:07:54,874] INFO Opening socket connection to server /192.168.1.32:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:07:56,947] INFO Client session timed out, have not heard from server in 2289ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:07:58,514] INFO Opening socket connection to server 192.168.1.31/192.168.1.31:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:08:00,516] INFO Client session timed out, have not heard from server in 3469ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:08:00,664] INFO Opening socket connection to server 192.168.1.28/192.168.1.28:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:08:02,667] INFO Client session timed out, have not heard from server in 2050ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:08:02,888] INFO Opening socket connection to server 192.168.1.32/192.168.1.32:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:08:04,891] INFO Client session timed out, have not heard from server in 2123ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:08:06,279] INFO Opening socket connection to server 192.168.1.31/192.168.1.31:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:08:08,282] INFO Client session timed out, have not heard from server in 3289ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:08:08,797] INFO Opening socket connection to server 192.168.1.28/192.168.1.28:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:08:10,800] INFO Client session timed out, have not heard from server in 2417ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:08:11,143] INFO Opening socket connection to server 192.168.1.32/192.168.1.32:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:08:13,146] INFO Client session timed out, have not heard from server in 2245ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
^C
You have new mail in /var/spool/mail/root
[root@sparkproject1 kafka]# [2018-10-23 03:08:14,939] INFO Opening socket connection to server 192.168.1.31/192.168.1.31:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:08:16,941] INFO Client session timed out, have not heard from server in 3695ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:08:17,713] INFO Opening socket connection to server 192.168.1.28/192.168.1.28:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:08:19,716] INFO Client session timed out, have not heard from server in 2675ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:08:20,390] INFO Opening socket connection to server 192.168.1.32/192.168.1.32:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:08:22,395] INFO Client session timed out, have not heard from server in 2578ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:08:24,446] INFO Opening socket connection to server 192.168.1.31/192.168.1.31:2181 (org.apache.zookeeper.ClientCnxn)

会一直这样提示下去,提示未连接zk。

因为我是 配的集群,它会尝试连接我各台机器的 zk:

[2018-10-23 03:13:39,551] INFO Client session timed out, have not heard from server in 2016ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:13:40,720] INFO Opening socket connection to server 192.168.1.31/192.168.1.31:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:13:42,722] INFO Client session timed out, have not heard from server in 3070ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:13:43,734] INFO Opening socket connection to server 192.168.1.28/192.168.1.28:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:13:45,737] INFO Client session timed out, have not heard from server in 2914ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:13:45,915] INFO Opening socket connection to server 192.168.1.32/192.168.1.32:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:13:47,917] INFO Client session timed out, have not heard from server in 2080ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:13:49,273] INFO Opening socket connection to server 192.168.1.31/192.168.1.31:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:13:51,276] INFO Client session timed out, have not heard from server in 3258ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:13:51,442] INFO Opening socket connection to server 192.168.1.28/192.168.1.28:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:13:53,445] INFO Client session timed out, have not heard from server in 2067ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:13:53,940] INFO Opening socket connection to server 192.168.1.32/192.168.1.32:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:13:55,944] INFO Client session timed out, have not heard from server in 2398ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:13:57,207] INFO Opening socket connection to server 192.168.1.31/192.168.1.31:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:13:59,210] INFO Client session timed out, have not heard from server in 3166ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:13:59,942] INFO Opening socket connection to server 192.168.1.28/192.168.1.28:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:14:01,943] INFO Client session timed out, have not heard from server in 2632ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:14:02,421] INFO Opening socket connection to server 192.168.1.32/192.168.1.32:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:14:04,424] INFO Client session timed out, have not heard from server in 2379ms for sessionid 0x0, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:14:05,

如果kafka一直连不上就会自动停掉。

[2018-10-23 03:29:00,341] INFO Opening socket connection to server 192.168.1.32/192.168.1.32:2181 (org.apache.zo
[2018-10-23 03:29:01,334] INFO Terminate ZkClient event thread. (org.I0Itec.zkclient.ZkEventThread)
[2018-10-23 03:29:01,801] INFO Session: 0x0 closed (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:29:01,802] INFO EventThread shut down (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:29:01,901] FATAL Fatal error during KafkaServerStable startup. Prepare to shutdown (kafka.server.
org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within timeout: 1000000
	at org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:880)
	at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:98)
	at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:84)
	at kafka.server.KafkaServer.initZk(KafkaServer.scala:113)
	at kafka.server.KafkaServer.startup(KafkaServer.scala:69)
	at kafka.server.KafkaServerStartable.startup(KafkaServerStartable.scala:34)
	at kafka.Kafka$.main(Kafka.scala:46)
	at kafka.Kafka.main(Kafka.scala)
[2018-10-23 03:29:01,922] INFO [Kafka Server 0], shutting down (kafka.server.KafkaServer)
[2018-10-23 03:29:02,008] INFO [Kafka Server 0], shut down completed (kafka.server.KafkaServer)
[2018-10-23 03:29:02,010] INFO [Kafka Server 0], shutting down (kafka.server.KafkaServer)
[root@sparkproject1 kafka]# 
You have new mail in /var/spool/mail/root

但是看日志,应该是我kafka配置的zk地址使用的还是以前的,这里需要改一下:

将config目录下的server.properties文件的最后的zk的配置修改一下:

修改前:


############################# Zookeeper #############################

# Zookeeper connection string (see zookeeper docs for details).
# This is a comma separated host:port pairs, each corresponding to a zk
# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
# You can also append an optional chroot string to the urls to specify the
# root directory for all kafka znodes.
zookeeper.connect=192.168.1.28:2181,192.168.1.31:2181,192.168.1.32:2181

修改后 :

############################# Zookeeper #############################

# Zookeeper connection string (see zookeeper docs for details).
# This is a comma separated host:port pairs, each corresponding to a zk
# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
# You can also append an optional chroot string to the urls to specify the
# root directory for all kafka znodes.
zookeeper.connect=sparkproject1:2181,sparkproject2:2181,sparkproject3:2181

 

 

 

kafka的启动与停止:

使用kafka自带的zk,分别在3台机器上的kafka目录下执行,启动zk,:

bin/zookeeper-server-start.sh config/zookeeper.properties &

启动日志:

[root@sparkproject1 local]# cd kafka/
[root@sparkproject1 kafka]# bin/zookeeper-server-start.sh config/zookeeper.properties &
[1] 31276
[root@sparkproject1 kafka]# [2018-10-23 03:03:14,355] INFO Reading configuration from: config/zookeeper.properties (org.apache.zookeeper.server.quorum.QuorumPeerConfig)
[2018-10-23 03:03:14,358] WARN Either no config or no quorum defined in config, running  in standalone mode (org.apache.zookeeper.server.quorum.QuorumPeerMain)
[2018-10-23 03:03:14,430] INFO Reading configuration from: config/zookeeper.properties (org.apache.zookeeper.server.quorum.QuorumPeerConfig)
[2018-10-23 03:03:14,437] INFO Starting server (org.apache.zookeeper.server.ZooKeeperServerMain)
[2018-10-23 03:03:14,475] INFO Server environment:zookeeper.version=3.3.3-1203054, built on 11/17/2011 05:47 GMT (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,476] INFO Server environment:host.name=sparkproject1 (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,476] INFO Server environment:java.version=1.7.0_65 (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,476] INFO Server environment:java.vendor=Oracle Corporation (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,478] INFO Server environment:java.home=/usr/java/jdk1.7.0_65/jre (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,479] INFO Server environment:java.class.path=.::/usr/java/latest/lib:/usr/java/latest/jre/lib:/usr/local/kafka/bin/../core/build/dependant-libs-2.8.0/*.jar:/usr/local/kafka/bin/../perf/build/libs//kafka-perf_2.8.0*.jar:/usr/local/kafka/bin/../clients/build/libs//kafka-clients*.jar:/usr/local/kafka/bin/../examples/build/libs//kafka-examples*.jar:/usr/local/kafka/bin/../contrib/hadoop-consumer/build/libs//kafka-hadoop-consumer*.jar:/usr/local/kafka/bin/../contrib/hadoop-producer/build/libs//kafka-hadoop-producer*.jar:/usr/local/kafka/bin/../libs/jopt-simple-3.2.jar:/usr/local/kafka/bin/../libs/kafka_2.9.2-0.8.1.jar:/usr/local/kafka/bin/../libs/log4j-1.2.15.jar:/usr/local/kafka/bin/../libs/metrics-annotation-2.2.0.jar:/usr/local/kafka/bin/../libs/metrics-core-2.2.0.jar:/usr/local/kafka/bin/../libs/scala-library-2.9.2.jar:/usr/local/kafka/bin/../libs/slf4j-api-1.7.2.jar:/usr/local/kafka/bin/../libs/slf4j-nop-1.7.6.jar:/usr/local/kafka/bin/../libs/snappy-java-1.0.5.jar:/usr/local/kafka/bin/../libs/zkclient-0.3.jar:/usr/local/kafka/bin/../libs/zookeeper-3.3.4.jar:/usr/local/kafka/bin/../core/build/libs/kafka_2.8.0*.jar (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,479] INFO Server environment:java.library.path=/usr/java/packages/lib/i386:/lib:/usr/lib (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,479] INFO Server environment:java.io.tmpdir=/tmp (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,479] INFO Server environment:java.compiler=<NA> (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,479] INFO Server environment:os.name=Linux (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,480] INFO Server environment:os.arch=i386 (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,480] INFO Server environment:os.version=2.6.32-358.el6.i686 (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,480] INFO Server environment:user.name=root (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,484] INFO Server environment:user.home=/root (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,485] INFO Server environment:user.dir=/usr/local/kafka (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,511] INFO tickTime set to 3000 (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,511] INFO minSessionTimeout set to -1 (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,511] INFO maxSessionTimeout set to -1 (org.apache.zookeeper.server.ZooKeeperServer)
[2018-10-23 03:03:14,573] INFO binding to port 0.0.0.0/0.0.0.0:2181 (org.apache.zookeeper.server.NIOServerCnxn)
[2018-10-23 03:03:14,610] INFO Snapshotting: 0 (org.apache.zookeeper.server.persistence.FileTxnSnapLog)

[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# jps
30452 NameNode
29898 ResourceManager
30619 SecondaryNameNode
31276 QuorumPeerMain
30762 DataNode
31295 Jps

看到 31276 QuorumPeerMain 已经启动了。

然后启动kafka:

分别3台机器都执行:

[root@sparkproject1 kafka]# bin/kafka-server-start.sh config/server.properties &

启动日志:

sparkproject1:

[root@sparkproject1 kafka]# bin/kafka-server-start.sh config/server.properties &
[2] 31971
[root@sparkproject1 kafka]# [2018-10-23 03:43:18,497] INFO Verifying properties (kafka.utils.VerifiableProperties)
[2018-10-23 03:43:18,592] INFO Property broker.id is overridden to 0 (kafka.utils.VerifiableProperties)
[2018-10-23 03:43:18,593] INFO Property log.cleaner.enable is overridden to false (kafka.utils.VerifiableProperties)
[2018-10-23 03:43:18,594] INFO Property log.dirs is overridden to /tmp/kafka-logs (kafka.utils.VerifiableProperties)
[2018-10-23 03:43:18,594] INFO Property log.retention.check.interval.ms is overridden to 60000 (kafka.utils.VerifiableProperties)
[2018-10-23 03:43:18,595] INFO Property log.retention.hours is overridden to 168 (kafka.utils.VerifiableProperties)
[2018-10-23 03:43:18,595] INFO Property log.segment.bytes is overridden to 536870912 (kafka.utils.VerifiableProperties)
[2018-10-23 03:43:18,596] INFO Property num.io.threads is overridden to 8 (kafka.utils.VerifiableProperties)
[2018-10-23 03:43:18,597] INFO Property num.network.threads is overridden to 2 (kafka.utils.VerifiableProperties)
[2018-10-23 03:43:18,597] INFO Property num.partitions is overridden to 2 (kafka.utils.VerifiableProperties)
[2018-10-23 03:43:18,598] INFO Property port is overridden to 9092 (kafka.utils.VerifiableProperties)
[2018-10-23 03:43:18,598] INFO Property socket.receive.buffer.bytes is overridden to 1048576 (kafka.utils.VerifiableProperties)
[2018-10-23 03:43:18,599] INFO Property socket.request.max.bytes is overridden to 104857600 (kafka.utils.VerifiableProperties)
[2018-10-23 03:43:18,599] INFO Property socket.send.buffer.bytes is overridden to 1048576 (kafka.utils.VerifiableProperties)
[2018-10-23 03:43:18,600] INFO Property zookeeper.connect is overridden to sparkproject1:2181,sparkproject2:2181,sparkproject3:2181 (kafka.utils.VerifiableProperties)
[2018-10-23 03:43:18,601] INFO Property zookeeper.connection.timeout.ms is overridden to 1000000 (kafka.utils.VerifiableProperties)
[2018-10-23 03:43:18,659] INFO [Kafka Server 0], starting (kafka.server.KafkaServer)
[2018-10-23 03:43:18,664] INFO [Kafka Server 0], Connecting to zookeeper on sparkproject1:2181,sparkproject2:2181,sparkproject3:2181 (kafka.server.KafkaServer)
[2018-10-23 03:43:18,714] INFO Starting ZkClient event thread. (org.I0Itec.zkclient.ZkEventThread)
[2018-10-23 03:43:18,729] INFO Client environment:zookeeper.version=3.3.3-1203054, built on 11/17/2011 05:47 GMT (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:43:18,729] INFO Client environment:host.name=sparkproject1 (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:43:18,729] INFO Client environment:java.version=1.7.0_65 (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:43:18,729] INFO Client environment:java.vendor=Oracle Corporation (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:43:18,730] INFO Client environment:java.home=/usr/java/jdk1.7.0_65/jre (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:43:18,730] INFO Client environment:java.class.path=.::/usr/java/latest/lib:/usr/java/latest/jre/lib:/usr/local/kafka/bin/../core/build/dependant-libs-2.8.0/*.jar:/usr/local/kafka/bin/../perf/build/libs//kafka-perf_2.8.0*.jar:/usr/local/kafka/bin/../clients/build/libs//kafka-clients*.jar:/usr/local/kafka/bin/../examples/build/libs//kafka-examples*.jar:/usr/local/kafka/bin/../contrib/hadoop-consumer/build/libs//kafka-hadoop-consumer*.jar:/usr/local/kafka/bin/../contrib/hadoop-producer/build/libs//kafka-hadoop-producer*.jar:/usr/local/kafka/bin/../libs/jopt-simple-3.2.jar:/usr/local/kafka/bin/../libs/kafka_2.9.2-0.8.1.jar:/usr/local/kafka/bin/../libs/log4j-1.2.15.jar:/usr/local/kafka/bin/../libs/metrics-annotation-2.2.0.jar:/usr/local/kafka/bin/../libs/metrics-core-2.2.0.jar:/usr/local/kafka/bin/../libs/scala-library-2.9.2.jar:/usr/local/kafka/bin/../libs/slf4j-api-1.7.2.jar:/usr/local/kafka/bin/../libs/slf4j-nop-1.7.6.jar:/usr/local/kafka/bin/../libs/snappy-java-1.0.5.jar:/usr/local/kafka/bin/../libs/zkclient-0.3.jar:/usr/local/kafka/bin/../libs/zookeeper-3.3.4.jar:/usr/local/kafka/bin/../core/build/libs/kafka_2.8.0*.jar (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:43:18,730] INFO Client environment:java.library.path=/usr/java/packages/lib/i386:/lib:/usr/lib (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:43:18,730] INFO Client environment:java.io.tmpdir=/tmp (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:43:18,730] INFO Client environment:java.compiler=<NA> (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:43:18,731] INFO Client environment:os.name=Linux (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:43:18,731] INFO Client environment:os.arch=i386 (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:43:18,731] INFO Client environment:os.version=2.6.32-358.el6.i686 (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:43:18,731] INFO Client environment:user.name=root (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:43:18,731] INFO Client environment:user.home=/root (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:43:18,732] INFO Client environment:user.dir=/usr/local/kafka (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:43:18,735] INFO Initiating client connection, connectString=sparkproject1:2181,sparkproject2:2181,sparkproject3:2181 sessionTimeout=6000 watcher=org.I0Itec.zkclient.ZkClient@d20835 (org.apache.zookeeper.ZooKeeper)
[2018-10-23 03:43:18,820] INFO Opening socket connection to server sparkproject3/192.168.124.112:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:43:18,840] INFO Socket connection established to sparkproject3/192.168.124.112:2181, initiating session (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:43:18,914] INFO Session establishment complete on server sparkproject3/192.168.124.112:2181, sessionid = 0x16690101c3f0000, negotiated timeout = 6000 (org.apache.zookeeper.ClientCnxn)
[2018-10-23 03:43:18,918] INFO zookeeper state changed (SyncConnected) (org.I0Itec.zkclient.ZkClient)
[2018-10-23 03:43:19,492] INFO Loading log 'TestTopic-0' (kafka.log.LogManager)
[2018-10-23 03:43:19,624] INFO Recovering unflushed segment 106 in log TestTopic-0. (kafka.log.Log)
[2018-10-23 03:43:19,662] INFO Completed load of log TestTopic-0 with log end offset 106 (kafka.log.Log)
[2018-10-23 03:43:19,774] INFO Starting log cleanup with a period of 60000 ms. (kafka.log.LogManager)
[2018-10-23 03:43:19,783] INFO Starting log flusher with a default period of 9223372036854775807 ms. (kafka.log.LogManager)
[2018-10-23 03:43:19,837] INFO Awaiting socket connections on 0.0.0.0:9092. (kafka.network.Acceptor)
[2018-10-23 03:43:19,838] INFO [Socket Server on Broker 0], Started (kafka.network.SocketServer)
[2018-10-23 03:43:20,060] INFO Will not load MX4J, mx4j-tools.jar is not in the classpath (kafka.utils.Mx4jLoader$)
[2018-10-23 03:43:20,260] INFO 0 successfully elected as leader (kafka.server.ZookeeperLeaderElector)
[2018-10-23 03:43:20,631] INFO Registered broker 0 at path /brokers/ids/0 with address sparkproject1:9092. (kafka.utils.ZkUtils$)
[2018-10-23 03:43:20,695] INFO [Kafka Server 0], started (kafka.server.KafkaServer)
[2018-10-23 03:43:20,902] INFO New leader is 0 (kafka.server.ZookeeperLeaderElector$LeaderChangeListener)

You have new mail in /var/spool/mail/root
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# 
[root@sparkproject1 kafka]# jps
30452 NameNode
32030 Jps
31971 Kafka
31903 QuorumPeerMain
29898 ResourceManager
30619 SecondaryNameNode
30762 DataNode
[root@sparkproject1 kafka]#

sparkproject2:

[root@sparkproject2 kafka]# bin/kafka-server-start.sh config/server.properties &
[2] 6668
[root@sparkproject2 kafka]# [2018-10-20 21:21:22,190] INFO Verifying properties (kafka.utils.VerifiableProperties)
[2018-10-20 21:21:22,315] INFO Property broker.id is overridden to 1 (kafka.utils.VerifiableProperties)
[2018-10-20 21:21:22,315] INFO Property log.cleaner.enable is overridden to false (kafka.utils.VerifiableProperties)
[2018-10-20 21:21:22,316] INFO Property log.dirs is overridden to /tmp/kafka-logs (kafka.utils.VerifiableProperties)
[2018-10-20 21:21:22,316] INFO Property log.retention.check.interval.ms is overridden to 60000 (kafka.utils.VerifiableProperties)
[2018-10-20 21:21:22,317] INFO Property log.retention.hours is overridden to 168 (kafka.utils.VerifiableProperties)
[2018-10-20 21:21:22,318] INFO Property log.segment.bytes is overridden to 536870912 (kafka.utils.VerifiableProperties)
[2018-10-20 21:21:22,318] INFO Property num.io.threads is overridden to 8 (kafka.utils.VerifiableProperties)
[2018-10-20 21:21:22,319] INFO Property num.network.threads is overridden to 2 (kafka.utils.VerifiableProperties)
[2018-10-20 21:21:22,320] INFO Property num.partitions is overridden to 2 (kafka.utils.VerifiableProperties)
[2018-10-20 21:21:22,320] INFO Property port is overridden to 9092 (kafka.utils.VerifiableProperties)
[2018-10-20 21:21:22,321] INFO Property socket.receive.buffer.bytes is overridden to 1048576 (kafka.utils.VerifiableProperties)
[2018-10-20 21:21:22,322] INFO Property socket.request.max.bytes is overridden to 104857600 (kafka.utils.VerifiableProperties)
[2018-10-20 21:21:22,322] INFO Property socket.send.buffer.bytes is overridden to 1048576 (kafka.utils.VerifiableProperties)
[2018-10-20 21:21:22,323] INFO Property zookeeper.connect is overridden to sparkproject1:2181,sparkproject2:2181,sparkproject3:2181 (kafka.utils.VerifiableProperties)
[2018-10-20 21:21:22,324] INFO Property zookeeper.connection.timeout.ms is overridden to 1000000 (kafka.utils.VerifiableProperties)
[2018-10-20 21:21:22,374] INFO [Kafka Server 1], starting (kafka.server.KafkaServer)
[2018-10-20 21:21:22,381] INFO [Kafka Server 1], Connecting to zookeeper on sparkproject1:2181,sparkproject2:2181,sparkproject3:2181 (kafka.server.KafkaServer)
[2018-10-20 21:21:22,413] INFO Starting ZkClient event thread. (org.I0Itec.zkclient.ZkEventThread)
[2018-10-20 21:21:22,449] INFO Client environment:zookeeper.version=3.3.3-1203054, built on 11/17/2011 05:47 GMT (org.apache.zookeeper.ZooKeeper)
[2018-10-20 21:21:22,449] INFO Client environment:host.name=sparkproject2 (org.apache.zookeeper.ZooKeeper)
[2018-10-20 21:21:22,449] INFO Client environment:java.version=1.7.0_65 (org.apache.zookeeper.ZooKeeper)
[2018-10-20 21:21:22,450] INFO Client environment:java.vendor=Oracle Corporation (org.apache.zookeeper.ZooKeeper)
[2018-10-20 21:21:22,450] INFO Client environment:java.home=/usr/java/jdk1.7.0_65/jre (org.apache.zookeeper.ZooKeeper)
[2018-10-20 21:21:22,450] INFO Client environment:java.class.path=:/usr/local/kafka/bin/../core/build/dependant-libs-2.8.0/*.jar:/usr/local/kafka/bin/../perf/build/libs//kafka-perf_2.8.0*.jar:/usr/local/kafka/bin/../clients/build/libs//kafka-clients*.jar:/usr/local/kafka/bin/../examples/build/libs//kafka-examples*.jar:/usr/local/kafka/bin/../contrib/hadoop-consumer/build/libs//kafka-hadoop-consumer*.jar:/usr/local/kafka/bin/../contrib/hadoop-producer/build/libs//kafka-hadoop-producer*.jar:/usr/local/kafka/bin/../libs/jopt-simple-3.2.jar:/usr/local/kafka/bin/../libs/kafka_2.9.2-0.8.1.jar:/usr/local/kafka/bin/../libs/log4j-1.2.15.jar:/usr/local/kafka/bin/../libs/metrics-annotation-2.2.0.jar:/usr/local/kafka/bin/../libs/metrics-core-2.2.0.jar:/usr/local/kafka/bin/../libs/scala-library-2.9.2.jar:/usr/local/kafka/bin/../libs/slf4j-api-1.7.2.jar:/usr/local/kafka/bin/../libs/slf4j-nop-1.7.6.jar:/usr/local/kafka/bin/../libs/snappy-java-1.0.5.jar:/usr/local/kafka/bin/../libs/zkclient-0.3.jar:/usr/local/kafka/bin/../libs/zookeeper-3.3.4.jar:/usr/local/kafka/bin/../core/build/libs/kafka_2.8.0*.jar (org.apache.zookeeper.ZooKeeper)
[2018-10-20 21:21:22,450] INFO Client environment:java.library.path=/usr/java/packages/lib/i386:/lib:/usr/lib (org.apache.zookeeper.ZooKeeper)
[2018-10-20 21:21:22,451] INFO Client environment:java.io.tmpdir=/tmp (org.apache.zookeeper.ZooKeeper)
[2018-10-20 21:21:22,451] INFO Client environment:java.compiler=<NA> (org.apache.zookeeper.ZooKeeper)
[2018-10-20 21:21:22,451] INFO Client environment:os.name=Linux (org.apache.zookeeper.ZooKeeper)
[2018-10-20 21:21:22,451] INFO Client environment:os.arch=i386 (org.apache.zookeeper.ZooKeeper)
[2018-10-20 21:21:22,451] INFO Client environment:os.version=2.6.32-358.el6.i686 (org.apache.zookeeper.ZooKeeper)
[2018-10-20 21:21:22,452] INFO Client environment:user.name=root (org.apache.zookeeper.ZooKeeper)
[2018-10-20 21:21:22,452] INFO Client environment:user.home=/root (org.apache.zookeeper.ZooKeeper)
[2018-10-20 21:21:22,452] INFO Client environment:user.dir=/usr/local/kafka (org.apache.zookeeper.ZooKeeper)
[2018-10-20 21:21:22,456] INFO Initiating client connection, connectString=sparkproject1:2181,sparkproject2:2181,sparkproject3:2181 sessionTimeout=6000 watcher=org.I0Itec.zkclient.ZkClient@d20835 (org.apache.zookeeper.ZooKeeper)
[2018-10-20 21:21:22,503] INFO Opening socket connection to server sparkproject1/192.168.124.110:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-20 21:21:22,515] INFO Socket connection established to sparkproject1/192.168.124.110:2181, initiating session (org.apache.zookeeper.ClientCnxn)
[2018-10-20 21:21:22,573] INFO Session establishment complete on server sparkproject1/192.168.124.110:2181, sessionid = 0x1669d4b5bde0000, negotiated timeout = 6000 (org.apache.zookeeper.ClientCnxn)
[2018-10-20 21:21:22,577] INFO zookeeper state changed (SyncConnected) (org.I0Itec.zkclient.ZkClient)
[2018-10-20 21:21:23,096] INFO Loading log 'AdRealTimeLog-0' (kafka.log.LogManager)
[2018-10-20 21:21:23,210] INFO Recovering unflushed segment 0 in log AdRealTimeLog-0. (kafka.log.Log)
[2018-10-20 21:21:24,327] INFO Completed load of log AdRealTimeLog-0 with log end offset 25145 (kafka.log.Log)
[2018-10-20 21:21:24,378] INFO Starting log cleanup with a period of 60000 ms. (kafka.log.LogManager)
[2018-10-20 21:21:24,385] INFO Starting log flusher with a default period of 9223372036854775807 ms. (kafka.log.LogManager)
[2018-10-20 21:21:24,432] INFO Awaiting socket connections on 0.0.0.0:9092. (kafka.network.Acceptor)
[2018-10-20 21:21:24,434] INFO [Socket Server on Broker 1], Started (kafka.network.SocketServer)
[2018-10-20 21:21:24,637] INFO Will not load MX4J, mx4j-tools.jar is not in the classpath (kafka.utils.Mx4jLoader$)
[2018-10-20 21:21:24,772] INFO 1 successfully elected as leader (kafka.server.ZookeeperLeaderElector)
[2018-10-20 21:21:25,067] INFO Registered broker 1 at path /brokers/ids/1 with address sparkproject2:9092. (kafka.utils.ZkUtils$)
[2018-10-20 21:21:25,134] INFO [Kafka Server 1], started (kafka.server.KafkaServer)
[2018-10-20 21:21:25,301] INFO New leader is 1 (kafka.server.ZookeeperLeaderElector$LeaderChangeListener)
[root@sparkproject2 kafka]# jps
6230 NodeManager
6605 QuorumPeerMain
6437 DataNode
6707 Jps
6668 Kafka
[root@sparkproject2 kafka]# 

sparkproject3:

[root@sparkproject3 kafka]# bin/kafka-server-start.sh config/server.properties &
[2] 3573
[root@sparkproject3 kafka]# [2018-10-20 14:05:22,674] INFO Verifying properties (kafka.utils.VerifiableProperties)
[2018-10-20 14:05:22,783] INFO Property broker.id is overridden to 2 (kafka.utils.VerifiableProperties)
[2018-10-20 14:05:22,784] INFO Property log.cleaner.enable is overridden to false (kafka.utils.VerifiableProperties)
[2018-10-20 14:05:22,785] INFO Property log.dirs is overridden to /tmp/kafka-logs (kafka.utils.VerifiableProperties)
[2018-10-20 14:05:22,786] INFO Property log.retention.check.interval.ms is overridden to 60000 (kafka.utils.VerifiableProperties)
[2018-10-20 14:05:22,786] INFO Property log.retention.hours is overridden to 168 (kafka.utils.VerifiableProperties)
[2018-10-20 14:05:22,788] INFO Property log.segment.bytes is overridden to 536870912 (kafka.utils.VerifiableProperties)
[2018-10-20 14:05:22,789] INFO Property num.io.threads is overridden to 8 (kafka.utils.VerifiableProperties)
[2018-10-20 14:05:22,790] INFO Property num.network.threads is overridden to 2 (kafka.utils.VerifiableProperties)
[2018-10-20 14:05:22,790] INFO Property num.partitions is overridden to 2 (kafka.utils.VerifiableProperties)
[2018-10-20 14:05:22,791] INFO Property port is overridden to 9092 (kafka.utils.VerifiableProperties)
[2018-10-20 14:05:22,792] INFO Property socket.receive.buffer.bytes is overridden to 1048576 (kafka.utils.VerifiableProperties)
[2018-10-20 14:05:22,792] INFO Property socket.request.max.bytes is overridden to 104857600 (kafka.utils.VerifiableProperties)
[2018-10-20 14:05:22,793] INFO Property socket.send.buffer.bytes is overridden to 1048576 (kafka.utils.VerifiableProperties)
[2018-10-20 14:05:22,794] INFO Property zookeeper.connect is overridden to sparkproject1:2181,sparkproject2:2181,sparkproject3:2181 (kafka.utils.VerifiableProperties)
[2018-10-20 14:05:22,795] INFO Property zookeeper.connection.timeout.ms is overridden to 1000000 (kafka.utils.VerifiableProperties)
[2018-10-20 14:05:22,858] INFO [Kafka Server 2], starting (kafka.server.KafkaServer)
[2018-10-20 14:05:22,863] INFO [Kafka Server 2], Connecting to zookeeper on sparkproject1:2181,sparkproject2:2181,sparkproject3:2181 (kafka.server.KafkaServer)
[2018-10-20 14:05:22,908] INFO Starting ZkClient event thread. (org.I0Itec.zkclient.ZkEventThread)
[2018-10-20 14:05:22,944] INFO Client environment:zookeeper.version=3.3.3-1203054, built on 11/17/2011 05:47 GMT (org.apache.zookeeper.ZooKeeper)
[2018-10-20 14:05:22,944] INFO Client environment:host.name=sparkproject3 (org.apache.zookeeper.ZooKeeper)
[2018-10-20 14:05:22,944] INFO Client environment:java.version=1.7.0_65 (org.apache.zookeeper.ZooKeeper)
[2018-10-20 14:05:22,944] INFO Client environment:java.vendor=Oracle Corporation (org.apache.zookeeper.ZooKeeper)
[2018-10-20 14:05:22,945] INFO Client environment:java.home=/usr/java/jdk1.7.0_65/jre (org.apache.zookeeper.ZooKeeper)
[2018-10-20 14:05:22,945] INFO Client environment:java.class.path=:/usr/local/kafka/bin/../core/build/dependant-libs-2.8.0/*.jar:/usr/local/kafka/bin/../perf/build/libs//kafka-perf_2.8.0*.jar:/usr/local/kafka/bin/../clients/build/libs//kafka-clients*.jar:/usr/local/kafka/bin/../examples/build/libs//kafka-examples*.jar:/usr/local/kafka/bin/../contrib/hadoop-consumer/build/libs//kafka-hadoop-consumer*.jar:/usr/local/kafka/bin/../contrib/hadoop-producer/build/libs//kafka-hadoop-producer*.jar:/usr/local/kafka/bin/../libs/jopt-simple-3.2.jar:/usr/local/kafka/bin/../libs/kafka_2.9.2-0.8.1.jar:/usr/local/kafka/bin/../libs/log4j-1.2.15.jar:/usr/local/kafka/bin/../libs/metrics-annotation-2.2.0.jar:/usr/local/kafka/bin/../libs/metrics-core-2.2.0.jar:/usr/local/kafka/bin/../libs/scala-library-2.9.2.jar:/usr/local/kafka/bin/../libs/slf4j-api-1.7.2.jar:/usr/local/kafka/bin/../libs/slf4j-nop-1.7.6.jar:/usr/local/kafka/bin/../libs/snappy-java-1.0.5.jar:/usr/local/kafka/bin/../libs/zkclient-0.3.jar:/usr/local/kafka/bin/../libs/zookeeper-3.3.4.jar:/usr/local/kafka/bin/../core/build/libs/kafka_2.8.0*.jar (org.apache.zookeeper.ZooKeeper)
[2018-10-20 14:05:22,946] INFO Client environment:java.library.path=/usr/java/packages/lib/i386:/lib:/usr/lib (org.apache.zookeeper.ZooKeeper)
[2018-10-20 14:05:22,946] INFO Client environment:java.io.tmpdir=/tmp (org.apache.zookeeper.ZooKeeper)
[2018-10-20 14:05:22,946] INFO Client environment:java.compiler=<NA> (org.apache.zookeeper.ZooKeeper)
[2018-10-20 14:05:22,946] INFO Client environment:os.name=Linux (org.apache.zookeeper.ZooKeeper)
[2018-10-20 14:05:22,946] INFO Client environment:os.arch=i386 (org.apache.zookeeper.ZooKeeper)
[2018-10-20 14:05:22,946] INFO Client environment:os.version=2.6.32-358.el6.i686 (org.apache.zookeeper.ZooKeeper)
[2018-10-20 14:05:22,947] INFO Client environment:user.name=root (org.apache.zookeeper.ZooKeeper)
[2018-10-20 14:05:22,947] INFO Client environment:user.home=/root (org.apache.zookeeper.ZooKeeper)
[2018-10-20 14:05:22,948] INFO Client environment:user.dir=/usr/local/kafka (org.apache.zookeeper.ZooKeeper)
[2018-10-20 14:05:22,950] INFO Initiating client connection, connectString=sparkproject1:2181,sparkproject2:2181,sparkproject3:2181 sessionTimeout=6000 watcher=org.I0Itec.zkclient.ZkClient@d20835 (org.apache.zookeeper.ZooKeeper)
[2018-10-20 14:05:23,002] INFO Opening socket connection to server sparkproject3/192.168.124.112:2181 (org.apache.zookeeper.ClientCnxn)
[2018-10-20 14:05:23,016] INFO Accepted socket connection from /192.168.124.112:60444 (org.apache.zookeeper.server.NIOServerCnxn)
[2018-10-20 14:05:23,018] INFO Socket connection established to sparkproject3/192.168.124.112:2181, initiating session (org.apache.zookeeper.ClientCnxn)
[2018-10-20 14:05:23,026] INFO Client attempting to establish new session at /192.168.124.112:60444 (org.apache.zookeeper.server.NIOServerCnxn)
[2018-10-20 14:05:23,038] INFO Established session 0x16690101c3f0001 with negotiated timeout 6000 for client /192.168.124.112:60444 (org.apache.zookeeper.server.NIOServerCnxn)
[2018-10-20 14:05:23,045] INFO Session establishment complete on server sparkproject3/192.168.124.112:2181, sessionid = 0x16690101c3f0001, negotiated timeout = 6000 (org.apache.zookeeper.ClientCnxn)
[2018-10-20 14:05:23,051] INFO zookeeper state changed (SyncConnected) (org.I0Itec.zkclient.ZkClient)
[2018-10-20 14:05:23,309] INFO Found clean shutdown file. Skipping recovery for all logs in data directory '/tmp/kafka-logs' (kafka.log.LogManager)
[2018-10-20 14:05:23,316] INFO Starting log cleanup with a period of 60000 ms. (kafka.log.LogManager)
[2018-10-20 14:05:23,343] INFO Starting log flusher with a default period of 9223372036854775807 ms. (kafka.log.LogManager)
[2018-10-20 14:05:23,528] INFO Awaiting socket connections on 0.0.0.0:9092. (kafka.network.Acceptor)
[2018-10-20 14:05:23,533] INFO [Socket Server on Broker 2], Started (kafka.network.SocketServer)
[2018-10-20 14:05:23,855] INFO Will not load MX4J, mx4j-tools.jar is not in the classpath (kafka.utils.Mx4jLoader$)
[2018-10-20 14:05:23,977] INFO Got user-level KeeperException when processing sessionid:0x16690101c3f0001 type:create cxid:0xc zxid:0xfffffffffffffffe txntype:unknown reqpath:n/a Error Path:/controller Error:KeeperErrorCode = NodeExists for /controller (org.apache.zookeeper.server.PrepRequestProcessor)
[2018-10-20 14:05:24,007] INFO conflict in /controller data: {"version":1,"brokerid":2,"timestamp":"1540015523884"} stored data: {"version":1,"brokerid":0,"timestamp":"1540237400075"} (kafka.utils.ZkUtils$)
[2018-10-20 14:05:24,407] INFO Registered broker 2 at path /brokers/ids/2 with address sparkproject3:9092. (kafka.utils.ZkUtils$)
[2018-10-20 14:05:24,453] INFO [Kafka Server 2], started (kafka.server.KafkaServer)

[root@sparkproject3 kafka]# 
[root@sparkproject3 kafka]# 
[root@sparkproject3 kafka]# 
[root@sparkproject3 kafka]# jps
3573 Kafka
3358 DataNode
3610 Jps
2920 NodeManager
3533 QuorumPeerMain
[root@sparkproject3 kafka]# 

可见注册到zk的集群是随机的。

 

 

kafka的停止:

执行:

[root@sparkproject3 kafka]# bin/kafka-server-stop.sh config/server.properties 

停止日志:

[root@sparkproject3 kafka]# bin/kafka-server-st
kafka-server-start.sh  kafka-server-stop.sh   
[root@sparkproject3 kafka]# bin/kafka-server-stop.sh config/server.properties 
[root@sparkproject3 kafka]# [2018-10-20 14:12:13,250] INFO [Kafka Server 2], shutting down (kafka.server.KafkaServer)
[2018-10-20 14:12:13,259] INFO [Socket Server on Broker 2], Shutting down (kafka.network.SocketServer)
[2018-10-20 14:12:13,270] INFO [Socket Server on Broker 2], Shutdown completed (kafka.network.SocketServer)
[2018-10-20 14:12:13,272] INFO [Kafka Request Handler on Broker 2], shutting down (kafka.server.KafkaRequestHandlerPool)
[2018-10-20 14:12:13,389] INFO [Kafka Request Handler on Broker 2], shut down completely (kafka.server.KafkaRequestHandlerPool)
[2018-10-20 14:12:13,789] INFO [Replica Manager on Broker 2]: Shut down (kafka.server.ReplicaManager)
[2018-10-20 14:12:13,791] INFO [ReplicaFetcherManager on broker 2] shutting down (kafka.server.ReplicaFetcherManager)
[2018-10-20 14:12:13,795] INFO [ReplicaFetcherManager on broker 2] shutdown completed (kafka.server.ReplicaFetcherManager)
[2018-10-20 14:12:13,808] INFO [Replica Manager on Broker 2]: Shutted down completely (kafka.server.ReplicaManager)
[2018-10-20 14:12:13,830] INFO Terminate ZkClient event thread. (org.I0Itec.zkclient.ZkEventThread)
[2018-10-20 14:12:13,833] INFO Processed session termination for sessionid: 0x16690101c3f0001 (org.apache.zookeeper.server.PrepRequestProcessor)
[2018-10-20 14:12:13,843] INFO Closed socket connection for client /192.168.124.112:60444 which had sessionid 0x16690101c3f0001 (org.apache.zookeeper.server.NIOServerCnxn)
[2018-10-20 14:12:13,845] INFO EventThread shut down (org.apache.zookeeper.ClientCnxn)
[2018-10-20 14:12:13,846] INFO Session: 0x16690101c3f0001 closed (org.apache.zookeeper.ZooKeeper)
[2018-10-20 14:12:13,849] INFO [Kafka Server 2], shut down completed (kafka.server.KafkaServer)

[2]+  Exit 130                bin/kafka-server-start.sh config/server.properties
[root@sparkproject3 kafka]# 
[root@sparkproject3 kafka]# 
[root@sparkproject3 kafka]# 
[root@sparkproject3 kafka]# 
[root@sparkproject3 kafka]# 
[root@sparkproject3 kafka]# jps
3358 DataNode
2920 NodeManager
3533 QuorumPeerMain
3634 Jps
[root@sparkproject3 kafka]# 

也可以jps直接杀死进程号。

  • 0
    点赞
  • 0
    评论
  • 1
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值