1. Download the installation file zookeeper-3.4.6.tar.gz mirror address 1: http://apache.fayea.com/zookeeper/Mirror address 2: http:// Mirrors.hust.edu.cn/apache/zookeeper/ 2. or copy the CentOS system desktop 3 to the virtual machine. New/usr/loca/zookeeper folder [[email protected] ~]# mkdir-pv/usr/local/zookeeper 4. Copying files to a specified folder [[email Protected] ~]# cd/root/desktop/[[email protected] ~]# CP./zookeeper-3.4.6.tar.gz/usr/local/zookeeper 5. unzip [[email protected] ~]# tar-zxvf jdk-8u121-linux-x64.tar.gz 6. Configure environment variables [[[email protected] ~] #cd/etc/[[email protected] ~] #cp./profile./profile.bak--Back up the files [email protected] ~] #vi/etc/profile--edit this profile to add this paragraph to the end of the file:--Start and--the middle section. (note, try to keep the environment variable names all uppercase and underlined.)--Start export zookeeper_install=/usr/local/zookeeper/zookeeper-3.4.6/export path= $PATH: $ZOOKEEPER _install/bin--ends 7. configuration file modification [[email protected] zookeeper-3.4.6]# cd/usr/local/zookeeper/zookeeper-3.4.6/conf/--Enter the path to the file [email protected] conf]# CP zoo_sample.cfg zoo.cfg--Copy the zoo.sample.cfg to a zoo. CFG out. File name Force 8. The contents of the file are as follows: [[email protected] conf]# VI zoo.cfg--Press I to enter edit mode. After the modification is complete, ESC exits edit mode, and the capital letter Z double-click saves. # the number of milliseconds of each tickticktime=2000# the number of ticks that the Initia l# synchronization phase can takeinitlimit=10# the number of ticks that can pass between# sending a request and getting an acknowledgementsynclimit=5# the directory where the snapshot is stored.# does not use/tmp for storage,/tmp here are just# Example Sakes.datadir=/tmp/zookeeper--here to set a file path path must exist, not exist, create a new chant datalogdir=/tmp/zookeeper/log--Log path path must exist, If it doesn't exist, create a new one. # The port at which the clients will connectclientport=2181--if it is a multi-machine, add the server ip# the maximum numbe at ClientPort R of Client connections.# increase this if you need to handle more clients#maxclientcnxns=60## is sure to read the Mainten ance 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.purgeinte rval=1 After you modify it, view the. 9 by > # cat zoo.cfg. Turn on the service, close the service, view [[email protected] bin]# cd/usr/local/zookeeper/zookeeper.3.4.6/bin/[[email protected] bin] #./zkserver.sh Stop-stop service JMX enabled by defaultusing Config:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /conf/zoo.cfgstopping Zookeeper ... Stopped [[email protected] bin]#./zkserver.sh Start--turn on service JMX enabled by defaultusing Config:/usr/local/ zookeeper/zookeeper-3.4.6/bin/. /conf/zoo.cfgstarting Zookeeper ... Started [[email protected] bin]#./zkserver.sh Status--View status JMX enabled by defaultusing Config:/usr/local/ zookeeper/zookeeper-3.4.6/bin/. /conf/zoo.cfgmode:standalone[[email protected] bin]# [[email protected] bin]#./zkCli.sh--Client initiated, can view boot status and log connecting to localhost:21812017-03-08 06:15:26,918 [myID:]-INFO [main:[email protected]]-ClIent environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 gmt2017-03-08 06:15:26,923 [myID:]-INFO [ma In:[email protected]]-Client environment:host.name=localhost2017-03-08 06:15:26,923 [myID:]-INFO [Main:[email protected]]-Client environment:java.version=1.8.0_1212017-03-08 06:15:26,925 [myID:]-INFO [main:[email Protected]-Client environment:java.vendor=oracle corporation2017-03-08 06:15:26,926 [myID:]-INFO [Main:[email protected]-Client environment:java.home=/usr/local/java/jdk1.8.0_121/jre2017-03-08 06:15:26,926 [myID:]- INFO [main:[email protected]]-Client environment:java.class.path=/usr/local/zookeeper/zookeeper-3.4.6/bin/. /build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/netty-3.7.0.final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /conf:.:/ usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121 /jre/lib:.:/ usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121 /jre/lib:.:/ usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121 /jre/lib:2017-03-08 06:15:26,926 [myID:]-INFO [main:[email protected]]-Client environment:java.library.path=/ usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib2017-03-08 06:15:26,926 [myID:]-INFO [Main:[email protected]]-Client environment:java.io.tmpdir=/tmp2017-03-08 06:15:26,926 [myID:]-INFO [main:[email ProtecteD]-Client environment:java.compiler=<na>2017-03-08 06:15:26,930 [myID:]-INFO [main:[email protected]]- Client environment:os.name=linux2017-03-08 06:15:26,930 [myID:]-INFO [main:[email protected]]-Client environment:os.arch=amd642017-03-08 06:15:26,930 [myID:]-INFO [main:[email protected]]-Client environment:o s.version=2.6.32-431.el6.x86_642017-03-08 06:15:26,931 [myID:]-INFO [main:[email protected]]-Client environment:user.name=root2017-03-08 06:15:26,931 [myID:]-INFO [main:[email protected]]-Client Environment: user.home=/root2017-03-08 06:15:26,931 [myID:]-INFO [main:[email protected]]-Client ENVIRONMENT:USER.DIR=/USR /local/zookeeper/zookeeper-3.4.6/bin2017-03-08 06:15:26,940 [myID:]-INFO [main:[email protected]]-Initiating Client connection, connectstring=localhost:2181 sessiontimeout=30000 [email protected]welcome to ZooKeeper! 2017-03-08 06:15:27,039 [myID:]-INFO [Main-sendthread (localhost:2181): [EMAIL&NBSp;protected]]-Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Won't attempt to authenticate using SASL (unknown error) JLine support is enabled2017-03-08 06:15:27,290 [myID:]-INFO [Main-sendthread (localhost:2181): [email protected]]-Socket connection established to localhost/ 0:0:0:0:0:0:0:1:2181, initiating session[zk:localhost:2181 (connecting) 0] 2017-03-08 06:15:27,445 [myID:]-INFO [ Main-sendthread (localhost:2181): [email protected]]-Session establishment complete on server localhost/ 0:0:0:0:0:0:0:1:2181, SessionID = 0x15aae45f1330000, negotiated timeout = 30000 watcher:: watchedevent State : syncconnected type:none path:null [email protected] bin]# ps-ef | grep Zookeeper--View zookeeper's service process. It looks like it's pretty good. Root 9779 9774 0 05:26 pts/0 00:00:09/usr/local/java/jdk1.8.0_121/bin/java-dzookeeper.log.dir=. -dzookeeper.root.logger=info,console-cp/usr/local/zookeeper/zookeeper-3.4.6/bin/. /build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/netty-3.7.0.final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /conf:.:/ usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121 /jre/lib:.:/ usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121 /jre/lib:.:/ usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121 /jre/lib:org.apache.zookeeper.zookeepermainroot 10188 10183 0 06:14 pts/0 00:00:00/usr/local/jAva/jdk1.8.0_121/bin/java-dzookeeper.log.dir=. -dzookeeper.root.logger=info,console-cp/usr/local/zookeeper/zookeeper-3.4.6/bin/. /build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/netty-3.7.0.final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /conf:.:/ usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121 /jre/lib:.:/ usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121 /jre/lib:.:/ Usr/local/java/jdk1.8.0_121/liB/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib: Org.apache.zookeeper.ZooKeeperMainroot 10230 1 0 06:15 pts/1 00:00:01/usr/local/java/jdk1.8.0_121/bin/java- Dzookeeper.log.dir=. -dzookeeper.root.logger=info,console-cp/usr/local/zookeeper/zookeeper-3.4.6/bin/. /build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/netty-3.7.0.final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /conf:.:/ Usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:-dcom.sun.management.jmxremote-dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.quorumpeermain/usr/local/zookeeper/zookeeper-3.4.6/bin/. /conf/zoo.cfgroot 10282 10277 0 06:15 pts/0 00:00:01/usr/local/java/jdk1.8.0_121/bin/java-dzookeeper.log.dir=. -dzookeeper.root.logger=info,console-cp/usr/local/zookeeper/zookeeper-3.4.6/bin/. /build/classes:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /build/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/netty-3.7.0.final.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/log4j-1.2.16.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /lib/jline-0.9.94.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /zookeeper-3.4.6.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /src/java/lib/*.jar:/usr/local/zookeeper/zookeeper-3.4.6/bin/. /conf:.:/ Usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121/jre/lib:.:/ usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121 /jre/lib:.:/ usr/local/java/jdk1.8.0_121/lib/dt.jar:/usr/local/java/jdk1.8.0_121/lib/tools.jar:/usr/local/java/jdk1.8.0_121 /jre/lib:org.apache.zookeeper.zookeepermainroot 10314 8885 0 06:18 pts/0 00:00:00 grep zookeeper[[email protected ] Bin]# 10 to this, zookeeper's stand-alone installation is complete.
Install zookeeper under Linux environment