====================================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的更多相关文章

  1. 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 ...

  2. Kafka自我学习3-Scalable

    1.After created the zookeeper cluster, we found all broker cluster topic can be find in zoo1, zoo2, ...

  3. Kafka自我学习2-Zookeeper cluster

    Test enviroment : zoo1, zoo2, zoo3 cluster 1. Install zookeeper, package in kafka [root@zoo1 ~]# pwd ...

  4. Kafka自我学习-报错篇

    1. kafka启动出现:Unsupported major.minor version 52.0 错误,  具体的错误输出: Exception in thread "main" ...

  5. kafka基本原理学习

    下载安装地址:http://kafka.apache.org/downloads.html  原文链接:http://www.jasongj.com/2015/01/02/Kafka深度解析 Kafk ...

  6. kafka分区及副本在broker的分配

    kafka分区及副本在broker的分配 部分内容參考自:http://blog.csdn.net/lizhitao/article/details/41778193 以下以一个Kafka集群中4个B ...

  7. Apache Kafka框架学习

    背景介绍 消息队列的比较 kafka框架介绍 术语解释 文件存储 可靠性保证 高吞吐量实现 负载均衡 应用场景 背景介绍: kafka是由Apache软件基金会维护的一个开源流处理平台,由scala和 ...

  8. UFLDL教程笔记及练习答案三(Softmax回归与自我学习***)

    :softmax回归 当p(y|x,theta)满足多项式分布,通过GLM对其进行建模就能得到htheta(x)关于theta的函数,将其称为softmax回归. 教程中已经给了cost及gradie ...

  9. java知识体系(自我学习中)

    java自我学习知识体系

随机推荐

  1. ubuntu配置机器学习环境(三) opencv 安装

    这里使用脚本安装 一些教程里使用cmake 安装,很容易出错的 使用github上的安装脚本,自动化安装 参考链接 Ubuntu $ cd Ubuntu/2.4 $ chmod +x * # 如果要安 ...

  2. 异步消息处理(Message, Handler, MessageQueue, Looper)

    AsyncTask 适用于单线程任务处理,多任务处理还是 Message/Handler 处理方便一些 主要使用方式: 1,创建子类继承自 Handler 类,覆盖 handleMessage(Mes ...

  3. struts2官方 中文教程 系列十一:使用XML进行表单验证

    在本教程中,我们将讨论如何使用Struts 2的XML验证方法来验证表单字段中用户的输入.在前面的教程中,我们讨论了在Action类中使用validate方法验证用户的输入.使用单独的XML验证文件让 ...

  4. 【PHP】进一法取整、四舍五入取整、忽略小数等的取整数方法大全

    PHP取整数函数常用的四种方法,下面收集了四个函数:经常用到取整的函数,今天小小的总结一下!其实很简单,就是几个函数而已--主要是:ceil,floor,round,intval PHP取整数函数常用 ...

  5. 1,理解java中的IO

    IO中的几种形式 基于字节:InputStream.OutputStream 基于字符:Writer.Reader 基于磁盘:File 基于网络Socket   最终都是字节操作,字符到字节要编码转换 ...

  6. Qt 蓝牙部分翻译

    这是我第一次尝试翻译技术文档,自己英语太烂,一直不敢尝试,感谢生活,让我勇敢迈出这第一步. 大部分都是直译,如有不妥,还请制导. Qt Bluetooth The Bluetooth API prov ...

  7. python终极篇 --- django---班级管理系统

    周末没事自己写了个班级管理系统,虽然简单,但也算个前期学习的总结吧 from django.db import models # Create your models here. class Banj ...

  8. [POJ3585]Accumulation Degree

    题面 \(\text{Solution:}\) 有些题目不仅让我们做树型 \(\text{dp}\) ,而且还让我们换每个根分别做一次, 然后这样就愉快的 \(\text{TLE}\) 了,所以我们要 ...

  9. Spring Boot学习(一):入门篇

    目录 Spring Boot简介 Spring Boot快速搭建 1 新建项目 2 运行项目 3 设置spring boot可以热部署(修改后端代码后,自动部署,不用手动部署) 3.1:配置pom.x ...

  10. esayui combotree 只能选择子节点

    esayui combotree 只能选择子节点用onBeforeSelect:参数是node,节点被选中之前触发,返回false取消选择动作. 网上找了好多都没一个可用的,要想知道他是子节点还是根节 ...