Zookeeper cluster installation (CentOS 7 environment)

Source: Internet
Author: User

Introduction of environment operating system and software version

1. Environment operating system for CentOS Linux release 7.2.1511 (Core)

Available Cat/etc/redhat-release queries

2. Software version

The zookeeper version is: 3.4.9

Note: Use Java–version to check the environment for any installed JDK, such as displaying Java version information, which indicates that it is installed and can perform the following steps. If no installation, install the JDK yourself and configure environment variables, and then do the following!

Second, detailed installation steps

1. Download the compressed package to the/data/soft directory on zookeeper website, download version zookeeper-3.4.9.tar.gz

2. Create a folder called Zkcluster under/data/app

3. From the current directory/data/soft extract zookeeper to/data/app/zkcluster directory

1 [[email protected] soft]# TAR-ZXVF zookeeper-3.4. 9. Tar.gz-c/data/app/zkcluster

4. Change the extracted file name to 3001

1 [[email protected] zkcluster]# mv zookeeper-3.4. 9 3001

4. Go to the/data/app/zkcluster/3001/conf directory and copy the Zoo_sample.cfg file and name it zoo.cfg

1 [[email protected] conf]# CP zoo_sample.cfg ZOO.CFG

6. After the copy is complete, edit the Zoo.cfg file and open it with VI

1 [[email protected] conf]# VI zoo.cfg

Can comment out the original data path (can also be retained), add a new data, logs path, modify the port, increase the cluster instance

1#dataDir =/tmp/Zookeeper2datadir=/data/app/zkcluster/3001/Data3datalogdir=/data/app/zkcluster/3001/logs4clientport=30015Server.1=192.168.1.18:2888:38886Server.2=192.168.1.18:2889:38897Server.3=192.168.1.18:2890:3890

7. Use: Wq command to save and close the Zoo.cfg file after the add is complete

8. The other two servers on the ZK ibid, first modify the folder name (in this article the other two folder names are 3002 and 3003)

Then go to the Conf directory, copy the Zoo_sample.cfg file and name it zoo.cfg, and then modify it:

1#dataDir =/tmp/Zookeeper2datadir=/data/app/zkcluster/3002/Data3datalogdir=/data/app/zkcluster/3002/logs4clientport=30025Server.1=192.168.1.18:2888:38886Server.2=192.168.1.18:2889:38897Server.3=192.168.1.18:2890:3890
1#dataDir =/tmp/Zookeeper2datadir=/data/app/zkcluster/3003/Data3datalogdir=/data/app/zkcluster/3003/logs4clientport=30035Server.1=192.168.1.18:2888:38886Server.2=192.168.1.18:2889:38897Server.3=192.168.1.18:2890:3890

9. Enter the/data/app/zkcluster/3001/data directory, add a myID file, and fill in the contents 1. 3002 in Folder myID is 2,3003 in myID for 3

1 [[email protected] data]# VI myID

Third, start & verify:

1. Start ZK under/data/app/zkcluster/3001/bin. 3002 and 3003 are the same.

1 [[email protected] bin]#./zkserver.sh start

2. After three servers are started, view the status separately:

1 [[email protected] bin]#./zkserver.sh status2default3 Using config:/ data/app/zkcluster/3001/bin/. /conf/zoo.cfg4mode:follower5[[email protected] bin]# pwd6 /data/app/zkcluster/3001/bin

1 [[email protected] bin]#./zkserver.sh status2default3 Using config:/ data/app/zkcluster/3002/bin/. /conf/zoo.cfg4 Mode:leader

1 [[email protected] bin]#./zkserver.sh status2default3 Using Config:/data/app/zkcluster/3003/bin/. /conf/zoo.cfg4 mode:follower

Visible, 3002 is leader,3001 and 3003 is follower.

3. Through the client connection zookeeper the cluster, we can arbitrarily zookeeper is to make the connection

First Connect 3002

1 192.168. 1.18:3002

Note: You can use Help to view related commands

1 192.168. 1.18:3003] Help

4. View the node now, then create the node test and store the data

1 192.168. 1.18:30020] ls/2[zookeeper]3192.168. 1.18:30021] Create/test data4 created/test

5. Connect to other zkserver using the Connect command

1 192.168. 1.18:30022192.168. 1.18:3001

Under 3001, use the LS path and get path command to detect if the node and data are synchronized

1[ZK:192.168.1.18:3001(CONNECTED)3] LS/2 [Zookeeper, Test]3[ZK:192.168.1.18:3001(CONNECTED)4]Get/Test4 Data5Czxid =0x2000000086CTime = Mon Jan -  -: -: GenevaCst .7Mzxid =0x2000000088Mtime = Mon Jan -  -: -: GenevaCst .9Pzxid =0x200000008TenCversion =0 OneDataversion =0 AAclversion =0 -Ephemeralowner =0x0 -Datalength =4 theNumchildren =0

Connect to the 3002 zkserver using the Connect command

Use the LS path and get path command under 3002 to detect if the node and data are synchronized

1[ZK:192.168.1.18:3001(CONNECTED)5] Connect192.168.1.18:30022[ZK:192.168.1.18:3002(CONNECTED)6] LS/3 [Zookeeper, Test]4[ZK:192.168.1.18:3002(CONNECTED)7]Get/Test5 Data6Czxid =0x2000000087CTime = Mon Jan -  -: -: GenevaCst .8Mzxid =0x2000000089Mtime = Mon Jan -  -: -: GenevaCst .TenPzxid =0x200000008 OneCversion =0 ADataversion =0 -Aclversion =0 -Ephemeralowner =0x0 theDatalength =4 -Numchildren =0

Connect to the 3003 zkserver using the Connect command

Use the LS path and get path command under 3003 to detect if the node and data are synchronized

1[ZK:192.168.1.18:3002(CONNECTED)8] Connect192.168.1.18:30032[ZK:192.168.1.18:3003(CONNECTED)9] LS/3 [Zookeeper, Test]4[ZK:192.168.1.18:3003(CONNECTED)Ten]Get/Test5 Data6Czxid =0x2000000087CTime = Mon Jan -  -: -: GenevaCst .8Mzxid =0x2000000089Mtime = Mon Jan -  -: -: GenevaCst .TenPzxid =0x200000008 OneCversion =0 ADataversion =0 -Aclversion =0 -Ephemeralowner =0x0 theDatalength =4 -Numchildren =0

Verify through!

Zookeeper cluster installation (CentOS 7 environment)

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.