CentOs7.3 build ZooKeeper-3.4.9 stand-alone service

Overview#

Zookeeper is actually developed by Yahoo and is used as a framework for consistent processing in distributed applications. It was originally a by-product of the development of Hadoop. Due to the difficulty of consistency processing in distributed systems, other distributed systems do not need to laboriously reinvent the wheels, so zookeeper is widely used in subsequent distributed systems, so that zookeeper has become the basic component of various distributed systems. The importance of status can be imagined. The famous hadoop, kafka, dubbo are all based on zookeeper.

To understand what zookeeper does, you must first understand clearly what is consistency? **

The so-called consistency actually revolves around "seeing". Who can see? Can you see it? When did you see it? For example: Taobao backend sellers put a big promotion item in the backend and submit it to the main database through server A. Assuming that immediately after submission, there are users who go to query the item from the database through application server B, and a Phenomenon, the seller has successfully updated, but the buyer can't see it; and after a period of time, the data in the master database is synchronized to the slave database, and the buyer can check it.

Assuming that the buyer can see the seller’s update immediately after the seller’s update is successful, it is called strong consistency

If the buyer cannot see the content updated by the seller after the seller update is successful, it is called weak consistency**

After the seller is updated successfully, the buyer can finally see the seller's update after a period of time, which is called final consistency

"Conformance Agreement"

"ZooKeeper Application Scenarios"

"Distributed Architecture"

"Distributed ZooKeeper Series"

surroundings#

VMware version number: 12.0.0

CentOS version: CentOS 7.3.1611

ZooKeeper version: ZooKeeper-3.4.9.tar.gz

JDK environment: jdk-8u144-linux-x64.tar.gz

JDK 1.8 installation

Specific reference ["CentOs7.3 install JDK1.8"] (https://segmentfault.com/a/1190000010716919)

ZooKeeper installation#

1. Download ZooKeeper

cd /opt/
wget https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/zookeeper-3.4.9/zookeeper-3.4.9.tar.gz

Or download and upload in the browser to the opt directory

2. Extract tar file##

cd /opt/
tar -zxf  zookeeper-3.4.9.tar.gz
cd zookeeper-3.4.9

Create a data folder to store data files

mkdir data  logs

Create a logs folder to store logs

mkdir logs  

3. Create configuration file##

Use the command vi conf/zoo.cfg to create a configuration file and open it, ps (in fact, there is a default configuration file under the directory conf, but there are too many comments, a lot of English, and too messy)

vi  /opt/zookeeper-3.4.9/conf/zoo.cfg

The edit content is as follows

tickTime =2000
dataDir =/opt/zookeeper-3.4.9/data
dataLogDir =/opt/zookeeper-3.4.9/logs
tickTime =2000
clientPort =2181
initLimit =5
syncLimit =2

Configuration file description

tickTime

dataDir

dataLogDir

initLimit

syncLimit

ZooKeeper operation#

Start service##

/opt/zookeeper-3.4.9/bin/zkServer.sh start

response

ZooKeeper JMX enabled by default
Using config:/opt/zookeeper-3.4.9/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

Connection service##

Connect to ZooKeeper service

/opt/zookeeper-3.4.9/bin/zkCli.sh

response

Connecting to localhost:21812017-08-2216:43:05,954[myid:]- INFO  [main:Environment@100]- Client environment:zookeeper.version=3.4.9-1757313, built on 08/23/201606:50 GMT
2017- 08- 2216:43:05,958[ myid:]- INFO  [main:Environment@100]- Client environment:host.name=node1
2017- 08- 2216:43:05,958[ myid:]- INFO  [main:Environment@100]- Client environment:java.version=1.8.0_144
2017- 08- 2216:43:05,967[ myid:]- INFO  [main:Environment@100]- Client environment:java.vendor=Oracle Corporation
2017- 08- 2216:43:05,967[ myid:]- INFO  [main:Environment@100]- Client environment:java.home=/usr/lib/jvm/jre
2017- 08- 2216:43:05,967[ myid:]- INFO  [main:Environment@100]- Client environment:java.class.path=/opt/zookeeper-3.4.9/bin/../build/classes:/opt/zookeeper-3.4.9/bin/../build/lib/*.jar:/opt/zookeeper-3.4.9/bin/../lib/slf4j-log4j12-1.6.1.jar:/opt/zookeeper-3.4.9/bin/../lib/slf4j-api-1.6.1.jar:/opt/zookeeper-3.4.9/bin/../lib/netty-3.10.5.Final.jar:/opt/zookeeper-3.4.9/bin/../lib/log4j-1.2.16.jar:/opt/zookeeper-3.4.9/bin/../lib/jline-0.9.94.jar:/opt/zookeeper-3.4.9/bin/../zookeeper-3.4.9.jar:/opt/zookeeper-3.4.9/bin/../src/java/lib/*.jar:/opt/zookeeper-3.4.9/bin/../conf:.:/lib/jvm/lib:/lib/jvm/jre/lib
2017- 08- 22 16:43:05,967 [ myid:] - INFO  [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2017- 08- 22 16:43:05,967 [ myid:] - INFO  [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2017- 08- 22 16:43:05,967 [ myid:] - INFO  [main:Environment@100] - Client environment:java.compiler=<NA>
2017- 08- 22 16:43:05,967 [ myid:] - INFO  [main:Environment@100] - Client environment:os.name=Linux
2017- 08- 22 16:43:05,967 [ myid:] - INFO  [main:Environment@100] - Client environment:os.arch=amd64
2017- 08- 22 16:43:05,967 [ myid:] - INFO  [main:Environment@100] - Client environment:os.version=3.10.0-514.26.2.el7.x86_64
2017- 08- 22 16:43:05,968 [ myid:] - INFO  [main:Environment@100] - Client environment:user.name=root
2017- 08- 22 16:43:05,968 [ myid:] - INFO  [main:Environment@100] - Client environment:user.home=/root
2017- 08- 22 16:43:05,968 [ myid:] - INFO  [main:Environment@100] - Client environment:user.dir=/opt/zookeeper-3.4.9
2017- 08- 22 16:43:05,969 [ myid:] - INFO  [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@506c589e
Welcome to ZooKeeper!
2017- 08- 22 16:43:06,011 [ myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
JLine support is enabled
2017- 08- 22 16:43:06,164 [ myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@876] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2017- 08- 22 16:43:06,237 [ myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1299] - Session establishment complete on server localhost/0:0:0:0:0:0:0:1:2181, sessionid = 0x15e091bf2020000, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null

[ zk: localhost:2181(CONNECTED) 0] 

service status##

/opt/zookeeper-3.4.9/bin/zkServer.sh status

response

ZooKeeper JMX enabled by default
Using config:/opt/zookeeper-3.4.9/bin/../conf/zoo.cfg
Mode: standalone

Out of service##

/opt/zookeeper-3.4.9/bin/zkServer.sh stop

response

bin/zkServer.sh stop
ZooKeeper JMX enabled by default
Using config:/opt/zookeeper-3.4.9/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED

Recommended reading##

CentOs7.3 build ZooKeeper-3.4.9 Cluster cluster service

Contact

Recommended Posts

CentOs7.3 build ZooKeeper-3.4.9 stand-alone service
CentOs7.3 build RabbitMQ 3.6 stand-alone service
Centos7 build DNS service
CentOs7.3 build SolrCloud cluster service
Build WeChat applet service based on CentOS
Build WeChat applet service based on CentOS
CentOS7 build jenkins
Centos build lnmp
Centos7 build python3.8.5+scrapy+gerapy
CentOS7 build gerrit code review service method
CentOS7.3 64 bit, build Zabbix3.4
CentOS 8 enable NTP service
Linux (centos7) build gitlab
Build k8s1.9.9 on centos7
CentOS6.7 build LNMP environment
Centos6.9 build rabbitmq 3.6.8 cluster
CentOS 7 install Docker service
Centos7.6 build LNMP environment
CentOS 7 deploys RabbitMQ service
CentOS 6.8 deploy zookeeper cluster
CentOS 7 deploy saltstack service
Centos7 build Kubernetes cluster
Centos 7.4 install stand-alone Spark
Jenkins build on centos
Build Hadoop in CentOS
CentOS7 deploys NFS service
Centos6.8 deploy vnc service
CentOS 7 build LNMP environment
CentOS7 deploy vsftp (FTP) service
Build docker environment under Centos6.5
Build OpenV** Server under CentOS7
Build zabbix monitoring zabbix4.2 in CentOS7.6
Build OpenLDAP server under CentOS7
Build zabbix monitoring zabbix4.2 in CentOS7.6
Build MariaDB replication on CentOS
Centos7.2 deployment vnc service record
Centos 7 install jdk and package service service
CentOS8.1 build Gitlab server detailed tutorial
Build a PXC cluster under CentOS8
CentOS builds a cloud service platform
CentOS 8 - install and configure NFS service
Centos6 method steps to build gitlab
Build an FTP server under centos7
Build Elasticsearch 6.2.4 (centos) based on docker
Build Nginx environment on Linux (CentOS)
CentOS 7 Tomcat service installation and configuration
(centos7) linux build nginx load balancing build
Centos7 build java web server tomcat
Build Discuz Forum based on CentOS
Build Yum private warehouse in Centos7.3
virtualBox install centos, and build tomcat