"Zookeeper" Zookeeper cluster construction

Source: Internet
Author: User

Cluster build Environment:

Release version: CentOS-6.6 64bit

Kernel: 2.6.32-504.el6.x86_64

Cpu:intel-i7 3.6G

Memory: 2G

Cluster Setup steps: 1. Ensure that the machine has a JDK installed

[Email protected] ~]# java-version

OPENJDK Version "1.8.0_51"

OpenJDK Runtime Environment (build 1.8.0_51-B16)

OpenJDK 64-bit Server VM (build 25.51-b03, Mixed mode)

If you cannot find the JDK, you can install it through yum, and if the release is not CentOS, search for the installation method for the corresponding release.

[[email protected] local]# Yum-y install Java

2. Download zookeeper, choose a suitable version

On the official website http://zookeeper.apache.org/releases.html find a suitable image to download. Download it here using the image of North Manager.

[email protected] local]# \

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

After the download is complete, unzip it separately to

[Email protected] local]# TAR-ZXVF zookeeper-3.4.6.tar.gz zookeeper-server1

[Email protected] local]# TAR-ZXVF zookeeper-3.4.6.tar.gz zookeeper-server2

[Email protected] local]# TAR-ZXVF zookeeper-3.4.6.tar.gz Zookeeper-server3

3. Copy the configuration file

[Email protected] local]# CD/USR/LOCAL/ZOOKEEPER-SERVER1/;CP conf/zoo_sample.cfg conf/zoo_test.cfg

[Email protected] local]# CD/USR/LOCAL/ZOOKEEPER-SERVER2/;CP conf/zoo_sample.cfg conf/zoo_test.cfg

[Email protected] local]# CD/USR/LOCAL/ZOOKEEPER-SERVER3/;CP conf/zoo_sample.cfg conf/zoo_test.cfg

4. Modify the configuration file

Zookeeper-server1

# The number of milliseconds of each tick

ticktime=2000

# The number of ticks that initial

# Synchronization phase can take

initlimit=10

# The number of ticks that can pass between

# Sending a request and getting an acknowledgement

Synclimit=5

Datadir=/tmp/zookeeper-server1/data

Datalogdir=/tmp/zookeeper-server1/logs

# The port at which the clients would connect

clientport=2181

server.1=127.0.0.1:8880:7770

server.2=127.0.0.1:8881:7770

server.3=127.0.0.1:8882:7770

Zookeeper-server2

# The number of milliseconds of each tick

ticktime=2000

# The number of ticks that initial

# Synchronization phase can take

initlimit=10

# The number of ticks that can pass between

# Sending a request and getting an acknowledgement

Synclimit=5

Datadir=/tmp/zookeeper-server2/data

Datalogdir=/tmp/zookeeper-server2/logs

# The port at which the clients would connect

clientport=3181

server.1=127.0.0.1:8880:7770

server.2=127.0.0.1:8881:7770

server.3=127.0.0.1:8882:7770

Zookeeper-server3

# The number of milliseconds of each tick

ticktime=2000

# The number of ticks that initial

# Synchronization phase can take

initlimit=10

# The number of ticks that can pass between

# Sending a request and getting an acknowledgement

Synclimit=5

Datadir=/tmp/zookeeper-server3/data

Datalogdir=/tmp/zookeeper-server3/logs

# The port at which the clients would connect

clientport=4181

server.1=127.0.0.1:8880:7770

server.2=127.0.0.1:8881:7770

server.3=127.0.0.1:8882:7770

5. Set up zookeeper run directory, data directory and log directory

[Email protected] local]# mkdir-p zookeeper-server1/logs zookeeper-server1/data

[Email protected] local]# mkdir-p zookeeper-server2/logs zookeeper-server2/data

[Email protected] local]# mkdir-p zookeeper-server3/logs zookeeper-server3/data

To view the current run directory situation:

[Email protected] tmp]# tree

├──zookeeper-server1

│├──data

│└──logs

├──zookeeper-server2

│├──data

│└──logs

└──zookeeper-server3

├──data

└──logs

6. Create the file myID file in the data directory and write each file to the server ID of the current machine

[[email protected] tmp]# echo "1" > Zookeeper-server1/data/myid

[[email protected] tmp]# echo "2" > Zookeeper-server2/data/myid

[[email protected] tmp]# echo "3" > Zookeeper-server3/data/myid

7. Start zookeeper in each directory

[[email protected] local]# cd/usr/local/zookeeper-server1/;bin/zkserver.sh start

[[email protected] local]# cd/usr/local/zookeeper-server2/;bin/zkserver.sh start

[[email protected] local]# cd/usr/local/zookeeper-server3/;bin/zkserver.sh start

View startup status

[[email protected] bin]#./zkserver.sh start
ZooKeeper JMX enabled by default
Using config:/opt/zookeeper-3/bin/. /conf/zoo.cfg
Starting zookeeper ... STARTED

Note that here if prompted

Error contacting service. It is probably not running.

Indicates that the process failed to start or the cluster was not successful, you need to look at the Zookeeper.out log in the corresponding directory to find the appropriate reason and resolve it.

8. Test Connection Zookeeper Cluster

[Email protected] local]# CD Zookeeper-server1;bin/zkcli.sh-server localhost:2181

You can see that the connection has been successful, and you can see the node situation, indicating that the zookeeper cluster has started to work.

Reference: Zookeeper Cluster construction Zookeeper configuration detailed

"Zookeeper" Zookeeper cluster 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.