Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of ZooKeeper3.4.6 Cluster Environment deployment and stand-alone deployment under CentOS 6.5

2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you the CentOS 6.5 ZooKeeper3.4.6 cluster environment deployment and stand-alone deployment example analysis, I believe that most people do not know much, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!

[system] CentOS 6.5

Cluster deployment

[software] prepare the jdk environment, this time our environment is open_jdk1.8.0_101

Zookeeper-3.4.6.tar.gz

[steps]

1. Preparation condition

If there is an internal dns or a domain name on the public network, use the domain name directly

If you do not need to modify the / etc/hosts file, or use IP directly

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 the relationship between master node and slave node, it is better to deploy an odd number of clusters, otherwise brain fissure may lead to abnormal service.

two。 Installation

Download address: http://archive.apache.org/dist/zookeeper/zookeeper-3.4.6/

Decompression

Tar-zxf zookeeper-3.4.6.tar.gz

Cd zookeeper-3.4.6

Copy the configuration file and distribute it to other nodes after modification

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 new myid file in the directory specified by dataDir in zoo.cfg.

For example, create a new myid under $ZK_INSTALL/data. Enter 1 in the myid file. Expressed as server.1.

If snapshot/d_2, the content in the myid file is 2, and so on.

Startup: execute the following command on each host in the cluster

Bin/zkServer.sh start

If you check the status, you can see that one of them is a master node and the other two are slave nodes:

Bin/zkServer.sh status

Primary node:

. / zkServer.sh status

JMX enabled by default

Using config: / data/yunva/zookeeper-3.4.6/bin/../conf/zoo.cfg

Mode: leader

Slave nodes:

. / 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 report:

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

2016-08-22 17 main:QuorumPeerConfig@103 55 main:QuorumPeerConfig@103 16145 [myid:]-INFO [main:QuorumPeerConfig@103]-Reading configuration from: / data/yunva/zookeeper-3.4.6/bin/../conf/zoo.cfg

2016-08-22 17 main:QuorumPeerConfig@340 55 main:QuorumPeerConfig@340 16 150 [myid:]-INFO [main:QuorumPeerConfig@340]-Defaulting to majority quorums

2016-08-22 17 main:QuorumPeerMain@85 55 main:QuorumPeerMain@85 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

Stand-alone deployment-suitable for development testing

Tar-zxvf zookeeper-3.4.6.tar.gz

Cd zookeeper-3.4.6/conf

Cp zoo_sample.cfg zoo.cfg

Create a 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 Java 2181 is suitable 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

These are all the contents of the article "sample Analysis of ZooKeeper3.4.6 Cluster Environment deployment and stand-alone deployment under CentOS 6.5.Thank you for reading!" I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report