首页 > 代码库 > zookeeper集群搭建
zookeeper集群搭建
1.由于是第一次搭建zk的集群,过程中遇到些问题,给自己也给遇到问题的人提供一种可能解决问题的方法。
第一步:下载zk的最新版,我下的是3.4.9,在zk的官网,下载后解压到/usr/local
tar -zxvf zookeeper-3.4.9
第二部:在conf 目录下,复制zoo_sample.cfg 另起名zoo.cfg(为什么叫这个名字我也不清楚,应该是zk的程序检测需要这个文件),配置zoo.cfg
mv zoo_sample.cfg /usr/local/zookeeper-3.4.9/conf/zoo.cfg
gedit 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=/tmp/zookeeper
dataLogDir=/tmp/zookeeperLogs
# 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=192.168.154.129:2888:3888
server.2=192.168.154.133:2888:3888
server.3=192.168.154.132:2888:3888
上图中的红色部分是集群需要配置的,
用bin/zkCli.sh -server.sh -server 192.168.154.129:2181 测试 输入如下:
启动成功。另外两台机器一样。
zookeeper集群搭建