CentOS under Zookeeper stand-alone mode, cluster mode installation

Source: Internet
Author: User

The environment of this article is as follows:
Operating system: CentOS 6 32-bit
Zookeeper version: 3.4.8

0. Environmental requirements

Zookeeper requires JDK1.6 above version of the Java environment
can refer to:
CentOS 6 Install JDK8 using rpm

1. Download the package

Download the package to the Zookeeper website http://zookeeper.apache.org/ , for example:

"http://apache.opencas.org/zookeeper/stable/zookeeper-3.4.8.tar.gz"tar -xzvf zookeeper-3.4.8.tar.gzmv zookeeper-3.4.8 /opt
2. Stand-alone mode 2.1 modify the configuration file
cd /opt/zookeeper-3.4.8/conf/cp zoo_sample.cfg zoo.cfgvi zoo.cfg

Zookeeper provides a copy of the default configuration file, which we need to change the path of data storage after the ZOO.CFG is opened:

dataDir=/opt/zookeeper-3.4.8/data
2.2 Running Zookeeper
cd /opt/zookeeper-3.4.8/bin/./zkServer.sh start

If no error is running, the zookeeper boot is successful.
For ease of operation, we can add zookeeper/bin to the path

vi /etc/profile

Add at the end:

ZOOKEEPER_HOME=/opt/zookeeper-3.4.8PATH=$PATH:$ZOOKEEPER_HOME/bin

To update the configuration:

source /etc/profile
3. Cluster mode

Stand-alone mode is handy for developing and testing scenarios, but in a production environment, you should run a cluster mode. Cluster mode should have at least 3 nodes, and it is strongly recommended that you have an odd number of nodes, each node should have the same configuration file.

3.1 Modifying a configuration file
cd /opt/zookeeper-3.4.8/conf/vi zoo.cfg

When opened, modify to:

tickTime=2000dataDir=/opt/zookeeper-3.4.8/dataclientPort=2181initLimit=5syncLimit=2server.1=master:2888:3888server.2=slave1:2888:3888server.3=slave2:2888:3888

The number followed by the server is the label of the node, and we need to write the number to the myid file named. The file should be stored in the directory pointed to by the DataDir configured earlier.
For example, the SLAVE1 node above data/myid should be written in the corresponding file 2 .

3.2 Copy Folder
scp -r /opt/zookeeper-3.4.8 root@slave1:/opt/scp -r /opt/zookeeper-3.4.8 root@slave2:/opt/

When the copy is complete, remember to modify the corresponding server myid file.

3.3 Starting the Service

The zookeeper service needs to be started on each node, and each node can be started with zkServer.sh status a view of the current node's startup state and whether it is a leader node or a follower node.

4. Anomaly Analysis

The Run log file defaults to the program directory zookeeper.out .

4.1 Unable to connect
 .-Geneva- -  to: -: +,531[myID:1]-WARN [workersender[myid=1]:quorumcnxmanager@400]-Cannot open channel to2At election address slave1/5.2. 8. 5:3888java.net.ConnectException:Connection refused at Java. NET. Plainsocketimpl. Socketconnect(Native Method) at Java. NET. Abstractplainsocketimpl. Doconnect(Abstractplainsocketimpl. Java: -) at Java. NET. Abstractplainsocketimpl. Connecttoaddress(Abstractplainsocketimpl. Java:206) at Java. NET. Abstractplainsocketimpl. Connect(Abstractplainsocketimpl. Java:188) at Java. NET. Sockssocketimpl. Connect(Sockssocketimpl. Java:392) at Java. NET. Socket. Connect(Socket. Java:589) at Org. Apache. Zookeeper. Server. Quorum. Quorumcnxmanager. ConnectOne(Quorumcnxmanager. Java:381) at Org. Apache. Zookeeper. Server. Quorum. Quorumcnxmanager. Tosend(Quorumcnxmanager. Java:354) at Org. Apache. Zookeeper. Server. Quorum. Fastleaderelection$Messenger $workersender. Process(fastleaderelection. Java:452) at Org. Apache. Zookeeper. Server. Quorum. Fastleaderelection$Messenger $workersender. Run(fastleaderelection. Java:433) at Java. Lang. Thread. Run(Thread. Java:745)

This exception can occur when the firewall of the Zookeeper node is turned on and the port (2888,3888) is not open, or the node may not be started or hung up.

CentOS under Zookeeper stand-alone mode, cluster mode installation

Related Article

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.