Kafka自我学习1-Multi-broker cluster
====================================Testing environment ===========================================
# cat /etc/redhat-release
CentOS Linux release 7.5. (Core)
====================================Setting up a single-node broker ===========================================
check monitor port
# ss -t -a
1.download kafka package
# wget http://mirrors.hust.edu.cn/apache/kafka/1.1.0/kafka_2.11-1.1.0.tgz
2.uncompress kafka
# tar xzf kafka_2.11-1.1.0.tgz
3.move kafka folder
# mv kafka_2.11-1.1.0 /usr/local/kafka
4.start zookeeper by default configuration
# /usr/local/kafka/bin/zookeeper-server-start.sh config/zookeeper.properties
5.start kafka by default configuration(broker id=0, port=9092)
# /usr/local/kafka/bin/kafka-server-start.sh config/server.properties
6.create test1 topic
# /usr/local/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test1
7.check test1 topic status
# /usr/local/kafka/bin/kafka-topics.sh --describe --zookeeper localhost:2181
Topic:test1 PartitionCount:1 ReplicationFactor:1 Configs:
Topic: test1 Partition: 0 Leader: 0 Replicas: 0 Isr: 0
8.produce a message data to test1 topic
# /usr/local/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test1
>helloworld
9.consume the message data from test1 topic
# /usr/local/kafka/bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic test1
>helloworld
==============================Setting up a multi-broker cluster on one server=========================================
1.create broker1(id=1,port=9093), broker2(id=2,port=9094)
# cd /usr/local/kafka/config/
# cp server.properties server1.properties
# cp server.properties server2.properties
2.start broker1 and broker2
# /usr/local/kafka/bin/kafka-server-start.sh config/server1.properties &
# /usr/local/kafka/bin/kafka-server-start.sh config/server2.properties &
3.create my-repliactied-topic topic with 3 replication times
# /usr/local/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 1 --topic my-replicated-topic
4.check my-repliactied-topic topic status, and this is kafka cluster, broker0,broker1,broker2 have 3 copy
# /usr/local/kafka/bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic my-replicated-topic
Topic:my-replicated-topic PartitionCount:1 ReplicationFactor:3 Configs:
Topic: my-replicated-topic Partition: 0 Leader: 2 Replicas: 2,0,1 Isr: 2,0,1
5.produce a message data to my-repliactied-topic topic
# /usr/local/kafka/bin/kafka-console-producer.sh --broker-list localhost:9094 --topic my-replicated-topic
>helloworld1234
6.consume the message data from my-repliactied-topic topic
# /usr/local/kafka/bin/kafka-console-consumer.sh --bootstrap-server localhost:9094 --from-beginning --topic my-replicated-topic
>helloworld1234
7.Search broker2 PID
# ps aux | grep server2.properties
7564 ttys002 0:15.91 /System/Library/Frameworks/JavaVM...................server2.properties
8.Kill broker2
# kill -9 7564
9.broker2 is dead, but can continue to produce another message data to my-repliactied-topic topic
# /usr/local/kafka/bin/kafka-console-producer.sh --broker-list localhost:9094 --topic my-replicated-topic
>helloworld1234
>56789
10.broker2 is dead, but can continue to consume the message data from my-repliactied-topic topic
# /usr/local/kafka/bin/kafka-console-consumer.sh --bootstrap-server localhost:9094 --from-beginning --topic my-replicated-topic
>helloworld1234
[2018-05-21 16:25:14,334] WARN [Consumer clientId=consumer-1, groupId=console-consumer-82232] Connection to node 2 could not be established. Broker may not be available.
>56789
11.check my-repliactied-topic topic status, Leader transfer to broker0, and broker2 stop sync
# /usr/local/kafka/bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic my-replicated-topic
Topic:my-replicated-topic PartitionCount:1 ReplicationFactor:3 Configs:
Topic: my-replicated-topic Partition: 0 Leader: 0 Replicas: 2,0,1 Isr: 0,1
Refer: https://kafka.apache.org/quickstart
Kafka自我学习1-Multi-broker cluster的更多相关文章
- How to set an Apache Kafka multi node – multi broker cluster【z】
Set a multi node Apache ZooKeeper cluster On every node of the cluster add the following lines to th ...
- Kafka自我学习3-Scalable
1.After created the zookeeper cluster, we found all broker cluster topic can be find in zoo1, zoo2, ...
- Kafka自我学习2-Zookeeper cluster
Test enviroment : zoo1, zoo2, zoo3 cluster 1. Install zookeeper, package in kafka [root@zoo1 ~]# pwd ...
- Kafka自我学习-报错篇
1. kafka启动出现:Unsupported major.minor version 52.0 错误, 具体的错误输出: Exception in thread "main" ...
- kafka基本原理学习
下载安装地址:http://kafka.apache.org/downloads.html 原文链接:http://www.jasongj.com/2015/01/02/Kafka深度解析 Kafk ...
- kafka分区及副本在broker的分配
kafka分区及副本在broker的分配 部分内容參考自:http://blog.csdn.net/lizhitao/article/details/41778193 以下以一个Kafka集群中4个B ...
- Apache Kafka框架学习
背景介绍 消息队列的比较 kafka框架介绍 术语解释 文件存储 可靠性保证 高吞吐量实现 负载均衡 应用场景 背景介绍: kafka是由Apache软件基金会维护的一个开源流处理平台,由scala和 ...
- UFLDL教程笔记及练习答案三(Softmax回归与自我学习***)
:softmax回归 当p(y|x,theta)满足多项式分布,通过GLM对其进行建模就能得到htheta(x)关于theta的函数,将其称为softmax回归. 教程中已经给了cost及gradie ...
- java知识体系(自我学习中)
java自我学习知识体系
随机推荐
- react ant-design自定义图标
ant-design给我们提供的图标不够怎么办呢?答案是我们可以自定义图标. 自定义图标也挺简单的,现在图标推荐用svg格式,那么我们就需要制作svg图片. 下面让我们看看如果制作svg图片吧. 1. ...
- python的初体验
最近由于毕业答辩,导致一些博客没有更新,见谅,今天我们开始一些新的内容 1.python的注释 单行注释:# 多行注释: ''' 这是多行注释 我们可以在里面写很多很多的行 ''' 2.编码风格 #c ...
- Grok Debugger本地安装(转载)
原文链接:http://fengwan.blog.51cto.com/508652/1758845 最近在使用ELK对日志进行集中管理,因为涉及到日志的规则经常要用到http://grokdebug. ...
- vue2018年5月报错No parser and no file path given
mac电脑直接: rm -rf node_modules rm package-lock.json npm install npm install prettier@~1.12.1 执行完这四个命令, ...
- 【转】使用git提交项目到码云
一.git安装 1.首先在官方网站下载git工具,或者根据以下链接进行下载:http://download.csdn.net/detail/qq_27501889/9788879(此链接版本为git- ...
- 2 socket UDP通信
1 socket套接字 class 对象 In [1]: import socket In [2]: help(socket.socket) class socket(_socket.socket) ...
- Android ANR 分析
首先贴一下trace 文件 Process: com.oppo.reader PID: 20358 Time: 2933175644_1545041895232 Flags: 0x38d83e44 P ...
- 【APUE】Chapter10 Signals
Signal主要分两大部分: A. 什么是Signal,有哪些Signal,都是干什么使的. B. 列举了非常多不正确(不可靠)的处理Signal的方式,以及怎么样设计来避免这些错误出现. 10.2 ...
- vue2.0 $emit $on组件通信
在vue1.0中父子组件通信使用$dispatch 和 $broadcast,但是在vue2.0中$dispatch 和 $broadcast 已经被弃用. 因为基于组件树结构的事件流方式实在是让人难 ...
- windows下网络命令----Tracert命令详解
现在网络四通八达,网线光纤基站卫星,只要运营商能收费的地方,就有网络,覆盖了全世界所有的区域.彻底改变了以前通讯基本靠吼的情况.那么宽广的网络世界,超过100米就得需要中继放大信号的网线,即使现在的光 ...