Zookeeper installation Run

Source: Internet
Author: User
Tags auth zookeeper zookeeper client
Zookeeper Introduction

Zookeeper is a full-fledged subproject of Hadoop, a reliable coordination system for large distributed systems, with features such as configuration maintenance, name services, distributed synchronization, group services, and so on. Zookeeper's goal is to encapsulate complex and error-prone key services, delivering easy-to-use interfaces and high-performance, functionally stable systems to users.

Zookeeper is an open-source implementation of Google's chubby. is a highly effective and reliable collaborative work system. Zookeeper can be used to leader elections, configure information maintenance, and so on. In a distributed environment, we need a master instance or store some configuration information To ensure the consistency of file writes. Zookeeper can guarantee the following 3 points: Watches are ordered with respect to other events, other Watches, and
Asynchronous replies. The Zookeeper client libraries ensures that
Everything is dispatched in order. A client would-watch event for a znode it's watching before seeing the new data that corresponds. The Order of watch events from zookeeper corresponds to the "Order of" the updates as seen by the zookeeper service.

In zookeeper, Znode is a node similar to the UNIX file system path where data can be stored or retrieved. If flag is set to ephemeral when the Znode is created, Then this znode will no longer exist in zookeeper when the node that created this znode is disconnected from zookeeper. Zookeeper uses watcher to detect event information, when the client receives event information, such as connection timeout, node data change, Child node changes, you can invoke the appropriate behavior to process the data. Zookeeper's wiki page shows how to use zookeeper to handle event notifications, queues, priority queues, locks, shared locks, revocable shared locks, and two-phase commit. Zookeeper official website

Zookeeper official website Zookeeper installation

First download the latest version of zookeeper-3.4.5.tar.gz

and unzip it.

Tar zxvf zookeeper-3.4.5.tar.gz

Then enter the Conf directory to modify ZOO_SAMPLE.CFG for zoo.cfg

Then VI zoo.cfg

Change to:

# The number of milliseconds of tick ticktime=2000 # The number of
ticks that initial 
# Synchronizati On phase can take
initlimit=10 # The number of
ticks so can pass between 
# Sending a request and getting a Acknowledgement
synclimit=5
# The directory where the snapshot is stored.
# do not use/tmp for storage,/tmp here is just 
# example sakes.
Datadir=/tmp/zookeeper
# The port at which the clients'll connect
clientport=2181
# be
sure to Rea d 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 into DataDir
#autopurge. snapretaincount=3
# Purge task interval in hours
# Set to ' 0 ' to Disable Auto Purge feature
#autopurge. purgeinterval=1

Edit save into Bin directory execution

./zkserver.sh start zookeeper test

[Root@localhost bin]#./zkcli.sh Connecting to localhost:2181 2013-01-16 [14:36:22,484:]-INFO [myID 0]-Client environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT 2013-01-16 14:36:22,488 [myID:]-I NFO [main:environment@100]-Client environment:host.name=localhost.localdomain 2013-01-16 14:36:22,489 [myID:]-INFO [ MAIN:ENVIRONMENT@100]-Client environment:java.version=1.6.0_29 2013-01-16 14:36:22,489 [myID:]-INFO [main: ENVIRONMENT@100]-Client Environment:java.vendor=sun Microsystems Inc. 2013-01-16 14:36:22,490 [myID:]-INFO [Main:Envi RONMENT@100]-Client environment:java.home=/usr/java/jdk1.6.0_29/jre 2013-01-16 14:36:22,490 [myID:]-INFO [main: ENVIRONMENT@100]-Client environment:java.class.path=/usr/local/zookeeper-3.4.5/bin/. /build/classes:/usr/local/zookeeper-3.4.5/bin/.. /build/lib/*.jar:/usr/local/zookeeper-3.4.5/bin/.. /lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper-3.4.5/bin/.. /lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper-3.4.5/bin/.. /lib/netty-3.2.2.final.jar:/usr/local/zookeeper-3.4.5/bin/.. /lib/log4j-1.2.15.jar:/usr/local/zookeeper-3.4.5/bin/.. /lib/jline-0.9.94.jar:/usr/local/zookeeper-3.4.5/bin/.. /zookeeper-3.4.5.jar:/usr/local/zookeeper-3.4.5/bin/.. /src/java/lib/*.jar:/usr/local/zookeeper-3.4.5/bin/.. /conf:./:/usr/java/jdk1.6.0_29/lib:/usr/java/jdk1.6.0_29/jre/lib 2013-01-16 14:36:22,491 [myID:]-INFO [main: ENVIRONMENT@100]-Client environment:java.library.path=/usr/java/jdk1.6.0_29/jre/lib/i386/client:/usr/java/ Jdk1.6.0_29/jre/lib/i386:/usr/java/jdk1.6.0_29/jre/.. /lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib 2013-01-16 14:36:22,491 [myID:]-INFO [main:environment@100]- Client environment:java.io.tmpdir=/tmp 2013-01-16 14:36:22,491 [myID:]-INFO [main:environment@100]-Client environmen t:java.compiler=<na> 2013-01-16 14:36:22,492 [myID:]-INFO [main:environment@100]-Client environment:os.name= Linux 2013-01-16 14:36:22,492 [myID:]-INFO [main:environment@100]-CliENT environment:os.arch=i386 2013-01-16 14:36:22,493 [myID:]-INFO [main:environment@100]-Client Environment:os.versi On=2.6.18-308.24.1.el5 2013-01-16 14:36:22,493 [myID:]-INFO [main:environment@100]-Client environment:user.name= Root 2013-01-16 14:36:22,493 [myID:]-INFO [main:environment@100]-Client environment:user.home=/root 2013-01-16 14:36: 22,494 [myID:]-INFO [main:environment@100]-Client environment:user.dir=/usr/local/zookeeper-3.4.5/bin 2013-01-16 14 : 36:22,496 [myID:]-INFO [main:zookeeper@438]-Initiating client connection, connectstring=localhost:2181 Sessiontimeo
ut=30000 watcher=org.apache.zookeeper.zookeepermain$mywatcher@5ffb18 Welcome to zookeeper! 2013-01-16 14:36:22,592 [myID:]-INFO [Main-sendthread (localhost.localdomain:2181): clientcnxn$sendthread@966]- Opening socket connection to server localhost.localdomain/127.0.0.1:2181. Will isn't attempt to authenticate using SASL (Unable to locate login configuration) 2013-01-16 14:36:22,601 [myID:]-INFO [Main-sendthread (Localhost.localdomain:2181): clientcnxn$sendthread@849]-Socket connection established to localhost.localdomain/ 127.0.0.1:2181, initiating session jline support are enabled 2013-01-16 14:36:22,693 [myID:]-INFO [Main-sendthread (Local host.localdomain:2181): clientcnxn$sendthread@1207]-session establishment complete on server localhost.localdomain/ 127.0.0.1:2181, SessionID = 0x13c3c5224cc0000, negotiated timeout = 30000 Watcher:: Watchedevent state:syncconnected Typ
        E:none Path:null [zk:localhost:2181 (CONNECTED) 0] help zookeeper-server host:port cmd args connect host:port Get path [watch] ls path [watch] set path data [version] RMR path Delquota [-n|-b] pa Th quit printwatches On|off create [s] [e] path data ACL stat path [watch] Clos e LS2 path [watch] history Listquota path setacl path ACL getacl path sy NC path Redo Cmdno Addauth Scheme auth Delete path [version] setquota-n|-b val path [zk:localhost:2181 (CONNECTED) 1] create/my_data "da Ta.ch.com "Created/my_data [zk:localhost:2181 (CONNECTED) 2] get/my_data" data.ch.com "Czxid = 0x2 CTime = Wed 16 14 : 38:20 CST 2013 MZXID = 0x2 mtime = Wed, 14:38:20 CST 2013 Pzxid = 0x2 cversion = 0 dataversion = 0 aclversion = 0 E Phemeralowner = 0x0 Datalength = Numchildren = 0 [zk:localhost:2181 (CONNECTED) 3] set/my_date "123456.com" Node does Not exist:/my_date [zk:localhost:2181 (CONNECTED) 4] set/my_data "123456.com" Czxid = 0x2 CTime = Wed the following 14:38:20 CS T 2013 Mzxid = 0x4 mtime = Wed, 14:38:58 CST 2013 Pzxid = 0x2 cversion = 0 dataversion = 1 aclversion = 0 Ephemeralo  Wner = 0x0 Datalength = Numchildren = 0 [zk:localhost:2181 (CONNECTED) 5] get/my_data "123456.com" Czxid = 0x2 CTime = Wed 14:38:20 CST 2013 MZXID = 0x4 mtime = Wed of 14:38:58 CST 2013 PZXID = 0x2 cversion = 0 dataversion = 1 ac lversion = 0 EphemeralowNER = 0x0 Datalength = Numchildren = 0 [zk:localhost:2181 (CONNECTED) 6] create/mytemp "How are You?" Created/mytemp [Zk:loca lhost:2181 (CONNECTED) 7] get/myt Node does not exist:/myt [zk:localhost:2181 (CONNECTED) 8] get/mytemp "How are you?" Czxid = 0x 5 CTime = Wed 14:40:44 CST 2013 MZXID = 0x5 mtime = Wed of the CST 14:40:44 2013 = Pzxid 0x5 = 0 cversion On = 0 Aclversion = 0 Ephemeralowner = 0x0 datalength = one numchildren = 0 [zk:localhost:2181 (CONNECTED) 9] get/mytemp " How are you doing? "Czxid = 0x5 CTime = Wed of the 14:40:44 CST 2013 MZXID = 0x5 mtime = Wed of the 14:40:44 CST 2013 PZXID = 0x5 Cversio n = 0 dataversion = 0 aclversion = 0 Ephemeralowner = 0x0 datalength = one numchildren = 0 [zk:localhost:2181 (CONNECTED) 1 0] get/my_data "123456.com" Czxid = 0x2 CTime = Wed of the 14:38:20 CST 2013 MZXID = 0x4 mtime = Wed of the 14:38:58 CST 2013 Pzxid = 0x2 cversion = 0 dataversion = 1 aclversion = 0 Ephemeralowner = 0x0 datalength = Numchildren = 0 [Zk:loc alhost:2181 (CONNECTED) 11] ls zookeeper-server host:port cmd args connect host:port get path [watch] ls path [watch]
        Set path data [version] RMR path Delquota [-n|-b] path quit Printwatches On|off 
        Create [-S] [e] path data ACL stat path [watch] close LS2 path [watch] History Listquota path setacl path ACL getacl path sync path redo Cmdno addauth scheme  Auth delete path [version] setquota-n|-b val path [zk:localhost:2181 (CONNECTED) 12]


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.