Zookeeper pseudo-distributed cluster environment construction

Source: Internet
Author: User
Tags socket time interval zookeeper port number
step1, download

Download Address: http://zookeeper.apache.org/releases.html

Put the downloaded compressed package in the user's home directory (other directories can also)

Step2, decompression

$tar –ZXVF zookeeper-3.4.6.tar.gz

Renaming

$MV zookeeper-3.4.6 Zookeeper

step3, Configuration

Enter the zookeeper/conf/directory, copy 4 copies of the ZOO_SAMPLE.CFG configuration file under directory, then zoo.cfg zoo1.cfg zoo2.cfg zoo3.cf

Use Vim to edit the three profiles of Zoo1.cfg zoo2.cfg zoo3.cfg

$ vim Zoo1.cfg
Modify the content as follows

Configuration Instructions Ticktime: This time is the time interval between the Zookeeper server or between the client and the server to maintain the heartbeat, that is, each ticktime time sends a heartbeat. Initlimit: This configuration item is used to configure the Zookeeper accept client (the client here is not the client that connects the Zookeeper server, but the Leader that is connected to Follower in the Zookeeper server cluster) Server) The maximum number of heartbeat intervals that can be tolerated when a connection is initialized. The client connection failed when the Zookeeper server has not received the return information of the client after 10 heartbeats (that is, ticktime) length. The total length of time is 10*2000=20 seconds Synclimit: This configuration item identifies the message sent between Leader and Follower, the length of the request and response time, the maximum length of time that can not exceed how many ticktime, the total length of time is 5*2000=10 seconds D Atadir: As the name implies is Zookeeper to save the data directory, by default, Zookeeper will write the data log file is also stored in this directory. ClientPort: This port is the port that the client connects to the Zookeeper server, Zookeeper listens to the port and accepts the client's access request. Server. A=b:c:d: Where A is a number, indicating this is the first server, B is the IP address of this server, C is the server and the Leader server in the cluster to exchange information on the port; D means that in case the Leader server in the cluster hangs, a port is needed to re-elect , select a new Leader, which is the port that the server communicates with each other when the election is performed. If it is a pseudo-cluster configuration, because B is the same, so different Zookeeper instance communication port numbers can not be the same, so they should be assigned a different port number.
Use Vim to modify Zoo2.cfg's datadir=/home/jianjian/zookeeper/server2/data,clientport=2182, modify Zoo3.cfg's datadir=/home/ jianjian/zookeeper/server3/data,clientport=2183. DataDir directory does not exist, it needs to be created manually, and a file named myID is created under each data file with the file content corresponding to the server number

[Jianjian@localhost zookeeper]$ echo 1 > Server1/data/myid
[Jianjian@localhost zookeeper]$ echo 2 > server2/ Data/myid
[Jianjian@localhost zookeeper]$ echo 3 > Server3/data/myid

STEP4, start

Go to the Directory/home/hadoop/zookeeper/bin directory and execute the command:

$zkServer. Sh Start zoo1.cfg
Start the zoo1.cfg configured service, and in turn start the services configured by ZOO2.CFG and Zoo3.cfg

step5, viewing status

In turn, see the three services launched, the second service is leader, the first and three for follower (test many times is the second is leader, only once is the third is leader, drunk ~)

attached:

When the zkserver.sh start and zkserver.sh status commands do not receive the configuration file parameter, the default is to use CONF/ZOO.CFG as the parameter

This is only the case of starting a service, visible mode for standalone, only one service cluster ...

step6, connectivity test

Test Server2 (leader, other services similarly) connectivity

[Root@localhost bin]#./zkcli.sh-server 127.0.0.1:2182 connecting to 127.0.0.1:2182 2015-08-12 20:55:23,658 [myID:]-INF
o  [main:environment@100]-Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT 2015-08-12 20:55:23,661 [myID:]-info  [main:environment@100]-Client environment:host.name= Localhost.localdomain 2015-08-12 20:55:23,661 [myID:]-info  [main:environment@100]-Client Environment: java.version=1.7.0_79 2015-08-12 20:55:23,662 [myID:]-info  [main:environment@100]-Client Environment: Java.vendor=oracle Corporation 2015-08-12 20:55:23,662 [myID:]-info  [main:environment@100]-Client Environment: Java.home=/usr/java/jdk1.7.0_79/jre 2015-08-12 20:55:23,662 [myID:]-info  [main:environment@100]-Client environment:java.class.path=/home/jianjian/zookeeper/bin/. /build/classes:/home/jianjian/zookeeper/bin/. /build/lib/*.jar:/home/jianjian/zookeeper/bin/. /lib/slf4j-log4j12-1.6.1.jar:/home/jianjian/zookeeper/bin/. /lib/slf4j-api-1.6.1.jar:/home/jianjian/zookeeper/bin/. /lib/netty-3.7.0.final.jar:/home/jianjian/zookeeper/bin/. /lib/log4j-1.2.16.jar:/home/jianjian/zookeeper/bin/. /lib/jline-0.9.94.jar:/home/jianjian/zookeeper/bin/. /zookeeper-3.4.6.jar:/home/jianjian/zookeeper/bin/. /src/java/lib/*.jar:/home/jianjian/zookeeper/bin/. /conf:2015-08-12 20:55:23,663 [myID:]-info  [main:environment@100]-Client environment:java.library.path=/usr/ Java/packages/lib/i386:/lib:/usr/lib 2015-08-12 20:55:23,663 [myID:]-info  [main:environment@100]-Client Environment:java.io.tmpdir=/tmp 2015-08-12 20:55:23,663 [myID:]-info  [main:environment@100]-Client environment:java.compiler=<na> 2015-08-12 20:55:23,663 [myID:]-info  [main:environment@100]-Client Environment:os.name=linux 2015-08-12 20:55:23,663 [myID:]-info  [main:environment@100]-Client environment:o s.arch=i386 2015-08-12 20:55:23,663 [myID:]-info  [main:environment@100]-Client Environment:Os.version=2.6.18-194.el5 2015-08-12 20:55:23,663 [myID:]-info  [main:environment@100]-Client Environment:
User.name=root 2015-08-12 20:55:23,663 [myID:]-info  [main:environment@100]-Client environment:user.home=/root 2015-08-12 20:55:23,664 [myID:]-info  [main:environment@100]-Client environment:user.dir=/home/jianjian/ Zookeeper/bin 2015-08-12 20:55:23,665 [myID:]-info  [main:zookeeper@438]-Initiating client connection, CONNECTST ring=127.0.0.1:2182 sessiontimeout=30000 watcher=org.apache.zookeeper.zookeepermain$mywatcher@154ea79 2015-08-12 20:55:23,699 [myID:]-info  [Main-sendthread (127.0.0.1:2182): clientcnxn$sendthread@975]-Opening socket Connection to server 127.0.0.1/127.0.0.1:2182. Won't attempt to authenticate using SASL (unknown error) 2015-08-12 20:55:23,703 [myID:]-info  [Main-sendthread ( 127.0.0.1:2182): clientcnxn$sendthread@852]-Socket connection established to 127.0.0.1/127.0.0.1:2182, initiating Session 2015-08-12 20:55:23,718 [myID:]-info  [Main-sendthread (127.0.0.1:2182): clientcnxn$sendthread@1235]-Session Establishment Complete on server 127.0.0.1/127.0.0.1:2182, SessionID = 0x24f21e1b05b0000, negotiated timeout = 30000 Welcome to Zookeepe

R!  
 Watcher:: Watchedevent state:syncconnected type:none path:null jline support is enabled [zk:127.0.0.1:2182 (CONNECTED) 0]
The above information indicates successful connectivity.

attached:

See some people configure a pseudo-cluster is to compress the compressed package after copying a few copies, each copy represents a zookeeper service, the individual feel unnecessary, only copy the configuration file and modify the line, a configuration file represents a zookeeper service.

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.