Zookeeper(1)Introduction and Install on Win7

MrZhangAdd 2012-06-09

Zookeeper(1)IntroductionandInstallonWin7

1.Overview

Zookeeperisahigh-performancecoordinationservicefordistributedapplications.

2.InstalltheZookeeperonwin7

Idownloadthelatestversionzookeeper-3.4.3.tar.gz.

Unzipthefileonwindows,copythedirectorytoworkingdirectory.

Addthedirectorytomypath=D:\tool\zookeeper-3.4.3\bin

copytheconfigurationfilefromconf/zoo_sample.cfgtozoo.cfg.Changesomecontentasfollow:

#Thenumberofmillisecondsofeachtick

tickTime=2000

#Thenumberofticksthattheinitial

#synchronizationphasecantake

initLimit=10

#Thenumberofticksthatcanpassbetween

#sendingarequestandgettinganacknowledgement

syncLimit=5

#thedirectorywherethesnapshotisstored.

#donotuse/tmpforstorage,/tmphereisjust

#examplesakes.

dataDir=c://tmp/zookeeper

#theportatwhichtheclientswillconnect

clientPort=2181

#

#Besuretoreadthemaintenancesectionofthe

#administratorguidebeforeturningonautopurge.

#

#http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance

#

#ThenumberofsnapshotstoretainindataDir

#autopurge.snapRetainCount=3

#Purgetaskintervalinhours

#Setto"0"todisableautopurgefeature

#autopurge.purgeInterval=1

runthecommandtostarttheserveronwindows:

>zkServer.cmd

3.Trytheclientonwin7

>zkCli.cmd-server127.0.0.1:2181

>help

>ls/

[zookeeper]

Trytocreateanewznodebyrunningcreate/zk_testmy_datacommand.

>create/zk_testmy_data

Create/zk_test

>ls/

[zookeeper,zk_test]

>get/zk_test

my_data

>set/zk_testjunk

>delete/zk_test

>ls/

[zookeeper]

4.RunningReplicatedZooKeeper

Standalonemodeisconvenientforevaluation,somedevelopment,andtesting.Butinproduction,

weshouldrunZookeeperinreplicatedmode.

Areplicatedgroupofserversinthesameapplicationiscalledaquorum.

Changetheconfigurationzoo.cfgasfollow:

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

initLimitistimeoutsZooKeeperusestolimitthelengthoftimetheZooKeeperserversinquorumhavetoconnecttoaleader.

syncLimitlimitshowfaroutofdateaservercanbefromaleader.

Ifyouwanttotestmultipleserversonasinglemachine,specifytheservernameaslocalhostwithuniquequorum&leaderelectionports(i.e.2888:3888,2889:3889,2890:3890intheexampleabove)foreachserver.Xinthatserver'sconfigfile.OfcourseseparatedataDirsanddistinctclientPortsarealsonecessary(intheabovereplicatedexample,runningonasinglelocalhost,youwouldstillhavethreeconfigfiles).

Itisnotwisetorunitonwindowsfrommyunderstanding,soIfindaredhatservertodothis.

5.InstallationonRedhat

>wgethttp://apache.deathculture.net/zookeeper/zookeeper-3.4.3/zookeeper-3.4.3.tar.gz

>tarzxvfzookeeper-3.4.3.tar.gz

>sudomvzookeeper-3.4.3//opt/tools/

>cpzoo_sample.cfgzoo1.cfg

>vizoo1.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

>vizoo2.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

>vizoo3.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

Createthesedirectory

>mkdir/tmp/zookeeper/snapshot/d_1

>mkdir/tmp/zookeeper/snapshot/d_2

>mkdir/tmp/zookeeper/snapshot/d_3

Andcreatefilemyidunderthesedirectory

>vi/tmp/zookeeper/snapshot/d_1/myid

1

>vi/tmp/zookeeper/snapshot/d_2/myid

2

>vi/tmp/zookeeper/snapshot/d_3/myid

3

Addthistomymyprofilepath

>sudovi/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

starttheserverwiththesecommands:

>zkServer.shstartzoo1.cfg

>zkServer.shstartzoo2.cfg

>zkServer.shstartzoo3.cfg

Checkiftheserverisstarted.

>jps

10129Jps

9783QuorumPeerMain

9815QuorumPeerMain

9844QuorumPeerMain

Itrytoconnecttheserverwithmyclient.ButIgottheseerrormessage:

ErrorMessage:

WelcometoZooKeeper!

2012-06-0914:22:20,543[myid:]-WARN[main-SendThread(localhost.localdomain:2181):ZooKeeperSaslClient@123]-SecurityException:java.lang.SecurityException:UnabletolocatealoginconfigurationoccurredwhentryingtofindJAASconfiguration.

2012-06-0914:22:20,544[myid:]-INFO[main-SendThread(localhost.localdomain:2181):ZooKeeperSaslClient@125]-ClientwillnotSASL-authenticatebecausethedefaultJAASconfigurationsection'Client'couldnotbefound.IfyouarenotusingSASL,youmayignorethis.Ontheotherhand,ifyouexpectedSASLtowork,pleasefixyourJAASconfiguration.

2012-06-0914:22:20,590[myid:]-INFO[main-SendThread(localhost.localdomain:2181):ClientCnxn$SendThread@1053]-Unabletoreadadditionaldatafromserversessionid0x0,likelyserverhasclosedsocket,closingsocketconnectionandattemptingreconnect

2012-06-0914:22:29,264[myid:]-WARN[main-SendThread(localhost.localdomain:2181):ZooKeeperSaslClient@123]-SecurityException:java.lang.SecurityException:UnabletolocatealoginconfigurationoccurredwhentryingtofindJAASconfiguration.

2012-06-0914:22:29,264[myid:]-INFO[main-SendThread(localhost.localdomain:2181):ZooKeeperSaslClient@125]-ClientwillnotSASL-authenticatebecausethedefaultJAASconfigurationsection'Client'couldnotbefound.IfyouarenotusingSASL,youmayignorethis.Ontheotherhand,ifyouexpectedSASLtowork,pleasefixyourJAASconfiguration.

Solution:

>sudovi/etc/hosts

iphadoop_name

Notsolvethisproblem.Iwillchecklater.

references:

http://zookeeper.apache.org/

http://blog.csdn.net/baiduforum/article/details/6981456

http://blog.csdn.net/gudaoqianfu/article/details/7327191

相关推荐

一个人的世界 / 0评论 2018-08-25