Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1036772
  • 博文数量: 239
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 3618
  • 用 户 组: 普通用户
  • 注册时间: 2012-11-12 13:17
文章分类

全部博文(239)

文章存档

2021年(1)

2016年(1)

2015年(30)

2014年(91)

2013年(116)

分类: HADOOP

2015-10-29 17:36:48

三台操作系统搭建kafka集群环境

OS版本:
[root@Master kafka_2.10-0.8.2.2]# lsb_release -a
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.5 (Final)
Release: 6.5
Codename: Final

[root@Master kafka_2.10-0.8.2.2]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.56.121 Master
192.168.56.122 Slave1
192.168.56.123 Slave2

软件目录安装在:
/usr/local/kafka/kafka_2.10-0.8.2.2

Master环境的zookeeper.properties修改:

点击(此处)折叠或打开

点击(此处)折叠或打开

  1. tickTime=2000
  2. dataDir=/data/zookeeper
  3. clientPort=2181
  4. maxClientCnxns=0
  5. initLimit=5
  6. syncLimit=2
  7. server.1=192.168.56.121:2888:3888
  8. server.2=192.168.56.122:2888:3888
  9. server.3=192.168.56.123:2888:3888



Master环境的server.properties文件修改如下所示。
Slave1和Slave2环境的broker.id为2和3,host.name分别为192.168.56.122和192.168.56.123


点击(此处)折叠或打开

  1. broker.id=1
  2. port=9092
  3. host.name=192.168.56.121
  4. zookeeper.connect=192.168.56.121:2181,192.168.56.122:2181,192.168.56.123:2181
  5. log.dirs=/data/kafka-logs
  6. producer.type=async
  7. broker.list=192.168.56.121:9092,192.168.56.122:9092,192.168.56.123:9092



启动每台服务器的kafka:

>bin/kafka-server-start.sh config/server.properties &

测试集群

创建一个topic

>bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

查看创建的topic

[root@Slave1 kafka_2.10-0.8.2.2]# bin/kafka-topics.sh --list --zookeeper 192.168.56.121:2181
test
[root@Slave1 kafka_2.10-0.8.2.2]# bin/kafka-topics.sh --list --zookeeper 192.168.56.122:2181
test
[root@Slave1 kafka_2.10-0.8.2.2]# bin/kafka-topics.sh --list --zookeeper 192.168.56.123:2181
test

查看集群情况:

[root@Master kafka_2.10-0.8.2.2]# bin/kafka-topics.sh --describe --zookeeper 192.168.56.121:2181 --topic test Topic:test
PartitionCount:1 ReplicationFactor:1 Configs: Topic: test Partition: 0 Leader: 3 Replicas: 3 Isr: 3
[root@Master kafka_2.10-0.8.2.2]# bin/kafka-topics.sh --describe --zookeeper 192.168.56.122:2181 --topic test Topic:test
PartitionCount:1 ReplicationFactor:1 Configs: Topic: test Partition: 0 Leader: 3 Replicas: 3 Isr: 3
[root@Master kafka_2.10-0.8.2.2]# bin/kafka-topics.sh --describe --zookeeper 192.168.56.123:2181 --topic test Topic:test
PartitionCount:1 ReplicationFactor:1 Configs: Topic: test Partition: 0 Leader: 3 Replicas: 3 Isr: 3


阅读(1376) | 评论(0) | 转发(0) |
0

上一篇:kafka安装配置

下一篇:ELK整合kafka

给主人留下些什么吧!~~