设为首页 加入收藏

TOP

centos下安装单机版kafka-0.10.0.1
2018-11-29 11:19:44 】 浏览:58
Tags:centos 安装 单机版 kafka-0.10.0.1
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/su377486/article/details/77845379

1.环境说明

主机信息如下:
操作系统版本如下:
1
[root@test1 soft]# cat /etc/redhat-release 
2
CentOS release 6.4 (Final)
3
[root@test1 soft]# uname -a
4
Linux test1 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
5

2.下载kafka

下载地址如下:
我这里使用Scala 2.11 -kafka_2.11-0.10.0.1.tgz(asc,md5)版本

3.安装配置kafka

一.解压缩kafka

二.配置zookeeper

由于kafka需要使用到zookeeper来注册信息,因此需要首先配置zookeeper.在kafka的安装包中已经提供了zookeeper,不需要额外安装,直接配置一下即可.配置文件在config下的zookeeper. properties
1
[root@test1 config]# cat zookeeper.properties 
2
# Licensed to the Apache Software Foundation (ASF) under one or more
3
# contributor license agreements.  See the NOTICE file distributed with
4
# this work for additional information regarding copyright ownership.
5
# The ASF licenses this file to You under the Apache License, Version 2.0
6
# (the "License"); you may not use this file except in compliance with
7
# the License.  You may obtain a copy of the License at
8
# 
9
#   http://www.apache.org/licenses/LICENSE-2.0
10
# 
11
# Unless required by applicable law or agreed to in writing, software
12
# distributed under the License is distributed on an "AS IS" BASIS,
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
# See the License for the specific language governing permissions and
15
# limitations under the License.
16
# the directory where the snapshot is stored.
17
dataDir=/root/kafka/kafka_2.11-0.10.0.1/zoodata            ###########这里修改zookeeper的快照目录,需要事先在文件系统上创建目录,其它默认即可.
18
# the port at which the clients will connect
19
clientPort=2181        #默认端口号2181
20
# disable the per-ip limit on the number of connections since this is a non-production config
21
maxClientCnxns=0
22

三.配置kafka

kafka的配置文件在config下的server.properties文件.下面是一个配置实例:

4.启动kafka

为了方便可以将kafka的运行目录添加到PATH环境变量中.
首先使用命令bin/zookeeper-server-start.sh config/zookeeper.properties
启动zookeeper.
1
[root@test1 kafka_2.11-0.10.0.1]# nohup ./bin/zookeeper-server-start.sh config/zookeeper.properties &
2
[1] 1888
3
[root@test1 kafka_2.11-0.10.0.1]# nohup: ignoring input and appending output to `nohup.out'
4
5
[root@test1 kafka_2.11-0.10.0.1]# jps
6
1888 QuorumPeerMain
7
2118 Jps
8
再使用命令bin/kafka-server-start.sh config/server.properties
启动kafka

5.模拟测试kafka发布订阅

新建一个窗口模拟producer,执行:
kafka-console-producer.sh --broker-list localhost:9092 --topic
然后在窗口中随便输入
1
[root@test1 kafka]# kafka-console-producer.sh --broker-list localhost:9092 --topic test
2
aaaa
3
bbbb
4
在另外一个窗口中模拟consumer,执行:
[root@test1 ~]# kafka-console-consumer.sh --zookeeper localhost:2181 --topic test1 --from-beginning
然后会发现producer的输入会实时的发布到consumer中
创建主题:
1
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
查看主题:
1
 bin/kafka-topics.sh --list --zookeeper localhost:2181

















】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Kafka单机、集群模式安装详解(一) 下一篇关于Kafka 的 consumer 消费者手..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目