zookeeper伪分布安装

zookeeper伪分布安装

本文主要参考:
http://blog.csdn.net/java2000_wl/article/details/8627874

好,下面上货。前面已经介绍了zookeeper的基本使用和单节点环境的搭建,现在介绍一下伪分布式环境的zookeeper是如何搭建的。

1、首先下载zookeeper最新版本的3.4.10


2、解压到指定文件夹,这里解压到/data文件夹下。同时复制2份。


3、修改配置文件conf文件下的zoo.cfg文件。
配置文件1:
# 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=/data/zoodata1
dataLogDir=/data/zoodata1/logs
# 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=127.0.0.1:4000:5000  
server.2=127.0.0.1:4001:5001  
server.3=127.0.0.1:4002:5002

配置文件2
# 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=/data/zoodata2
dataLogDir=/data/zoodata2/logs
# the port at which the clients will connect
clientPort=2182
# 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=127.0.0.1:4000:5000  
server.2=127.0.0.1:4001:5001  
server.3=127.0.0.1:4002:5002

配置文件3:
# 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=/data/zoodata3
dataLogDir=/data/zoodata3/logs
# the port at which the clients will connect
clientPort=2183
# 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=127.0.0.1:4000:5000  
server.2=127.0.0.1:4001:5001  
server.3=127.0.0.1:4002:5002

4、然后根据配置的datadir和datalogdir进行创建文件夹。


5、启动zookeeper,启动的时候分别启动每一个./zkServer.sh start

6、查看节点状态,查看哪个是leader,哪个是follower。
echo stat | nc 192.168.0.99 2181
zookeeper伪分布安装_第1张图片

echo stat | nc 192.168.0.99 2182
zookeeper伪分布安装_第2张图片

echo stat | nc 192.168.0.99 2183
zookeeper伪分布安装_第3张图片

ok!这样就完成了zookeeper的伪分布式搭建。

你可能感兴趣的:(zookeeper)