Zookeeper's installation mode is divided into three types, namely: Single machine mode (stand-alone), cluster mode and cluster pseudo-distribution mode. ZooKeeper stand-alone mode installation is relatively simple, if the first contact with ZooKeeper, it is recommended to install ZooKeeper single-machine mode or cluster pseudo-distribution mode.
ZooKeeper Standalone Mode
To download the zookeeper package from the Apache website (zookeeper.apache.org), I chose the 3.3.4 version (ZOOKEEPER-3.3.4.TAR.GZ), installed on a Linux machine is very easy, only need to decompress, simple configuration can be started Zookeeper server process.
Modify the zoo_sample.cfg below the zookeeper-3.3.4/conf directory to Zoo.cfg, and the configuration file contents are as follows:
[plain] view plain copy ticktime=2000 datadir=/home/hadoop/storage/zookeeper clientport=2181 initlimit=5 synclimit=2 the meaning of each configuration parameter above is also very simple, the reference is as follows:
[plain] view plain copy ticktime--the basic time unit in milliseconds used by ZooKeeper. It's used to do heartbeats and the minimum session timeout would be twice the ticktime. Datadir--the location to store the In-memory database snapshots and, unless specified otherwise, the transaction log of Updates to the database. Clientport--the The Zookeeper server process starts below the port to listen for client connections:
[plain] view plain copy CD zookeeper-3.3.4/bin/zkserver.sh start with JPS command to view Zookeeper server process, named Quorumpeermai N.
To connect the zookeeper server to the client, execute the following command:
[plain] view plain copy bin/zkcli.sh-server dynamic:2181 above dynamic is my hostname, if executed natively, execute the following command:
[plain] view Plain copy bin/zkcli.sh Client connection information is as follows:
[Plain] View Plain Copy hadoop@master:~/installation/zookeeper-3.3.4$ bin/zkcli.sh -server dynamic :2181 connecting to dynamic:2181 2012-01-08 21:30:06,178 - info [main:Environment@97] - Client environment:zookeeper.version=3.3.3-1203054, built on 11/17/2011 05:47 gmt 2012-01-08 21:30:06,188 - info [main:Environment@97] - Client environment:host.name=master 2012-01-08 21:30:06,191 - info [main:environment@97] - client environment: java.version=1.6.0_30 2012-01-08 21:30:06,194 - info [main:environment@97 ] - client environment:java.vendor=sun microsystems inc. 2012-01-08 21:30:06,200 - info [main:environment@97] - client environment:java.home=/ Home/hadoop/installation/jdk1.6.0_30/jre 2012-01-08 21:30:06,203 - info [main: environment@97] - client environment:java.class.path=/home/hadoop/installation/zookeeper-3.3.4/ bin/. /build/classes:/home/hadoop/installation/zookeeper-3.3.4/bin/. /build/lib/*.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/. /zookeeper-3.3.4.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/. /lib/log4j-1.2.15.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/. /lib/jline-0.9.94.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/. /lib/commons-lang-2.4.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/. /lib/commons-collections-3.2.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/. /lib/commons-cli-1.1.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/. /lib/apache-rat-tasks-0.6.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/. /lib/apache-rat-core-0.6.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/. /src/java/lib/*.jar:/home/hadoop/installation/zookeeper-3.3.4/bin/. /conf:/home/hadoop/installation/jdk1.6.0_30/lib/*.jar:/home/hadoop/installation/jdk1.6.0_30/jre/lib/*.jar 2012-01-08 21:30:06,206 - info [main:environment@97] - client environment:java.library.path=/home/hadoop/installation/jdk1.6.0_30/jre/lib/i386/client:/home/hadoop/ Installation/jdk1.6.0_30/jre/lib/i386:/home/hadoop/installation/jdk1.6.0_30/jre/. /lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib 2012-01-08 21:30:06,213 - info [main:Environment@97] - Client environment:java.io.tmpdir=/tmp 2012-01-08 21:30:06,216 - info [main:environment@97] - client environment:java.compiler=<na> 2012-01-08 21:30:06,235 - info [main :environment@97] - client environment:os.name=linux 2012-01-08 21:30:06,244 - info [main:environment@97] -&nbSp client environment:os.arch=i386 2012-01-08 21:30:06,246 - info [main :environment@97] - client environment:os.version=3.0.0-14-generic 2012-01-08 21:30:06,251 - info [main:environment@97] - client environment:user.name= hadoop 2012-01-08 21:30:06,254 - info [main:environment@97] - client environment:user.home=/home/hadoop 2012-01-08 21:30:06,255 - info [main:environment@97] - client environment:user.dir=/home/hadoop/installation/ zookeeper-3.3.4 2012-01-08 21:30:06,264 - info [main:zookeeper@379] - initiating client connection, connectstring=dynamic:2181 sessiontimeout=30000 watcher=org.apache.zookeeper.zookeepermain$mywatcher@bf32c 2012-01-08 21:30:06,339 - INFO [Main-sendthread ():clientcnxn$sendthread@1061] - opening socket connection to server dynamic/192.168.0.107:2181 welcome to zookeeper! 2012-01-08 21:30:06,397 - info [main-sendthread (dynamic:2181): clientcnxn$sendthread@950] - Socket connection established to dynamic/192.168.0.107:2181, initiating session jline support is enabled 2012-01-08 21:30:06,492 - info [main-sendthread (dynamic:2181):clientcnxn$sendthread@739] - session establishment complete on server dynamic/192.168.0.107:2181, sessionid = 0x134b9b714f9000c, negotiated timeout = 30000 WATCHER:: watchedevent state:syncconnected type:none path:null [zk: dynamic : 2181 (CONNECTED) 0]
You can then use Help to view the basic operations commands that the zookeeper client can use.