<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">zookeeper可以作为一个小的存储数据库使用。用于实时计算。</span>
启动zk server
[hadoop@hutx kafka_2.9.2-0.8.1.1]$ bin/zookeeper-server-start.sh config/zookeeper.properties[2014-08-06 01:59:26,853] INFO Reading configuration from: config/zookeeper.properties (org.apache.zookeeper.server.quorum.QuorumPeerConfig)[2014-08-06 01:59:26,874] WARN Either no config or no quorum defined in config, running in standalone mode (org.apache.zookeeper.server.quorum.QuorumPeerMain)[2014-08-06 01:59:26,910] INFO Reading configuration from: config/zookeeper.properties (org.apache.zookeeper.server.quorum.QuorumPeerConfig)[2014-08-06 01:59:26,923] INFO Starting server (org.apache.zookeeper.server.ZooKeeperServerMain)[2014-08-06 01:59:26,950] INFO Server environment:zookeeper.version=3.3.3-1203054, built on 11/17/2011 05:47 GMT (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 01:59:26,950] INFO Server environment:host.name=hutx (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 01:59:26,950] INFO Server environment:java.version=1.7.0_65 (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 01:59:26,950] INFO Server environment:java.vendor=Oracle Corporation (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 01:59:26,950] INFO Server environment:java.home=/home/hadoop/jdk1.7.0_65/jre (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 01:59:26,950] INFO Server environment:java.class.path=.:/home/hadoop/jdk1.7.0_65/lib:/home/hadoop/jdk1.7.0_65/jre/lib::/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../core/build/dependant-libs-2.8.0/*.jar:/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../perf/build/libs//kafka-perf_2.8.0*.jar:/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../clients/build/libs//kafka-clients*.jar:/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../examples/build/libs//kafka-examples*.jar:/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../contrib/hadoop-consumer/build/libs//kafka-hadoop-consumer*.jar:/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../contrib/hadoop-producer/build/libs//kafka-hadoop-producer*.jar:/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../libs/jopt-simple-3.2.jar:/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../libs/kafka_2.9.2-0.8.1.1.jar:/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../libs/kafka_2.9.2-0.8.1.1-javadoc.jar:/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../libs/kafka_2.9.2-0.8.1.1-scaladoc.jar:/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../libs/kafka_2.9.2-0.8.1.1-sources.jar:/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../libs/log4j-1.2.15.jar:/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../libs/metrics-core-2.2.0.jar:/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../libs/scala-library-2.9.2.jar:/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../libs/slf4j-api-1.7.2.jar:/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../libs/slf4j-nop-1.7.7.jar:/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../libs/snappy-java-1.0.5.jar:/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../libs/zkclient-0.3.jar:/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../libs/zookeeper-3.3.4.jar:/home/hadoop/kafka_2.9.2-0.8.1.1/bin/../core/build/libs/kafka_2.8.0*.jar (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 01:59:26,951] INFO Server environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 01:59:26,951] INFO Server environment:java.io.tmpdir=/tmp (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 01:59:26,951] INFO Server environment:java.compiler=<NA> (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 01:59:26,951] INFO Server environment:os.name=Linux (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 01:59:26,952] INFO Server environment:os.arch=amd64 (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 01:59:26,952] INFO Server environment:os.version=2.6.18-274.el5 (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 01:59:26,952] INFO Server environment:user.name=hadoop (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 01:59:26,952] INFO Server environment:user.home=/home/hadoop (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 01:59:26,952] INFO Server environment:user.dir=/home/hadoop/kafka_2.9.2-0.8.1.1 (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 01:59:26,965] INFO tickTime set to 3000 (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 01:59:26,966] INFO minSessionTimeout set to -1 (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 01:59:26,967] INFO maxSessionTimeout set to -1 (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 01:59:26,988] INFO binding to port 0.0.0.0/0.0.0.0:2181 (org.apache.zookeeper.server.NIOServerCnxn)[2014-08-06 01:59:27,021] INFO Reading snapshot /home/hadoop/zktmp/version-2/snapshot.0 (org.apache.zookeeper.server.persistence.FileSnap)[2014-08-06 01:59:27,137] INFO Snapshotting: 2c (org.apache.zookeeper.server.persistence.FileTxnSnapLog)[2014-08-06 01:59:36,002] INFO Expiring session 0x1478ca52bc00006, timeout of 6000ms exceeded (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 01:59:36,002] INFO Processed session termination for sessionid: 0x1478ca52bc00006 (org.apache.zookeeper.server.PrepRequestProcessor)[2014-08-06 01:59:36,003] INFO Creating new log file: log.2d (org.apache.zookeeper.server.persistence.FileTxnLog)[2014-08-06 02:00:00,003] INFO Expiring session 0x1478ca52bc00009, timeout of 30000ms exceeded (org.apache.zookeeper.server.ZooKeeperServer)[2014-08-06 02:00:00,003] INFO Processed session termination for sessionid: 0x1478ca52bc00009 (org.apache.zookeeper.server.PrepRequestProcessor)[2014-08-06 02:03:38,860] INFO Accepted socket connection from /127.0.0.1:36100 (org.apache.zookeeper.server.NIOServerCnxn)[2014-08-06 02:03:38,868] INFO Client attempting to establish new session at /127.0.0.1:36100 (org.apache.zookeeper.server.NIOServerCnxn)[2014-08-06 02:03:38,878] INFO Established session 0x147aa8b644b0000 with negotiated timeout 30000 for client /127.0.0.1:36100 (org.apache.zookeeper.server.NIOServerCnxn)
启动客户端;
[hadoop@hutx bin]$ ./zookeeper-shell.sh localhost:2181 Connecting to localhost:2181 Welcome to ZooKeeper! JLine support is disabled WATCHER:: WatchedEvent state:SyncConnected type:None path:null ls / [testRootPath, zk, zkk, zookeeper, hu]