Ubuntu下安装和使用zookeeper和kafka
来源:互联网 发布:广告数据分析 编辑:程序博客网 时间:2024/06/07 20:19
1.在清华镜像站下载kafka_2.10-0.10.0.0.tgz 和 zookeeper-3.4.10.tar.gz
分别解压到/usr/local目录下
2.进入zookeeper目录,在conf目录下将zoo_sample.cfg文件拷贝,并更名为zoo.cfg
参考 https://my.oschina.net/phoebus789/blog/730787
zoo.cfg文件的内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=
/home/common/zookeeper/zookeeperdir/zookeeper-data
dataLogDir=
/home/common/zookeeper/zookeeperdir/logs
# the port at which the clients will connect
clientPort=2181
server.1=10.10.100.10:2888:3888
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
新建下面这两个目录
1
2
/home/common/zookeeper/zookeeperdir/zookeeper-data
/home/common/zookeeper/zookeeperdir/logs
在zookeeper-data目录下新建一个myid文件,内容为1,代表这个服务器的编号是1,具体参考上面网址中的内容
最后在/etc/profile中添加环境变量,并source
1
2
export
ZOOKEEPER_HOME=
/usr/local/zookeeper
export
PATH=${ZOOKEEPER_HOME}
/bin
:$PATH
现在zookeeper就安装好了,现在启动zookeeper
1
bin
/zkServer
.sh start
查看状态
1
bin
/zkServer
.sh status
启动客户端脚本
1
bin
/zkCli
.sh -server zookeeper:2181
停止zookeeper
1
bin
/zkServer
.sh stop
1.现在安装kafka,同样是解压之后就安装好了
参考 http://www.jianshu.com/p/efc8b9dbd3bd
2.进入kafka目录下
kafka需要使用Zookeeper,首先需要启动Zookeeper服务,上面的操作就已经启动了Zookeeper服务
如果没有的话,可以使用kafka自带的脚本启动一个简单的单一节点Zookeeper实例
1
bin
/zookeeper-server-start
.sh config
/zookeeper
.properties
启动 Kafka服务
1
bin
/kafka-server-start
.sh config
/server
.properties
停止 Kafka服务
1
bin
/kafka-server-stop
.sh config
/server
.properties
3.创建一个主题
首先创建一个名为test
的topic,只使用单个分区和一个复本
1
bin
/kafka-topics
.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic
test
现在可以运行list topic命令看到我们的主题
1
bin
/kafka-topics
.sh --list --zookeeper localhost:2181
4.发送消息
1
2
3
bin
/kafka-console-producer
.sh --broker-list localhost:9092 --topic
test
This is a message
This is another message
5.启动一个消费者,消费者会接收到消息
1
bin
/kafka-console-consumer
.sh --zookeeper localhost:2181 --topic
test
--from-beginning 2>
/dev/null
阅读全文
0 0
- Ubuntu下安装和使用zookeeper和kafka
- linux下的kafka和zookeeper的使用配置
- windows下kafka的安装和使用
- zookeeper和PHP zookeeper和kafka 扩展安装
- zookeeper和PHP zookeeper和kafka 扩展安装
- Linux下kafka和zookeeper环境搭配
- windows下zookeeper,kafka和solr启动
- 关于zookeeper和kafka的配置安装
- KAFKA安装和使用
- Kafka怎么和Zookeeper配合使用
- linux(ubuntu)下安装和启动kafka以及若干坑
- zookeeper和kafka实践
- zookeeper和kafka
- Zookeeper安装和使用
- 在Windows中安装zookeeper和kafka单点环境
- Redhat Linux 6.5 单机安装配置zookeeper和kafka
- zookeeper和kafka集群搭建
- zookeeper和kafka的介绍
- Json数据格式总结
- 4.13 leetcode -13 reverse-integer
- MySQL添加和修改字段
- 浅谈同步,异步,阻塞,非阻塞
- why will unity not work with %AppData%
- Ubuntu下安装和使用zookeeper和kafka
- oracle 特殊语句
- opencv
- Spring核心类XmlBeanDefinitionReader
- X86模拟器输入法
- Composer安装与使用
- meta标签
- 在msys里进行复制和粘贴操作
- 全球突发比特币病毒,众多官网瘫痪!你的服务器被勒索了吗?