Deployment of ZooKeeper3.4.6 Cluster Environment and standalone deployment in CentOS 6.5

Source: Internet
Author: User

Deployment of ZooKeeper3.4.6 Cluster Environment and standalone deployment in CentOS 6.5

[System] CentOS 6.5

Cluster deployment

[Software] prepares the jdk environment. This time, our environment is open_jdk1.8.0_101.
Zookeeper-3.4.6.tar.gz
[STEP]
1. Prerequisites
If there is an internal dns or a domain name on the internet, use the domain name directly.
If you do not need to modify the/etc/hosts file, or directly use the IP address

Cluster Planning

Host type IP address Domain Name
Zookeeper1 192.168.1.1zookeeper1.chinasoft.com
Zookeeper2 192.168.1.2zookeeper2.chinasoft.com
Zookeeper3 192.168.1.3zookeeper3.chinasoft.com

Note: Because zookeeper has a relationship between the master node and the slave node, it is best to have an odd number of deployed clusters. Otherwise, split-brain may cause service exceptions.

2. Installation
: Http://archive.apache.org/dist/zookeeper/zookeeper-3.4.6/
Extract

Tar-zxf zookeeper-3.4.6.tar.gz
Cd zookeeper-3.4.6

Copy the configuration file and distribute the modification to other nodes.
Cd/data/zookeeper-3.4.6/
Cp zoo_sample.cfg zoo. cfg

Cat zoo. cfg

TickTime = 2000
InitLimit = 10
SyncLimit = 5
DataDir =/data/zookeeper-3.4.6/data
DataLogDir =/data/zookeeper-3.4.6/logs
ClientPort = 2181
Server 1 = u04rtv01. yaya. corp: 2888: 3888
Server.2 = u04rtv02. yaya. corp: 2888: 3888
Server.3 = u04rtv03. yaya. Corp.: 2888: 3888

3. Create data and Log folders
Mkdir/data/zookeeper-3.4.6/data
Mkdir/data/zookeeper-3.4.6/logs

       
4. Create a myid file under the directory specified by dataDir in zoo. cfg.
For example, create a new myid under $ ZK_INSTALL/data. Enter 1 in the myid file. Server.1.
If it is snapshot/d_2, the content in the myid file is 2, and so on.

Start: run the following command on each host in the Cluster:
Bin/zkServer. sh start

You can view the status of one master node and the other two slave nodes:
Bin/zkServer. sh status

Master node:
./ZkServer. sh status
JMX enabled by default
Using config:/data/yunva/zookeeper-3.4.6/bin/../conf/zoo. cfg
Mode: leader
Slave node:
./ZkServer. sh status
JMX enabled by default
Using config:/data/yunva/zookeeper-3.4.6/bin/../conf/zoo. cfg
Mode: follower

Stop:
Bin/zkServer. sh stop

Connection:
Bin/zkCli. sh-server zookeeper1: 2181
Bin/zkCli. sh-server zookeeper2: 2181
Bin/zkCli. sh-server zookeeper3: 2181

Error:
The reason is that the myid file is not created in the dataDir directory and assigned values (for example, 1, 2, and 3 represent server1, server2, and server3 in the cluster respectively)

17:55:16, 145 [myid:]-INFO [main: QuorumPeerConfig @ 103]-Reading configuration from:/data/yunva/zookeeper-3.4.6/bin/../conf/zoo. cfg
17:55:16, 150 [myid:]-INFO [main: QuorumPeerConfig @ 340]-Defaulting to majority quorums
17:55:16, 150 [myid:]-ERROR [main: QuorumPeerMain @ 85]-Invalid config, exiting abnormally
Org. apache. zookeeper. server. quorum. QuorumPeerConfig $ ConfigException: Error processing/data/yunva/zookeeper-3.4.6/bin/../conf/zoo. cfg
At org. apache. zookeeper. server. quorum. QuorumPeerConfig. parse (QuorumPeerConfig. java: 123)
At org. apache. zookeeper. server. quorum. QuorumPeerMain. initializeAndRun (QuorumPeerMain. java: 101)
At org. apache. zookeeper. server. quorum. QuorumPeerMain. main (QuorumPeerMain. java: 78)
Caused by: java. lang. IllegalArgumentException:/data/yunva/zookeeper-3.4.6/data/myid file is missing
At org. apache. zookeeper. server. quorum. QuorumPeerConfig. parseProperties (QuorumPeerConfig. java: 350)
At org. apache. zookeeper. server. quorum. QuorumPeerConfig. parse (QuorumPeerConfig. java: 119)
... 2 more

Invalid config, exiting abnormally

Standalone deployment-applicable to development and testing
Tar-zxvf zookeeper-3.4.6.tar.gz
Cd zookeeper-3.4.6/conf
Cp zoo_sample.cfg zoo. cfg
Create log directory
Mkdir/data/yunva/zookeeper-3.4.6/data
Mkdir/data/yunva/zookeeper-3.4.6/logs

Configuration: conf/zoo. cfg

TickTime = 2000
InitLimit = 10
SyncLimit = 5
DataDir =/data/yunva/zookeeper-3.4.6/logs
DataLogDir =/data/yunva/zookeeper-3.4.6/logs
ClientPort = 2181
# Automatically clear log files
Autopurge. snapRetainCount = 20
Autopurge. purgeInterval = 48

Start:

Bin/zkServer. sh start

Connect to Zookeeper:

Bin/zkCli. sh-server 127.0.0.1: 2181 for Java Development

View status:
Bin/zkServer. sh status
JMX enabled by default
Using config:/data/yunva/zookeeper-3.4.6/bin/../conf/zoo. cfg
Mode: standalone

Install Zookeeper-3.4.9 service https://www.bkjia.com/Linux/2016-09/135052.htm on CentOS7
ZooKeeper Overview 3.4.6 https://www.bkjia.com/Linux/2016-12/138025.htm
Build https://www.bkjia.com/Linux/2016-12/137958.htm in ZooKeeper 3.4.8 cluster environment under CentOS
Install https://www.bkjia.com/Linux/2017-01/139733.htm in Zookeeper cluster under CentOS 7
Distributed service Dubbo + Zookeeper Security Authentication https://www.bkjia.com/Linux/2017-12/149605.htm
Installing Zookeeper cluster https://www.bkjia.com/Linux/2017-01/139545.htm in Linux
Installation https://www.bkjia.com/Linux/2017-03/141400.htm of Zookeeper cluster in Linux

This article permanently updates link: https://www.bkjia.com/Linux/2018-03/151439.htm

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.