码迷,mamicode.com
首页 > 其他好文 > 详细

zookeeper以及kafka环境的搭建  

时间:2016-01-22 18:21:12      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:zookeeper以及kafka环境的搭建  

linux上的系统环境变量  在安装zookeeper时不需要配置


1. 下载zookeeper二进制安装包(可以下载附件内容或者到官网下载http://www.apache.org/dyn/closer.cgi/zookeeper/)


2解压到linux上任意一路径  本文新建在了/home/hadoop/下


tar -zxvf zookeeper-3.4.6.tar.gz


本人选择 zookeeper-3.4.6.tar.gz   因为3.4.6版本属于稳定版本  


3,配置zookeeper 配置文件 


进入 /home/hadoop/zookeeper-3.4.6/conf


cp zoo_sample.cfg zoo.cfg   复制程序包的事例配置文件  命名为zoo.cfg  zookeeper默认读取的就是zoo.cfg


# The number of milliseconds of each tick
tickTime=2000
# 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/hadoop/zookeeper-3.4.6/data
dataLogDir=/home/hadoop/zookeeper-3.4.6/dataLogs
# the port at which the clients will connect
clientPort=12181
# 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
server.1=192.168.2.200:12888:13888
server.2=192.168.2.202:12888:13888
server.3=192.168.2.204:12888:13888
dataDir  Zookeeper 将写数据的日志文件也保存在这个目录里
dataLogDir   Zookeeper  快照文件


端口号 12888 为Zookeeper之间的通信端口号   默认是 2888
端口号 13888 为Zookeeper之间的选举端口号  默认是 3888   每个为Zookeeper集群都有一个leader 如果其中一台机器的leader死掉  会从集群中的机器follow选出的新的Leader。

server.1 server.2 server.3 的来源

构成集群的依据就是 server.1 server.2 server.3

后面的 1,2,3是每个服务器在整个集群中的唯一标识 不能重复  

配置时候 需要到 dataDir 目录中执行 echo "1">myid(第一个机器),echo "2">myid(第二个机器),echo "3">myid(第三个机器)


4,启动 zookeeper

执行  /home/hadoop/zookeeper-3.4.6/bin   中的 sh zkServer.sh start

查看执行结果   jps

netstat -at|grep 12181

 至此 zookeeper的环境搭建已经完成  


下节文章将会介绍kafuka的环境搭建 


本文出自 “小西天” 博客,请务必保留此出处http://gggcgba.blog.51cto.com/3889163/1737680

zookeeper以及kafka环境的搭建  

标签:zookeeper以及kafka环境的搭建  

原文地址:http://gggcgba.blog.51cto.com/3889163/1737680

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!