Zookeeper Installation Deployment

Source: Internet
Author: User
Tags server port egrep

Reference http://kaibinyuan.blog.51cto.com/7304008/1616454

Reference http://luchunli.blog.51cto.com/2368057/1681841

1. Install Zookeeper standalone mode

Configuring the Java Environment

[[email protected] ~]# wget https://www.reucon.com/cdn/java/jdk-8u45-linux-x64.tar.gz[[ email protected] ~]# tar xf jdk-8u45-linux-x64.tar.gz[[email protected] ~]#  cp -r jdk1.8.0_45 /usr/local/[[email protected] ~]# cat /etc/ profile.d/java.shjava_home=/usr/local/jdk1.8.0_45java_bin=/usr/local/jdk1.8.0_45/binjre_home=/usr/local/ Jdk1.8.0_45/jrepath= $PATH://usr/local/jdk1.8.0_45/bin:/usr/local/jdk1.8.0_45/jre/binclasspath=/usr/local/ jdk1.8.0_45/jre/lib:/usr/local/jdk1.8.0_45/lib:/usr/local/jdk1.8.0_45/jre/lib/charsets.jar[[email  protected] ~]# source /etc/profile.d/java.sh[[email protected] ~]# java - versionjava version  "1.8.0_45" Java (TM)  SE Runtime Environment  (build 1.8.0_ 45-B14) Java hotspot (TM)  64-Bit Server VM  (Build 25.45-b02, mixed mode)

Download package

[Email protected] ~]# wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz

Installation

[[email protected] ~]# tar xf  zookeeper-3.4.6.tar.gz -c /usr/local/[[email protected] ~]# ln -s /usr/ local/zookeeper-3.4.6/ /usr/local/zookeeper[[email protected] conf]# pwd/usr/local/ zookeeper/conf[[email protected] conf]# cp zoo_sample.cfg zoo.cfg# Modifying a configuration file [[email  protected] conf]# egrep -v  "^#|^$"  /usr/local/zookeeper/conf/zoo.cfg ticktime= 2000initlimit=10synclimit=5datadir=/data/zookeeper/buildclientport=2181datalogdir=/data/zookeeper/logs# ticktime:  this time is the time interval between the zookeeper server or between the client and the server to maintain the heartbeat,  that is, each ticktime time sends a heartbeat #datadir:  As the name implies is zookeeper to save the data directory,  by default,  zookeeper writes the log of the data is also stored in this directory #clientport:  this port is the client connection Zookeeper server port ,  zookeeper listens to this port,  accepts the client's access request 

Start Zookeeper

[Email protected] ~]#/usr/local/zookeeper/bin/zkserver.sh startjmx enabled by defaultusing Config:/usr/local/ zookeeper/bin/. /conf/zoo.cfgstarting Zookeeper ...                        started# view results [[email protected] ~]# NETSTAT-TUNLP |grep 2181tcp 0 0::: 2181:::* LISTEN 1444/java

2. Installing the Zookeeper Cluster

Zookeeper-1 192.168.3.19

Zookeeper-2 192.168.3.20

Zookeeper-1 Operation:

#停止zookeeper服务 [[email protected] ~]#/usr/local/zookeeper/bin/zkserver.sh stopjmx enabled by defaultusing Config:/usr/ local/zookee# Modify configuration file/usr/local/zookeeper/conf/zoo.cfg[[email protected] ~]# egrep-v "^$|^#"/usr/local/zookeeper/ Conf/zoo.cfg ticktime=2000initlimit=10synclimit=5datadir=/data/zookeeper/buildclientport=2181datalogdir=/data/ Zookeeper/logsserver.1 = 192.168.3.19:2888:3888server.2 = 192.168.3.20:2888:3888# configuration Myid[[email protected] ~]# CAT/ Data/zookeeper/build/myid 1

Zookeeper-2 need to install Java and zookeeper, see the procedure above

#配置文件内容如下 [[email protected] conf]# egrep-v "^$|^#"/usr/local/zookeeper/conf/zoo.cfg ticktime=2000initlimit= 10synclimit=5datadir=/data/zookeeper/buildclientport=2181datalogdir=/data/zookeeper/logsserver.1 = 192.168.3.19:2888:3888server.2 = 192.168.3.20:2888:3888# start service [[email protected] ~]#/usr/local/zookeeper/bin/ zkserver.sh startjmx enabled by defaultusing Config:/usr/local/zookeeper/bin/. /conf/zoo.cfgstarting Zookeeper ... STARTED

Finally verify the cluster status

#zookeeper -1[[email protected] ~]#/usr/local/zookeeper/bin/zkserver.sh statusjmx enabled by defaultusing Config:/usr/ local/zookeeper/bin/. /conf/zoo.cfgmode:leader#zookeeper-2[[email protected] ~]#/usr/local/zookeeper/bin/zkserver.sh StatusJMX enabled by defaultusing config:/usr/local/zookeeper/bin/. /conf/zoo.cfgmode:follower

Validation through client script

[[Email protected] ~]# /usr/local/zookeeper/bin/zkcli.sh[zk: localhost:2181 (CONNECTED)  2] ls /[zookeeper]                 #  deploy zookeeper cluster for the first time, create a node named/zookeeper by default [zk: localhost:2181 (CONNECTED)  3]  ls /zookeeper[quota]#  reading Znode data [zk: localhost:2181 (CONNECTED)  5] get / zookeeper/quota   czxid = 0x0ctime = thu jan 01 08:00:00  CST 1970mZxid = 0x0mtime = Thu Jan 01 08:00:00 CST  1970pzxid = 0x0cversion = 0dataversion = 0aclversion = 0ephemeralowner  = 0x0dataLength = 0numChildren = 0#  Create znode[zk: localhost:2181 ( CONNECTED)  6] create /zk-book 123created /zk-book[zk: localhost:2181 (CONNECTED)  7] ls /[zk-book, zookeeper][zk: localhost:2181 (CONNECTED)  8] get /zk-book123cZxid =  0x300000004ctime = tue aug 11 14:46:48 cst 2015mzxid =  0x300000004mtime = tue aug 11 14:46:48 cst 2015pzxid =  0x300000004cversion = 0dataversion = 0         The version of     # version is 0aclversion = 0ephemeralowner = 0x0datalength  = 3numChildren = 0#  Update the value of Znode [zk: localhost:2181 (CONNECTED)  9] set  /zk-book 456cZxid = 0x300000004ctime = Tue Aug 11 14:46:48  cst 2015mzxid = 0x300000005mtime = tue aug 11 14:47:45 cst  2015pzxid = 0x300000004cversion = 0dataversion = 1             #  Post-UpdateVersion is 1aclversion = 0ephemeralowner = 0x0datalength = 3numchildren =  0# view results on zookeeper-2 [[EMAIL PROTECTED] ~]# /USR/LOCAL/ZOOKEEPER/BIN/ZKCLI.SH [ZK:  localhost:2181 (CONNECTED)  1] get /zk-book456czxid = 0x300000004ctime =  tue aug 11 14:46:48 cst 2015mzxid = 0x300000005mtime = tue  Aug 11 14:47:45 CST 2015pZxid = 0x300000004cversion =  0dataversion = 1aclversion = 0ephemeralowner = 0x0datalength =  3numchildren = 0# Delete/zk-book[zk: localhost:2181 (CONNECTED)  2] delete on zookeeper-2  /zk-book[zk: localhost:2181 (CONNECTED)  3] ls /[zookeeper] #在zookeeper-1 View results [ZK:  localhost:2181 (CONNECTED)  10] ls /[zookeeper]


This article is from the "ly36843" blog, please be sure to keep this source http://ly36843.blog.51cto.com/3120113/1683533

Zookeeper Installation Deployment

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.