Install the zookeeper and configure the cluster

Source: Internet
Author: User
Tags mkdir zookeeper
Install the zookeeper and configure the cluster

1, prepare three machines to do the cluster
Server 1 10.211.55.7 2181/2881/3881
Server 2 10.211.55.8 2181/2881/3881
Server 3 10.211.55.9 2181/2881/3881
2, Configuration
2.1 Configuring the Java Environment
Upload the jdk-8u141-linux-x64.tar.gz to the three server installation configurations.
Extract to/data/program/software/
and rename the folder to Java8
Configure JDK global variables.

Vi/etc/profile
export java_home=/data/program/software/java8
export jre_home=/data/program/software/ Java8/jre
export classpath=.: $CLASSPATH: $JAVA _home/lib: $JRE _home/lib 
export path= $PATH: $JAVA _home/bin:$ Jre_home/bin

2.2 Modify the operating system/etc/hosts file, add IP and hostname mapping:

   # Zookeeper Cluster servers
10.211.55.7 bigdata1 10.211.55.8 bigdata2 10.211.55.9 bigdata3

2.3 Download zookeeper-3.4.9.tar.gz to/data/program/software/directory

wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz

2.4 Decompression Zookeeper installation package, and to the node heavy people name

TAR-ZXVF zookeeper-3.4.9.tar.gz
server 1:
mv zookeeper-3.4.9 zookeeper
server 2:
MV zookeeper-3.4.9 Zookeeper
server 3:
mv zookeeper-3.4.9 Zookeeper

2.5 Creating data and log directories under each node of the zookeeper

CD zookeeper
mkdir data
mkdir logs

2.6 Renaming a configuration file
A copy of the Zoo_sample.cfg file in the zookeeper/conf directory is named Zoo.cfg:

CP zoo_sample.cfg zoo.cfg
Modify zoo.cfg configuration file
clientport=2181
datadir=/data/program/software/zookeeper/ Data
datalogdir=/data/program/software/zookeeper/logs

server.1=bigdata1:2881:3881
server.2= bigdata2:2881:3881
server.3=bigdata3:2881:3881

Parameter description:
ticktime=2000
Ticktime this time is the time interval between the zookeeper server or between the client and the server to maintain heartbeat, that is, each ticktime time will send a heartbeat.
initlimit=10
Initlimit This configuration entry is used to configure the Zookeeper accept client (where the client is not the client that connects to the zookeeper server, but zookeeper the leader that is connected to follower in the server cluster) Server) The maximum number of heartbeat intervals that can be tolerated when a connection is initialized. This client connection fails when the Zookeeper server has not received the return information of the client after the 10 heartbeat time (i.e. ticktime) length has expired. The total length of time is 10*2000=20 seconds.
Synclimit=5
Synclimit This configuration item identifies leader and follower send messages between the length of the request and reply time, the longest can not exceed the length of the ticktime, the total length of time is 5*2000=10 seconds.
Datadir=/data/program/software/zookeeper/data
DataDir as the name implies is zookeeper save the data directory, by default zookeeper will write the data log file also saved in this directory.
clientport=2181
ClientPort This port is the port where the client (application) connects to the zookeeper server, and zookeeper listens to the port to accept the client's access request.
Server. A=b:c:d
server.1=bigdata1:2881:3881
server.2=bigdata2:2881:3881
server.3=bigdata3:2881:3881
A is a number that indicates what the server is;
b is the IP address of the server (or the host name mapped with the IP address);
c The first port is used for information exchange of cluster members, which indicates that the server exchanges information with the leader server in the cluster;
D is the port that is used specifically for election leader when the leader is hung off.
Note: If you are configuring a pseudo cluster, different zookeeper instance communication port numbers cannot be the same, so assign them a different port number.
2.8 Creating myID Files
Create a myID file under Datadir= datadir=/data/program/software/zookeeper/data
Edit the myID file and enter the corresponding number on the corresponding IP machine. As in 1, the content of the myID file is 1, 2 is 2, 3 is 3:

vi/myid## value is 1
vi/myid## value is 2
vi/myid## value is 3

2.9 Start Test Zookeeper
(1) Enter the/bin directory to execute:
/zkserver.sh start

(2) Enter the JPS command to view the process:

Where Quorumpeermain is the zookeeper process, indicating that the boot is normal
(3) View status:
#/zkserver.sh Status

(4) View Zookeeper service output information:
Because the service information output file is in/bin/zookeeper.out

$ tail-500 F zookeeper.out

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.