重启前集群的一些状态记录:
[els@els1 wchane-1]$ kafka-topics.sh --zookeeper 10.156.10.126:2181 --describe --topic wchane
Topic:wchane PartitionCount:3 ReplicationFactor:2 Configs:
Topic: wchane Partition: 0 Leader: 2 Replicas: 2,0 Isr: 2,0
Topic: wchane Partition: 1 Leader: 0 Replicas: 0,1 Isr: 0,1
Topic: wchane Partition: 2 Leader: 1 Replicas: 1,2 Isr: 1,2
查看 brokerid 为 0 下文件的更新时间:
[els@els1 wchane-1]$ ls -al
总用量 20496
drwxrwxr-x 2 els els 4096 5月 28 10:28 .
drwxrwxr-x 5 els els 4096 5月 28 10:37 ..
-rw-rw-r-- 1 els els 10485760 5月 28 10:28 00000000000000000000.index
-rw-rw-r-- 1 els els 95 5月 28 10:28 00000000000000000000.log
-rw-rw-r-- 1 els els 10485756 5月 28 10:28 00000000000000000000.timeindex
-rw-rw-r-- 1 els els 8 5月 28 10:28 leader-epoch-checkpoint
接下来把brokerid 为0 的节点杀了
kill ****
接下来我们看看集群的一些状态:
Topic:wchane PartitionCount:3 ReplicationFactor:2 Configs:
Topic: wchane Partition: 0 Leader: 2 Replicas: 2,0 Isr: 2
Topic: wchane Partition: 1 Leader: 1 Replicas: 0,1 Isr: 1
Topic: wchane Partition: 2 Leader: 1 Replicas: 1,2 Isr: 1,2
接下来我们重启一下。
nohup kafka-server-start.sh ../config/server.properties &
接下来我们再看看集群的一些状态:
[els@els1 wchane-1]$ kafka-topics.sh --zookeeper 10.156.10.126:2181 --describe --topic wchane
Topic:wchane PartitionCount:3 ReplicationFactor:2 Configs:
Topic: wchane Partition: 0 Leader: 2 Replicas: 2,0 Isr: 2,0
Topic: wchane Partition: 1 Leader: 0 Replicas: 0,1 Isr: 1,0
Topic: wchane Partition: 2 Leader: 1 Replicas: 1,2 Isr: 1,2
发现brokerid=0的重新加入了集群并且恢复为leader。
再来看看日志文件的一些变化
[els@els1 wchane-1]$ ls -al
总用量 20500
drwxrwxr-x 2 els els 4096 5月 28 10:39 .
drwxrwxr-x 5 els els 4096 5月 28 10:48 ..
-rw-rw-r-- 1 els els 10485760 5月 28 10:42 00000000000000000000.index
-rw-rw-r-- 1 els els 95 5月 28 10:28 00000000000000000000.log
-rw-rw-r-- 1 els els 10485756 5月 28 10:42 00000000000000000000.timeindex
-rw-rw-r-- 1 els els 10 5月 28 10:39 00000000000000000002.snapshot
-rw-rw-r-- 1 els els 8 5月 28 10:28 leader-epoch-checkpoint
接下来。试试强杀
kill -9 **
[els@els1 wchane-1]$ kafka-topics.sh --zookeeper 10.156.10.126:2181 --describe --topic wchane
Topic:wchane PartitionCount:3 ReplicationFactor:2 Configs:
Topic: wchane Partition: 0 Leader: 2 Replicas: 2,0 Isr: 2
Topic: wchane Partition: 1 Leader: 1 Replicas: 0,1 Isr: 1
Topic: wchane Partition: 2 Leader: 1 Replicas: 1,2 Isr: 1,2
重启之后:
[els@els1 wchane-1]$ kafka-topics.sh --zookeeper 10.156.10.126:2181 --describe --topic wchane
Topic:wchane PartitionCount:3 ReplicationFactor:2 Configs:
Topic: wchane Partition: 0 Leader: 2 Replicas: 2,0 Isr: 2,0
Topic: wchane Partition: 1 Leader: 1 Replicas: 0,1 Isr: 1,0
Topic: wchane Partition: 2 Leader: 1 Replicas: 1,2 Isr: 1,2
总用量 20500
drwxrwxr-x 2 els els 4096 5月 28 10:51 .
drwxrwxr-x 5 els els 4096 5月 28 10:52 ..
-rw-rw-r-- 1 els els 10485760 5月 28 10:51 00000000000000000000.index
-rw-rw-r-- 1 els els 95 5月 28 10:28 00000000000000000000.log
-rw-rw-r-- 1 els els 10485756 5月 28 10:51 00000000000000000000.timeindex
-rw-rw-r-- 1 els els 10 5月 28 10:51 00000000000000000002.snapshot
-rw-rw-r-- 1 els els 8 5月 28 10:28 leader-epoch-checkpoint
接下来。停了broker 0 并进行数据写入。
[els@els1 wchane-1]$ kafka-topics.sh --zookeeper 10.156.10.126:2181 --describe --topic wchane
Topic:wchane PartitionCount:3 ReplicationFactor:2 Configs:
Topic: wchane Partition: 0 Leader: 2 Replicas: 2,0 Isr: 2
Topic: wchane Partition: 1 Leader: 1 Replicas: 0,1 Isr: 1
Topic: wchane Partition: 2 Leader: 2 Replicas: 1,2 Isr: 2,1
写入数据之后再试试重启
[els@els1 wchane-1]$ kafka-topics.sh --zookeeper 10.156.10.126:2181 --describe --topic wchane
Topic:wchane PartitionCount:3 ReplicationFactor:2 Configs:
Topic: wchane Partition: 0 Leader: 2 Replicas: 2,0 Isr: 2,0
Topic: wchane Partition: 1 Leader: 1 Replicas: 0,1 Isr: 1,0
Topic: wchane Partition: 2 Leader: 1 Replicas: 1,2 Isr: 2,1
[els@els1 wchane-1]$ ls -al
总用量 20500
drwxrwxr-x 2 els els 4096 5月 28 11:02 .
drwxrwxr-x 5 els els 4096 5月 28 11:03 ..
-rw-rw-r-- 1 els els 10485760 5月 28 11:02 00000000000000000000.index
-rw-rw-r-- 1 els els 190 5月 28 11:02 00000000000000000000.log
-rw-rw-r-- 1 els els 10485756 5月 28 11:02 00000000000000000000.timeindex
-rw-rw-r-- 1 els els 10 5月 28 10:51 00000000000000000002.snapshot
-rw-rw-r-- 1 els els 12 5月 28 11:02 leader-epoch-checkpoint
发现日志文件也进行的更新。