windows安装 zookeeper
1. 下载 zookeeper
从官网下载zookeeper
zookeeper 3.6.2 官网下载
2. 修改配置
2.1在zookeeper主目录新增data目录
2.2 修改配置文件
修改conf/zoo_samp.cfg >> dataDir=…/data/
并将conf/zoo_samp.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=../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
3. 启动zookeeper
./bin/zkServer.sh start
4. 查看是否启动成功
4.1 查看进程
netstat -aon|findstr "2181"
TCP 0.0.0.0:2181 0.0.0.0:0 LISTENING 14252
TCP [::]:2181 [::]:0 LISTENING 14252
4.2 客户端链接
zkCli.cmd
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0]
# 获取所有节点
[zk: localhost:2181(CONNECTED) 0] ls /
[dubbo, zookeeper]
# 创建节点
[zk: localhost:2181(CONNECTED) 1] create /test
Created /test
# 给节点设置值
[zk: localhost:2181(CONNECTED) 2] set /test "aa"
[zk: localhost:2181(CONNECTED) 3] get /test
aa