一:服务器资源
ZooKeeper server.1 10.243.3.18
ZooKeeper server.2 10.243.3.17
ZooKeeper server.3 10.243.3.27
二:下载ZooKeeper安装文件
zookeeper-3.4.10.tar.gz
三:将安装文件解压到指定目录
tar -xvf zookeeper-3.4.10.tar.gz
四:配置文件
cp zoo_sample.cfg 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=/gh/zookeeperData
-
# 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=10.243.3.18:2888:3888
-
server.2=10.243.3.17:2888:3888
-
server.3=10.243.3.27:2888:3888
在dataDir所配置的目录下,创建一个名为myid的文件,在该文件的第一行写上一个数字,和zoo.cfg中当前机器的编号对应上。
五: 启动服务器
/bin/zkServer.sh start
六:客户端测试
/bin/zkCli.sh
创建节点 create /dataSource 456
读取节点 get /dataSource
更新节点 set /dataSource 123
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28624388/viewspace-2137598/
,如需转载,请注明出处,否则将追究法律责任。