Windowsにzookeeperをインストールする
1.zookeeperをダウンロードします
公式ウェブサイトからzookeeperzookeeper3.6.2をダウンロードする公式ウェブサイトからダウンロードする
2.構成を変更します
2.1zookeeperのホームディレクトリにデータディレクトリを追加します
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