====================================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. Vee-validate学习

    Vee-validate使用方法 首先引入 <script src="https://cdn.bootcss.com/vee-validate/2.0.9/vee-validate.j ...

  2. python--基本类型之数值

    Number(数字): 数字类型创建: a = 10b = ab = 20 pint('a : 'a)pint('b : 'b) 数据类型转换: int(x,[,base]) 将 x 转换为一个整数f ...

  3. python2.7入门---字符串

        这次咱们就来看一下python的字符串类型.首先我们要知道,字符串是 Python 中最常用的数据类型.我们可以使用引号('或")来创建字符串.创建字符串很简单,只要为变量分配一个值 ...

  4. python2.7练习小例子(十二)

        12):题目:打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身.例如:153是一个"水仙花数" ...

  5. oracle 11g XE 学习版添加scott用户方法全步骤

    安装企业版的orcale是不是太费时费力了?若只是学习用途的话,不妨试试轻便版的XE版本,同样是官网下载的,但是这个安装起来比完整版简便多了. 首先,你得先安装好orcale 11g XE 版本:(这 ...

  6. LeetCode:17. Letter Combinations of a Phone Number(Medium)

    1. 原题链接 https://leetcode.com/problems/letter-combinations-of-a-phone-number/description/ 2. 题目要求 给定一 ...

  7. jpa Specification复杂查询

    public List<Receipts> test(List<String> costIds){ Specification<Receipts> specific ...

  8. python的正则表达一

    一.常用的正则表达式 1.了解正则表达式 正则表达式是对字符串操作的一种逻辑公式,就是用事先定义好的一些特定字符.及这些特定字符的组合,组成一个“规则字符串”,这个“规则字符串”用来表达对字符串的一种 ...

  9. shell -- if参数用法

    一.概要1.if与[之间要有空格2.[]与判断条件之间也必须有空格3.]与:之间不能有空格 二.对字符串的判断1.if [ str1=str2 ];then fi  ----当两个字符串相同时返回真2 ...

  10. [转]Git,SVN的优缺点及适合的范围,开源项目?公司项目?

    使用git不久,粗浅理解: 1)适用对象不同.Git适用于参与开源项目的开发者.他们由于水平高,更在乎的是效率而不是易用性.Svn则不同,它适合普通的公司开发团队.使用起来更加容易. 2)使用的场合不 ...