The installation process and test of Zookeeper under Windows
- install jdk
- Install Zookeeper. Download zookeeper from the official website http://zookeeper.apache.org/ . I downloaded the zookeeper-3.4.6 version.
- Unzip zookeeper-3.4.6 to D:\machine\zookeeper-3.4.6.
- Create new data and log directories in D:\machine.
- There are three installation modes of ZooKeeper: stand-alone mode, cluster mode and cluster pseudo-distribution mode. The installation of ZooKeeper stand-alone mode is relatively simple. If you are new to ZooKeeper, it is recommended to install ZooKeeper stand-alone mode or cluster pseudo-distributed mode.
- Install click mode. Copy zoo_sample.cfg to D:\machine\zookeeper-3.4.6\conf and paste it into the current directory, name it zoo.cfg.
- Edit zoo.cfg. Modify the following configuration
- Enter the D:\machine\zookeeper-3.4.6\bin directory under the cmd command to run zkserver.cmd. As shown in the following figure:
- After the startup is completed, under the cmd command, netstat-ano checks the port monitoring service.
- Enter D:\machine\zookeeper-3.4.6\bin under cmd and run zkcli.cmd. As shown in the following figure:
- Install cluster pseudo-distributed mode.
- Modify the zoo.cfg file. As shown in the following figure:
Save as zoo-1.cmd.
Save as zoo-2.cmd.
Save as zoo-3.cmd. - Modify the zkserver.cmd file. As shown in the following figure:
Save as zkserver-1.cmd and
save as zkserver-2.cmd and
save as zkserver-3.cmd. - Run zkserver-1.cmd, zkserver-2.cmd, zkserver-3.cmd respectively under cmd.
- Run netstar-ano under cmd to view the port listening status.
- cmd下运行zkcli.cmd -server:localhost:2181;zkcli.cmd ;-server:localhost:2182;zkcli.cmd -server:localhost:2183.
- The connection between zookeeper and java
Single machine connection:
cluster connection:
Problems encountered during deployment, zookeeper cannot be started normally
Today, in order to free up space, I killed the zookeeper process, but I didn't expect it to start after killing.
Prompt to start normally
[root@lnx-a-11 bin]# ./zkServer.sh start
JMX enabled by default
Using config: /home/tester/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@lnx-air-9-27 bin]# ps aux |grep zook
But look at the background process no
Check the zookeeper.out log, there are the following tips:
2015-12-31 17:32:04,090 [myid:] - ERROR [main:QuorumPeerMain@85] - Invalid config, exiting abnormally
org.apache.zookeeper.server.quorum.QuorumPeerConfig$ConfigException: Error processing /home/tester/zookeeper/bin/../conf/zoo.cfg
at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:123)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun(QuorumPeerMain.java:101)
at org.apache.zookeeper.server.quorum.QuorumPeerMain.main(QuorumPeerMain.java:78)
Caused by: java.lang.IllegalArgumentException: /tmp/zookeeper/data/myid file is missing
at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties(QuorumPeerConfig.java:350)
at org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse(QuorumPeerConfig.java:119)
The prompt is obvious /tmp/zookeeper/data/myid file is missing
I found that there is no myid file in this directory. Everyone knows that the /tmp folder is a temporary directory, and the files in it are likely to be deleted after a period of time.
Check the /etc/cron.daily/tmpwatch file and display the following
#! /bin/sh
flags=-umc
/usr/sbin/tmpwatch "$flags" -x /tmp/.X11-unix -x /tmp/.XIM-unix \
-x /tmp/.font-unix -x /tmp/.ICE-unix -x /tmp/.Test-unix \
-X '/tmp/hsperfdata_*' 10d /tmp
/usr/sbin/tmpwatch "$flags" 30d /var/tmp
for d in /var/{cache/man,catman}/{cat?,X11R6/cat?,local/cat?}; do
if [ -d "$d" ]; then
/usr/sbin/tmpwatch "$flags" -f 30d "$d"
fi
done
It can be known that the contents of the /tmp file will be cleared once every 10 days except for the set file.
So we shouldn't put myid under /tmp or exclude this file from cleanup
Add the myid file, modify the data directory in zoo.cfg, start again, and start successfully
[root@lnx-a-11 bin]# ps aux |grep zook
root 21869 24.7 0.8 2584892 35100 pts/2 Sl 17:54 0:01 java -Dzookeeper.log.dir=/home/tester/zookeeper/bin/../logs -Dzookeeper.root.logger=INFO,CONSOLE -cp /home/tester/zookeeper/bin/../build/classes:/home/tester/zookeeper/bin/../build/lib/*.jar:/home/tester/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/home/tester/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/home/tester/zookeeper/bin/../lib/netty-3.7.0.Final.jar:/home/tester/zookeeper/bin/../lib/log4j-1.2.16.jar:/home/tester/zookeeper/bin/../lib/jline-0.9.94.jar:/home/tester/zookeeper/bin/../zookeeper-3.4.6.jar:/home/tester/zookeeper/bin/../src/java/lib/*.jar:/home/tester/zookeeper/bin/../conf: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /home/tester/zookeeper/bin/../conf/zoo.cfg
root 21948 0.0 0.0 103252 808 pts/2 D+ 17:55 0:00 grep zook