install zookeeper on windows
1. Download zookeeper
Download zookeeper zookeeper 3.6.2 from the official website Download from official website
2. Modify the configuration
2.1 Add a data directory to the zookeeper home directory
2.2 Modify the configuration file
Modify conf/zoo_samp.cfg >> dataDir=…/data/
and modify conf/zoo_samp.cfg to 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. Start zookeeper
./bin/zkServer.sh start
4. Check whether the startup is successful
4.1 View process
netstat -aon|findstr "2181"
TCP 0.0.0.0:2181 0.0.0.0:0 LISTENING 14252
TCP [::]:2181 [::]:0 LISTENING 14252
4.2 Client Link
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