Win10 stand-alone installation Zookeeper cluster combat

Win10 stand-alone installation Zookeeper pseudo cluster

Installation process

1. Download
https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/stable/

The latest 3.5.5.bin.tar.gz decompression conflict, do not know why, or the next version 3.4.9:
http://archive.apache.org/dist/zookeeper/zookeeper-3.4.9/

2. Extract to "D: \ programGreen \ zookeeper-3.4.9"

3. Modify the "zoo_sample.cfg" as "zoo.cfg"


Stand-alone mode

Run directly

  • D:\programGreen\zookeeper-3.4.9\bin>zkServer.cmd

win10 cluster

1.conf directory Add zoo1.cfg, zoo2.cfg, zoo3.cfg configuration file, the contents are as follows:

# zoo1.cfg
tickTime=2000
initLimit=10
syncLimit=5
server.1=localhost:2888:3888
server.2=localhost:2889:3889
server.3=localhost:2890:3890
# 集群参数
dataDir=/tmp/zookeeper/d1
dataLogDir=/tmp/zookeeper/log1
clientPort=2181
# zoo2.cfg
tickTime=2000
initLimit=10
syncLimit=5
server.1=localhost:2888:3888
server.2=localhost:2889:3889
server.3=localhost:2890:3890
# 集群参数
dataDir=/tmp/zookeeper/d2
dataLogDir=/tmp/zookeeper/log2
clientPort=2182
# zoo3.cfg
tickTime=2000
initLimit=10
syncLimit=5
server.1=localhost:2888:3888
server.2=localhost:2889:3889
server.3=localhost:2890:3890
# 集群参数
dataDir=/tmp/zookeeper/d3
dataLogDir=/tmp/zookeeper/log3
clientPort=2183

2.bin zkserver.cmd replication in 3 parts: zkserver1.cmd, zkserver2.cmd, zkserver3.cmd, were added to a line "set ZOOCFG = ... \ conf \ zooX.cfg"

@echo off
setlocal
call "%~dp0zkEnv.cmd"
set ZOOMAIN=org.apache.zookeeper.server.quorum.QuorumPeerMain
set ZOOCFG=..\conf\zoo1.cfg
echo on
call %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %*
endlocal
...
set ZOOCFG=..\conf\zoo2.cfg
...
...
set ZOOCFG=..\conf\zoo3.cfg
...

3.D disk create a directory

  • D: \ tmp \ zookeeper \ d1 \ myid ------------ myid file inside 1
  • D: \ tmp \ zookeeper \ d2 \ myid ------------ myid file inside of 2
  • D: \ tmp \ zookeeper \ d3 \ myid ------------ myid file inside of 3
  • D:\tmp\zookeeper\log1
  • D:\tmp\zookeeper\log2
  • D:\tmp\zookeeper\log3

3.3 cmd windows were run three zkserverX.cmd, netstar-ano view port listening situation. - seemingly can not monitor it;

4.3 cmd window run zkCli.cmd

  • zkCli.cmd -server:localhost:2181;
  • zkCli.cmd -server:localhost:2182;
  • zkCli.cmd -server:localhost:2183;
C:\Windows\system32>d:
D:\>cd D:\programGreen\zookeeper-3.4.9\bin
D:\programGreen\zookeeper-3.4.9\bin>zkCli.cmd -server:localhost:2181;

5. In the black box input commands zkCli.cmd

  • ls / ------- View znode
  • create / zk_test my_data ------- create znode
  • ls / ------- znode more zk_test,
  • get / zk_test ------- see the value my_data
  • set / zk_test junk ------- is disposed junk
  • get / zk_test ------- see is junk
  • delete / zk_test ------- delete znode

appendix

Parameter Meaning

  • dataDir: storage memory database snapshot location, as well as updates to the database transaction log (unless otherwise specified).
  • dataLogDir: transaction log directory. ------ set this parameter may get lower latency update
  • tickTime: unit time, in milliseconds.
  • initLimit: When starting follower leader synchronization data from the completion time of the initial state; or follower must be connected to the leader of time, otherwise the follower will be rejected, on which the client is assigned to the other follower. ----- Under normal circumstances, we do not care too much about setting this parameter. If the amount of data clusters is large, it is necessary to properly turn up.
  • clientPort: listening port for client connections.
  • syncLimit: limit the extent of obsolete between the server and the leader. For example, leader issued a heartbeat packets but no response is received within the specified time, it is believed follower does not exist. Do not take this parameter is set too high, otherwise it may mask some problems.
  • server.x = host: port1: port2. myid x digital files with the same id, port1 for inter-machine communications, port2 for elections.

Official Documents

Guess you like

Origin blog.csdn.net/sndayYU/article/details/90718238