Construction of Zookeeper in windows

download

[external chain picture transfer failed. The source station may have anti-theft chain mechanism. It is recommended to save the picture and upload it directly

Download address: https://mirrors.cnnic.cn/apache/zookeeper/

PS: zookeeper package with bin ID from version 3.5.5 or later, otherwise an error will be reported when starting: "error: the main class org.apache.zookeeper.server.quorum.QuorumPeerMain cannot be found or loaded". tar.gz package is only the source package, which can not be used directly. The package with bin name is the package we want to download and can be used directly. There are compiled binary packages in it.

install

There is no need to install. Just unzip it to the directory you want to store it. I'll store it in disk D.

to configure

  1. Modify file name: Zoom_ simple. Change the cfg file name to zoo cfg.
  2. Configure log storage path
# The number of milliseconds of each tick
#  The time interval between Zookeeper servers or between clients and servers to maintain heartbeat, that is, one heartbeat will be sent every tickTime.
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
# The maximum number of heartbeats (number of ticktimes) that can be tolerated during the initial connection between the follower server (F) and the leader server (L) in the cluster
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
# The maximum number of heartbeats that can be tolerated between requests and responses between the follower server and the leader server in the cluster (the number of ticktimes)
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
# Zookeeper will also save the log file of data writing in this directory
# Because the cluster is configured later, the data is distinguished by the directory, and the stand-alone version uses the digital 0 directory
dataDir=D:\\Install\\zookeeper\\apache-zookeeper-3.5.8-bin\\data\\0
# Zookeeper the directory where the log files are saved
dataLogDir=D:\\Install\\zookeeper\\apache-zookeeper-3.5.8-bin\\log\\0
# the port at which the clients will connect
# This port is the port where the client connects to the zookeeper server. Zookeeper will listen to this port and accept the client's access request.
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

Stand alone version

start-up

Find zkserver.com in bin directory CMD double click to open

test

Check whether the startup is successful. Double click to open zkcli cmd

PS: if you open zkserver CMD flash back to zkserver pause is added at the end of CMD file, so it will not flash back, which is convenient to view the error information, as follows:

echo on
call %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" "-Dzookeeper.log.file=%ZOO_LOG_FILE%" "-XX:+HeapDumpOnOutOfMemoryError" "-XX:OnOutOfMemoryError=cmd /c taskkill /pid %%%%p /t /f" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %*
pause
endlocal

Cluster version

to configure

  1. Copy three zoos CFG, respectively named zoo1 cfg,zoo2.cfg,zoo3.cfg

zoo1.cfg

#dataDir=/tmp/zookeeper
# Zookeeper will also save the log file of data writing in this directory
dataDir=D:\\Install\\zookeeper\\apache-zookeeper-3.5.8-bin\\data\\1
# Zookeeper the directory where the log files are saved
dataLogDir=D:\\Install\\zookeeper\\apache-zookeeper-3.5.8-bin\\log\\1
# the port at which the clients will connect
clientPort=2181
#Add cluster configuration
server.1=localhost:2887:3887
server.2=localhost:2888:3888
server.3=localhost:2889:3889

zoo2.cfg

# Zookeeper will also save the log file of data writing in this directory
dataDir=D:\\Install\\zookeeper\\apache-zookeeper-3.5.8-bin\\data\\2
# Zookeeper the directory where the log files are saved
dataLogDir=D:\\Install\\zookeeper\\apache-zookeeper-3.5.8-bin\\log\\2
# the port at which the clients will connect
clientPort=2181
#Add cluster configuration
server.1=localhost:2887:3887
server.2=localhost:2888:3888
server.3=localhost:2889:3889

zoo3.cfg

# Zookeeper will also save the log file of data writing in this directory
dataDir=D:\\Install\\zookeeper\\apache-zookeeper-3.5.8-bin\\data\\3
# Zookeeper the directory where the log files are saved
dataLogDir=D:\\Install\\zookeeper\\apache-zookeeper-3.5.8-bin\\log\\3
# the port at which the clients will connect
clientPort=2181
#Add cluster configuration
server.1=localhost:2887:3887
server.2=localhost:2888:3888
server.3=localhost:2889:3889
  1. Create directories 1, 2 and 3 under the data directory

Create myid files in directories 1, 2 and 3 respectively. 1. The myid in the directory is stored 1; 2. The myid in the directory is stored 2; 3 the myid in the directory is stored 3.

  1. Copy three zkservers CMD, respectively named zkserver-1 cmd,zkServer-2.cmd,zkServer-3.cmd

zkServer-1.cmd,zkServer-2.cmd,zkServer-3.cmd configuration cfg file path, add a sentence

set ZOOCFG=..\conf\zoo1.cfg

zkServer-1.cmd

setlocal
call "%~dp0zkEnv.cmd"

set ZOOMAIN=org.apache.zookeeper.server.quorum.QuorumPeerMain
set ZOOCFG=..\conf\zoo1.cfg
set ZOO_LOG_FILE=zookeeper-%USERNAME%-server-%COMPUTERNAME%.log

echo on
call %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" "-Dzookeeper.log.file=%ZOO_LOG_FILE%" "-XX:+HeapDumpOnOutOfMemoryError" "-XX:OnOutOfMemoryError=cmd /c taskkill /pid %%%%p /t /f" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %*

endlocal

zkServer-2.cmd

setlocal
call "%~dp0zkEnv.cmd"

set ZOOMAIN=org.apache.zookeeper.server.quorum.QuorumPeerMain
set ZOOCFG=..\conf\zoo2.cfg
set ZOO_LOG_FILE=zookeeper-%USERNAME%-server-%COMPUTERNAME%.log

echo on
call %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" "-Dzookeeper.log.file=%ZOO_LOG_FILE%" "-XX:+HeapDumpOnOutOfMemoryError" "-XX:OnOutOfMemoryError=cmd /c taskkill /pid %%%%p /t /f" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %*

endlocal

zkServer-3.cmd

setlocal
call "%~dp0zkEnv.cmd"

set ZOOMAIN=org.apache.zookeeper.server.quorum.QuorumPeerMain
set ZOOCFG=..\conf\zoo3.cfg
set ZOO_LOG_FILE=zookeeper-%USERNAME%-server-%COMPUTERNAME%.log

echo on
call %JAVA% "-Dzookeeper.log.dir=%ZOO_LOG_DIR%" "-Dzookeeper.root.logger=%ZOO_LOG4J_PROP%" "-Dzookeeper.log.file=%ZOO_LOG_FILE%" "-XX:+HeapDumpOnOutOfMemoryError" "-XX:OnOutOfMemoryError=cmd /c taskkill /pid %%%%p /t /f" -cp "%CLASSPATH%" %ZOOMAIN% "%ZOOCFG%" %*

endlocal

start-up

Double click to open zkserver-1 cmd,zkServer-2.cmd,zkServer-3.cmd, start zkserver-1 An error will be reported during CMD. The reason is zkserver-2 cmd,zkServer-3.cmd has not been started yet, so it is impossible to interact between zookeeper s. After the remaining cluster servers are started, there will be no error messages.

Tags: Windows Zookeeper

Posted by mouse02 on Wed, 25 May 2022 04:12:15 +0300