首页 > 其他 > 详细

zookeeper 入门(二)

时间:2014-04-23 06:57:06      阅读:539      评论:0      收藏:0      [点我收藏+]

上一篇教程中重点讲解了如何部署启动一台zookeeper服务

本章中我们会重点讲解下如何 部署一套zookeeper的集群环境

基于paxos 算法,部署一套集群环境要求 至少 要有3个节点  并且节点的个数一定为奇数

1 在本机中模拟 3个节点

准备工作

bubuko.com,布布扣
cp -r /usr/local/zookeeper-3.4.6 /srv/zookeeper01
bubuko.com,布布扣

打开配置文件

bubuko.com,布布扣
vi /srv/zookeeper01/conf/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=/srv/zookeeper01/data
# the port at which the clients will connect
clientPort=2181
# 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=localhost:2888:3888
server.2=localhost:2888:3888
server.3=localhost:2888:3888
bubuko.com,布布扣

其中server.X代表组成整个服务的机器,当服务启动时,会在数据目录下查找这个文件myid,这个文件中存有服务器的号码。

创建myid文件

bubuko.com,布布扣
touch /srv/zookeeper01/data/myid
echo 1 > /srv/zookeeper01/data/myid
bubuko.com,布布扣

创建另外2台zookeeper 节点 

bubuko.com,布布扣
cd /srv
cp -r zookeeper01/ zookeeper02/
#修改dataDir=/srv/zookeeper02/data
vi zookeeper02/conf/zoo.cfg  
#修改myid
echo 2 > /srv/zookeeper02/data/myid

cp -r zookeeper01/ zookeeper03/
#修改dataDir=/srv/zookeeper03/data
vi zookeeper03/conf/zoo.cfg  
#修改myid
echo 3 > /srv/zookeeper03/data/myid
bubuko.com,布布扣

启动3台服务

bubuko.com,布布扣
/srv/zookeeper01/bin/zkServer.sh start
/srv/zookeeper02/bin/zkServer.sh start
/srv/zookeeper03/bin/zkServer.sh start
bubuko.com,布布扣

 

 

zookeeper 入门(二),布布扣,bubuko.com

zookeeper 入门(二)

原文:http://www.cnblogs.com/balaamwe/p/3680857.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!