ZooKeeper cluster configuration, zookeeper Cluster

Source: Internet
Author: User

ZooKeeper cluster configuration, zookeeper Cluster

Reference:

This article describes how to install and configure a zookeeper cluster.

I. Environment 1. Operating System

CentOS-7-x86_64-Everything-1511

2. Version

JDK 8u131: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Zookeeper 3.4.10 (stable version as of 20170703): http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz

3. Topology

Ii. ZooKeeper installation and configuration

Take the node zk-node1 as an example, zk-node2/3 adjusted according to the situation.

1. Install jdk

ZooKeeper runs in a java environment. We recommend that you install jdk 1.7 or later ).

1) download
[root@zk-node1 ~]# cd /usr/local/src/[root@zk-node1 src]# wget http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm?AuthParam=1499065226_0efcc513ff7eb3edb189b0ee0eb7f2d1
2) install jdk
# Use "java -- version" after installation to check if the environment is ready [root @ zk-node1 src] # rpm-ivh jdk-8u131-linux-x64.rpm
2. Install ZooKeeper1) download ZooKeeper
[root@zk-node1 src]# wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
2) decompress and generate the zoo. cfg file
[root@zk-node1 ~]# cd /usr/local/src/[root@zk-node1 src]# tar -zxvf zookeeper-3.4.10.tar.gz -C /usr/local/[root@zk-node1 src]# cd /usr/local/[root@zk-node1 local]# mv zookeeper-3.4.10/ zookeeper/[root@zk-node1 local]# chown -R root:root zookeeper/[root@zk-node1 local]# cd zookeeper/[root@zk-node1 zookeeper]# cp conf/zoo_sample.cfg conf/zoo.cfg
3) set the zoo. cfg file
[Root @ zk-node1 zookeeper] # vim conf/zoo. cfg # tickTime: the smallest unit of time in zookeeper, in milliseconds (MS), all time in zookeeper is based on this unit of time for integer times configuration; tickTime = 2000 # initLimit, zookeeper accepts the timeout interval between the client (not the client that the user connects to the zookeeper server, but the follower server connected to the leader in the zookeeper server cluster) to initialize the connection and complete data synchronization, multiples Based on tickTime; initLimit = 10 # syncLimit, configure the maximum latency between the leader and follower for heartbeat detection, a multiple based on tickTime; syncLimit = 5 # dataDir, the directory where zookeepe stores snapshot files. By default, transaction logs are also in this directory; # dataLogDir, which is not configured by default DataDir; dataDir =/usr/local/zookeeper/datadataLogDir =/usr/local/zookeeper/logs # clientPort, zookeeper service listening port; clientPort = 2181 # server. id = ip1: port1: port2, id is the Server ID, used to identify the machine serial number in the cluster (create the myid file under the dataDir directory, and the file content is the Server ID number corresponding to the machine ); # ip1 is the node IP address. port1 is used to specify the port for communications and data synchronization between the follower server and the leader server, and port2 is used for voting communication during leader election; this parameter is not configured in standalone mode. Server.1 = 10.11.4.191: 2888: 3888server. 2 = 10.11.4.192: 2888: 3888server. 3 = 10.11.4.193: 2888: 3888
4) create a myid File
# Myid value needs to be adjusted according to the node [root @ zk-node1 ~] # Mkdir-p/usr/local/zookeeper/data [root @ zk-node1 ~] # Mkdir-p/usr/local/zookeeper/logs [root @ zk-node1 ~] # Echo "1">/usr/local/zookeeper/data/myid
5) set Environment Variables
[root@zk-node1 ~]# echo -e "export PATH=$PATH:/usr/local/zookeeper/bin" >> /etc/profile[root@zk-node1 ~]# source /etc/profile
3. Set iptables
[root@zk-node1 ~]# vim /etc/sysconfig/iptables-A INPUT -p tcp -m state --state NEW -m tcp --dport 2181 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 2888 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 3888 -j ACCEPT[root@zk-node1 ~]# service iptables restart
4. Start
# When starting the first node, there may be an error, after all the nodes are started no longer report error [root @ zk-node1 ~] # ZkServer. sh start
5. Set startup
[root@mesos-node1 ~]# cd /etc/rc.d/init.d/[root@mesos-node1 init.d]# vim zookeeper#!/bin/bash#chkconfig:2345 20 90#description:zookeeper#processname:zookeepercase $1 in          start) su root /usr/local/zookeeper/bin/zkServer.sh start;;          stop) su root /usr/local/zookeeper/bin/zkServer.sh stop;;          status) su root /usr/local/zookeeper/bin/zkServer.sh status;;          restart) su root /usr/local/zookeeper/bin/zkServer.sh restart;;          *)  echo "require start|stop|status|restart"  ;;esac[root@mesos-node1 init.d]# chmod +x zookeeper[root@mesos-node1 init.d]# chkconfig --add zookeeper
6. Verify 1) view the status
[root@zk-node1 ~]# zkServer.sh status

[root@zk-node2 ~]# zkServer.sh status

[root@zk-node3 ~]# zkServer.sh status

2) remote connection
[root@zk-node1 ~]# zkCli.sh -server 10.11.4.193

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.