kafka集群搭建整理
来源:互联网 发布:原创歌词制作软件 编辑:程序博客网 时间:2024/06/14 00:44
1.Download and install kafka
wget https://www.apache.org/dyn/closer.cgi?path=/kafka/0.8.1.1/kafka_2.10-0.8.1.1.tgztar zvxf kafka_2.10-0.8.1.1.tgzcd kafka_2.10-0.8.1.1
2.Start zookeeper
bin/zookeeper-server-start.sh config/zookeeper.properties
3.Start kafka
bin/kafka-server-start.sh config/server.properties
4.Create topic
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partition 1 --topics test
5.Open producer,send message
bin/kafka-console-producer.sh --broler-list localhost:9092 --topic test
6.Open consumer, receive message
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
7.Build a multi broker cluster
7.1 Copy setting files from the first broker
cp config/server.properties config/server-1.propertiescp config/server.properties config/server-2.properties
7.2 Add code below to every new broker
for broker1
broker.id = 1port = 9093log.dir = /tmp/kafka-log-1
for broker2
broker.id = 2port = 9094log.dir = /tmp/kafka-log-2
==++In the cluster, broker.id pointed to only one certain node. In case overwrite the data, we have to set different port and log file for each broker in the same mechine.++==
7.3 Now we have three node and one already be started, we just need to start the tow new nodes.
bin/kafka-server-start.sh config/server-1.propertiesbin/kafka-server-start.sh config/server-2.properties
7.4 Create a topic which has three copies
bin/kafka-topics.sh --create --zookeeper lcoalhost:2181 --replication-factor 3 --partition 1 --topic my-replicated-topic
8. Now we have a cluster with three nodes, but how do we know information about each node? Run describe topics command and you will see.
bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic my-replicated-topic
Topic:my-replication-topic PartitionCount:1 Configs:
Topic:my-replication-topic Partition:1 Leader:0 Replicas:2,0,1 Isr:0,1,2
Notification: The first row show information of all the partitions. Below the first row, every partition has a row to show detail of its own information. Since there is only one partition for the topic, there is only one row.
Leader: Manage meaage reading and meaage writing
Replicas:List all broker
Isr: List all the broker which is in servicing
9. Test the fault-durable capbility of kafka
From information above we know that broker 0 is the leader, then we open this broker and send messages
bin/kafka-console-producer.sh --broler-list localhost:9092 --topic my-replicated-topic
And we open a consumer to receive the message
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic my-replicated-topic --from-beginning
Then we kill broker 0
netstat -tnlp
find broker 0(localhost:9092),remember PID, and kill it
kill -9 PID
And use command ‘describe’ we can see kafka chose another broker as the new leader and we use this new leader to send massege , the consumer can receive the message normally.
- kafka集群搭建整理
- 【Kafka】Kafka集群搭建
- kafka集群搭建
- kafka集群搭建
- kafka集群搭建
- kafka集群搭建
- kafka集群搭建
- 搭建kafka集群
- 搭建kafka集群
- kafka集群环境搭建
- Kafka集群搭建
- 搭建kafka集群
- kafka集群环境搭建
- Zookeeper+Kafka集群搭建
- KAFKA集群环境搭建
- 搭建Kafka集群环境
- kafka集群搭建
- Kafka 集群搭建步骤
- 【Zookeeper】源码分析之请求处理链(二)
- 多线程的几种实现方式
- &位与的用法
- HDU 1025 (最长上升子序列(nlogn)算法)
- 如果看了此文你还不懂傅里叶变换,那就过来掐死我吧【完整版】
- kafka集群搭建整理
- mysql 添加时间列(用于记录创建时间和修改时间)
- Android开发笔记(一百零六)支付缴费SDK
- 优化Myshool第四章高级查询
- mysql-5.7.17免安装版环境搭建
- SpringMVC入门之十:异常的优化处理
- 绘制canvas彩色泡泡小球碰撞
- 白盒与黑盒测试的区别
- 理解快速傅里叶变换(FFT)算法