Zookeeper pseudo-cluster environment construction

Source: Internet
Author: User

1. Download the package from the official website.


2. Unzip.

[Email protected] software]$ tar xzvf zookeeper-3.4.6.tar.gz

3. Create the data directory after entering the zookeeper directory.

[[Email protected] software]$ CD Zookeeper-3.4.6[[email protected] software]$ mkdir data
[[Email protected] software]$ CD Data[[email protected] software]$ touch myID

myID This file must be created, or it will run out the following exception when it is started.

[[email protected] bin]$./zkserver.sh start-foregroundjmx enabled by defaultusing Config:/home/dev/zookeeper/ zookeeper1/bin/. /conf/zoo.cfg2015-03-12 16:06:38,155 [myID:]-INFO [main:[email protected]]-Reading configuration from:/home/de v/zookeeper/zookeeper1/bin/. /conf/zoo.cfg2015-03-12 16:06:38,159 [myID:]-INFO [main:[email protected]]-defaulting to majority quorums2015-0 3-12 16:06:38,161 [myID:]-ERROR [main:[email protected]]-Invalid config, exiting Abnormallyorg.apache.zookeeper . Server.quorum.quorumpeerconfig$configexception:error processing/home/dev/zookeeper/zookeeper1/bin/. /conf/zoo.cfg at Org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse (quorumpeerconfig.java:121) at Org.apach E.zookeeper.server.quorum.quorumpeermain.initializeandrun (quorumpeermain.java:101) at Org.apache.zookeeper.server.quorum.QuorumPeerMain.main (quorumpeermain.java:78) caused by: Java.lang.IllegalArgumentException:/home/dev/zookeeper/zookeeper1/data/myID file is missing at Org.apache.zookeeper.server.quorum.QuorumPeerConfig.parseProperties (Quorumpeerconfig.java : 344) at Org.apache.zookeeper.server.quorum.QuorumPeerConfig.parse (quorumpeerconfig.java:117) ... 2 moreinvalid config, exiting abnormally

The content must be in the myID file, and its value corresponds to the ID of the server in Zoo.cfg. A bit around, I also tried several times to be well-equipped. Also say, if the cluster is configured as follows, that question, how to distinguish between the current start of the zookeeper is? is through the myID file to distinguish, 1th zookeeper service myID file content is 1, and so on. If myID match wrong, the consequence is very serious--zookeeper service does not come, O (∩_∩) o haha ~, and reported the following exception.

server.1=localhost:2888:3888server.2=localhost:2889:3889server.3=localhost:2890:3890
[[email protected] bin]$./zkserver.sh start-foregroundjmx enabled by defaultusing Config:/home/dev/zookeeper/ zookeeper2/bin/. /conf/zoo.cfg2015-03-12 16:09:35,422 [myID:]-INFO [main:[email protected]]-Reading configuration from:/home/de v/zookeeper/zookeeper2/bin/. /conf/zoo.cfg2015-03-12 16:09:35,426 [myID:]-INFO [main:[email protected]]-defaulting to majority quorums2015-0 3-12 16:09:35,434 [myid:0]-INFO [main:[email protected]]-autopurge.snapretaincount set to 32015-03-12 16:09:35,4 [myid:0]-INFO [main:[email protected]]-autopurge.purgeinterval set to 02015-03-12 16:09:35,435 [myid:0]-INF O [main:[email protected]]-Purge task is not scheduled.2015-03-12 16:09:35,455 [myid:0]-INFO [main:[email   Protected]]-starting quorum peer2015-03-12 16:09:35,472 [myid:0]-INFO [main:[email protected]]-binding to port 0.0.0.0/0.0.0.0:21822015-03-12 16:09:35,500 [myid:0]-INFO [main:[email protected]]-Ticktime setTo 20002015-03-12 16:09:35,501 [myid:0]-INFO [main:[email protected]]-minsessiontimeout set to-12015-03-12 16:0 9:35,501 [myid:0]-INFO [main:[email protected]]-maxsessiontimeout set to-12015-03-12 16:09:35,502 [myid:0]-in FO [main:[email protected]]-initlimit set to 102015-03-12 16:09:35,519 [myid:0]-ERROR [main:[email protecte D]]-Setting learnertype to PARTICIPANT but 0 not in quorumpeers.2015-03-12 16:09:35,530 [myid:0]-INFO [MAIN:[EMAIL&NB Sp;protected]]-Currentepoch not found! Creating with a reasonable default of 0. This should if happen is upgrading your installation2015-03-12 16:09:35,591 [myid:0]-INFO [main:[email&nbsp ;p rotected]]-Acceptedepoch not found! Creating with a reasonable default of 0. This should if happen is upgrading your installation2015-03-12 16:09:35,598 [myid:0]-ERROR [main:[email&nbsp ;p rotected]]-Unexpected exception, exiting Abnormallyjava.lang.RuntimeException:My ID 0 not in the PeeR list at org.apache.zookeeper.server.quorum.QuorumPeer.startLeaderElection (quorumpeer.java:479) at Org.apache.zoo Keeper.server.quorum.QuorumPeer.start (quorumpeer.java:411) at Org.apache.zookeeper.server.quorum.QuorumPeerMain.runFromConfig (quorumpeermain.java:151) at Org.apache.zookeeper.server.quorum.QuorumPeerMain.initializeAndRun (quorumpeermain.java:111) at Org.apache.zookeeper.server.quorum.QuorumPeerMain.main (quorumpeermain.java:78)

4. Modify the Zoo.cfg file.

The directory where zookeeper/conf/zoo.cfg modifies datadir is the data directory that we created in step 2nd.

Add the Zookeeper cluster node address at the end of the file.

server.1=localhost:2888:3888server.2=localhost:2889:3889server.3=localhost:2890:3890

5. Other node configuration.

Well, it's already configured with 1 zookeeper services, and then copy the two copies of the Zookeeper directory just right. Modify the Datadir,clientport of id,zoo.cfg in the Data/myid file.


6. Then start zookeeper separately.


Zookeeper pseudo-cluster environment set up, otherwise let it run quietly there, continue to tinker with it ...


Zookeeper pseudo-cluster environment construction

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.