MyException - 我的异常网
当前位置:我的异常网» 软件架构设计 » Zookeeper(一)Introduction and Install on Win7

Zookeeper(一)Introduction and Install on Win7

www.MyException.Cn  网友分享于:2013-06-29  浏览:298次
Zookeeper(1)Introduction and Install on Win7
Zookeeper(1)Introduction and Install on Win7

1. Overview
Zookeeper is a high-performance coordination service for distributed applications.

2. Install the Zookeeper on win7
I download the latest version zookeeper-3.4.3.tar.gz.

Unzip the file on windows, copy the directory to working directory.

Add the directory to my path=D:\tool\zookeeper-3.4.3\bin

copy the configuration file from conf/zoo_sample.cfg to zoo.cfg. Change some content as follow:
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=c://tmp/zookeeper
# the port at which the clients will connect
clientPort=2181
#
# Be sure to read 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 in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

run the command to start the server on windows:
>zkServer.cmd

3. Try the client on win7
>zkCli.cmd -server 127.0.0.1:2181

>help

>ls /
[zookeeper]

Try to create a new znode by running create /zk_test my_data command.
>create /zk_test my_data
Create /zk_test
>ls /
[zookeeper, zk_test]

>get /zk_test
my_data

>set /zk_test junk

>delete /zk_test
>ls /
[zookeeper]

4. Running Replicated ZooKeeper
Standalone mode is convenient for evaluation, some development, and testing. But in production,
we should run Zookeeper in replicated mode.

A replicated group of servers in the same application is called a quorum.

Change the configuration zoo.cfg as follow:
tickTime=2000
initLimit=10
syncLimit=5
dataDir=c://tmp/zookeeper
clientPort=2181
server.1=zoo1:2888:3888
server.2=zoo2:2888:3888
server.3=zoo3:2888:3888


initLimit is timeouts ZooKeeper uses to limit the length of time the ZooKeeper servers in quorum have to connect to a leader.

syncLimit limits how far out of date a server can be from a leader.

If you want to test multiple servers on a single machine, specify the servername as localhost with unique quorum & leader election ports (i.e. 2888:3888, 2889:3889, 2890:3890 in the example above) for each server.X in that server's config file. Of course separate dataDirs and distinct clientPorts are also necessary (in the above replicated example, running on a single localhost, you would still have three config files).

It is not wise to run it on windows from my understanding, so I find a redhat server to do this.

5. Installation on Redhat
>wget http://apache.deathculture.net/zookeeper/zookeeper-3.4.3/zookeeper-3.4.3.tar.gz
>tar zxvf zookeeper-3.4.3.tar.gz
>sudo mv zookeeper-3.4.3/ /opt/tools/
>cp zoo_sample.cfg zoo1.cfg
>vi zoo1.cfg
ckTime=2000
initLimit=10
syncLimit=5
dataDir=/tmp/zookeeper/snapshot/d_1
clientPort=2181
server.1=zoo1:2888:3888
server.2=zoo2:2889:3889
server.3=zoo3:2890:3890

>vi zoo2.cfg
ckTime=2000
initLimit=10
syncLimit=5
dataDir=/tmp/zookeeper/snapshot/d_2
clientPort=2182
server.1=zoo1:2888:3888
server.2=zoo2:2889:3889
server.3=zoo3:2890:3890

>vi zoo3.cfg
ckTime=2000
initLimit=10
syncLimit=5
dataDir=/tmp/zookeeper/snapshot/d_3
clientPort=2183
server.1=zoo1:2888:3888
server.2=zoo2:2889:3889
server.3=zoo3:2890:3890

Create these directory
>mkdir /tmp/zookeeper/snapshot/d_1
>mkdir /tmp/zookeeper/snapshot/d_2
>mkdir /tmp/zookeeper/snapshot/d_3

And create file myid under these directory
>vi /tmp/zookeeper/snapshot/d_1/myid
1
>vi /tmp/zookeeper/snapshot/d_2/myid
2
>vi /tmp/zookeeper/snapshot/d_3/myid
3

Add this to my myprofile path
>sudo vi /etc/profile
PATH=.:$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin:$ANT_HOME/bin:/sbin:/opt/tools/zookeeper-3.4.3/bin:/usr/sbin:/usr/local/sbin:/home/luohua/git-1.7.6
>. /etc/profile

start the server with these commands:
>zkServer.sh start zoo1.cfg
>zkServer.sh start zoo2.cfg
>zkServer.sh start zoo3.cfg

Check if the server is started.
>jps
10129 Jps
9783 QuorumPeerMain
9815 QuorumPeerMain
9844 QuorumPeerMain

I try to connect the server with my client. But I got these error message:
Error Message:
Welcome to ZooKeeper!
2012-06-09 14:22:20,543 [myid:] - WARN  [main-SendThread(localhost.localdomain:2181):ZooKeeperSaslClient@123] - SecurityException: java.lang.SecurityException: Unable to locate a login configuration occurred when trying to find JAAS configuration.
2012-06-09 14:22:20,544 [myid:] - INFO  [main-SendThread(localhost.localdomain:2181):ZooKeeperSaslClient@125] - Client will not SASL-authenticate because the default JAAS configuration section 'Client' could not be found. If you are not using SASL, you may ignore this. On the other hand, if you expected SASL to work, please fix your JAAS configuration.

2012-06-09 14:22:20,590 [myid:] - INFO  [main-SendThread(localhost.localdomain:2181):ClientCnxn$SendThread@1053] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect

2012-06-09 14:22:29,264 [myid:] - WARN  [main-SendThread(localhost.localdomain:2181):ZooKeeperSaslClient@123] - SecurityException: java.lang.SecurityException: Unable to locate a login configuration occurred when trying to find JAAS configuration.
2012-06-09 14:22:29,264 [myid:] - INFO  [main-SendThread(localhost.localdomain:2181):ZooKeeperSaslClient@125] - Client will not SASL-authenticate because the default JAAS configuration section 'Client' could not be found. If you are not using SASL, you may ignore this. On the other hand, if you expected SASL to work, please fix your JAAS configuration.

Solution:
>sudo vi /etc/hosts
ip hadoop_name

Not solve this problem. I will check later.

references:
http://zookeeper.apache.org/
http://blog.csdn.net/baiduforum/article/details/6981456
http://blog.csdn.net/gudaoqianfu/article/details/7327191
http://haohouhou.iteye.com/blog/1424048


文章评论

Web开发者需具备的8个好习惯
Web开发者需具备的8个好习惯
如何区分一个程序员是“老手“还是“新手“?
如何区分一个程序员是“老手“还是“新手“?
团队中“技术大拿”并非越多越好
团队中“技术大拿”并非越多越好
程序员最害怕的5件事 你中招了吗?
程序员最害怕的5件事 你中招了吗?
程序猿的崛起——Growth Hacker
程序猿的崛起——Growth Hacker
程序员周末都喜欢做什么?
程序员周末都喜欢做什么?
Java 与 .NET 的平台发展之争
Java 与 .NET 的平台发展之争
做程序猿的老婆应该注意的一些事情
做程序猿的老婆应该注意的一些事情
看13位CEO、创始人和高管如何提高工作效率
看13位CEO、创始人和高管如何提高工作效率
漫画:程序员的工作
漫画:程序员的工作
5款最佳正则表达式编辑调试器
5款最佳正则表达式编辑调试器
程序员眼里IE浏览器是什么样的
程序员眼里IE浏览器是什么样的
十大编程算法助程序员走上高手之路
十大编程算法助程序员走上高手之路
老程序员的下场
老程序员的下场
旅行,写作,编程
旅行,写作,编程
我的丈夫是个程序员
我的丈夫是个程序员
每天工作4小时的程序员
每天工作4小时的程序员
老美怎么看待阿里赴美上市
老美怎么看待阿里赴美上市
Java程序员必看电影
Java程序员必看电影
一个程序员的时间管理
一个程序员的时间管理
“懒”出效率是程序员的美德
“懒”出效率是程序员的美德
程序员的一天:一寸光阴一寸金
程序员的一天:一寸光阴一寸金
中美印日四国程序员比较
中美印日四国程序员比较
10个帮程序员减压放松的网站
10个帮程序员减压放松的网站
为啥Android手机总会越用越慢?
为啥Android手机总会越用越慢?
什么才是优秀的用户界面设计
什么才是优秀的用户界面设计
程序员的鄙视链
程序员的鄙视链
聊聊HTTPS和SSL/TLS协议
聊聊HTTPS和SSL/TLS协议
科技史上最臭名昭著的13大罪犯
科技史上最臭名昭著的13大罪犯
编程语言是女人
编程语言是女人
 程序员的样子
程序员的样子
初级 vs 高级开发者 哪个性价比更高?
初级 vs 高级开发者 哪个性价比更高?
Web开发人员为什么越来越懒了?
Web开发人员为什么越来越懒了?
程序员都该阅读的书
程序员都该阅读的书
我是如何打败拖延症的
我是如何打败拖延症的
60个开发者不容错过的免费资源库
60个开发者不容错过的免费资源库
程序员和编码员之间的区别
程序员和编码员之间的区别
程序员必看的十大电影
程序员必看的十大电影
总结2014中国互联网十大段子
总结2014中国互联网十大段子
10个调试和排错的小建议
10个调试和排错的小建议
代码女神横空出世
代码女神横空出世
要嫁就嫁程序猿—钱多话少死的早
要嫁就嫁程序猿—钱多话少死的早
程序员应该关注的一些事儿
程序员应该关注的一些事儿
不懂技术不要对懂技术的人说这很容易实现
不懂技术不要对懂技术的人说这很容易实现
当下全球最炙手可热的八位少年创业者
当下全球最炙手可热的八位少年创业者
软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有