Zookeeper Local Mode Installation

installation steps

Upload gz package

By rz command, the installation package zookeeper-3.4.10.tar.gz upload / opt / soft / folder.

[root@bigdata111 soft]# rz
[root@bigdata111 soft]# ls
hadoop-2.8.4.tar.gz  jdk-8u144-linux-x64.tar.gz  zookeeper-3.4.10.tar.gz

Extracting package

Zookeeper to unzip under / opt / module / directory through the tar command.

[root@bigdata111 soft]# tar -zvxf zookeeper-3.4.10.tar.gz -C /opt/module/
[root@bigdata111 soft]# cd /opt/module/
[root@bigdata111 module]# ls
hadoop-2.8.4  jdk1.8.0_144  zookeeper-3.4.10

New zkData directory

ZkData new folder in the directory zookeeper decompression for data file directory + persistent data path.

[root@bigdata111 module]# cd zookeeper-3.4.10/
[root@bigdata111 zookeeper-3.4.10]# mkdir zkData
[root@bigdata111 zookeeper-3.4.10]# ls
bin  build.xml  conf  contrib  dist-maven  docs  ivysettings.xml  ivy.xml  lib  LICENSE.txt  NOTICE.txt  README_packaging.txt  README.txt  recipes  src  zkData  zookeeper-3.4.10.jar  zookeeper-3.4.10.jar.asc  zookeeper-3.4.10.jar.md5  zookeeper-3.4.10.jar.sha1

Modify the default file name

Switch to conf directory zookeeper, modification identified zoo.cfg zoo_sample.cfg the default configuration file.

[root@bigdata111 module]# cd zookeeper-3.4.10/conf
[root@bigdata111 conf]# ll
总用量 12
-rw-rw-r--. 1 1001 1001  535 3月  23 2017 configuration.xsl
-rw-rw-r--. 1 1001 1001 2161 3月  23 2017 log4j.properties
-rw-rw-r--. 1 1001 1001  922 3月  23 2017 zoo_sample.cfg
[root@bigdata111 conf]# mv zoo_sample.cfg zoo.cfg
[root@bigdata111 conf]# ll
总用量 12
-rw-rw-r--. 1 1001 1001  535 3月  23 2017 configuration.xsl
-rw-rw-r--. 1 1001 1001 2161 3月  23 2017 log4j.properties
-rw-rw-r--. 1 1001 1001  922 3月  23 2017 zoo.cfg

Configuration changes

Zoo.cfg zookeeper's configuration file, save and exit.

[root@bigdata111 conf]# vi zoo.cfg

Wherein the values ​​of dataDir modified as follows:

dataDir=/opt//module/zookeeper-3.4.10/zkData

Configuration environment variable

Vi command execution

[root@bigdata111 conf]# vi /etc/profile

In the / etc / profile add the contents of the file at the end of the following, the configuration is complete, save and exit.

export ZOOKEEPER_HOME=/opt/module/zookeeper-3.4.10
export PATH=$PATH:$ZOOKEEPER_HOME/bin

Refresh profile configuration file

[root@bigdata111 zookeeper-3.4.10]# source /etc/profile

Start zk server

Zk start the server to see if the process is started (QuorumPeerMain process for the zookeeper's server), view the status of zkServer.

[root@bigdata111 zookeeper-3.4.10]# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.4.10/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@bigdata111 zookeeper-3.4.10]# jps
2817 NodeManager
2565 DataNode
3014 QuorumPeerMain
2426 NameNode
3034 Jps
[root@bigdata111 zookeeper-3.4.10]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.4.10/bin/../conf/zoo.cfg
Mode: standalone

Start zk client

[root@bigdata111 zookeeper-3.4.10]# zkCli.sh
Connecting to localhost:2181
2019-09-01 00:00:07,411 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT
2019-09-01 00:00:07,413 [myid:] - INFO  [main:Environment@100] - Client environment:host.name=bigdata111
2019-09-01 00:00:07,413 [myid:] - INFO  [main:Environment@100] - Client environment:java.version=1.8.0_144
2019-09-01 00:00:07,423 [myid:] - INFO  [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2019-09-01 00:00:07,423 [myid:] - INFO  [main:Environment@100] - Client environment:java.home=/opt/module/jdk1.8.0_144/jre
2019-09-01 00:00:07,424 [myid:] - INFO  [main:Environment@100] - Client environment:java.class.path=/opt/module/zookeeper-3.4.10/bin/../build/classes:/opt/module/zookeeper-3.4.10/bin/../build/lib/*.jar:/opt/module/zookeeper-3.4.10/bin/../lib/slf4j-log4j12-1.6.1.jar:/opt/module/zookeeper-3.4.10/bin/../lib/slf4j-api-1.6.1.jar:/opt/module/zookeeper-3.4.10/bin/../lib/netty-3.10.5.Final.jar:/opt/module/zookeeper-3.4.10/bin/../lib/log4j-1.2.16.jar:/opt/module/zookeeper-3.4.10/bin/../lib/jline-0.9.94.jar:/opt/module/zookeeper-3.4.10/bin/../zookeeper-3.4.10.jar:/opt/module/zookeeper-3.4.10/bin/../src/java/lib/*.jar:/opt/module/zookeeper-3.4.10/bin/../conf:
2019-09-01 00:00:07,424 [myid:] - INFO  [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2019-09-01 00:00:07,424 [myid:] - INFO  [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2019-09-01 00:00:07,424 [myid:] - INFO  [main:Environment@100] - Client environment:java.compiler=<NA>
2019-09-01 00:00:07,424 [myid:] - INFO  [main:Environment@100] - Client environment:os.name=Linux
2019-09-01 00:00:07,424 [myid:] - INFO  [main:Environment@100] - Client environment:os.arch=amd64
2019-09-01 00:00:07,424 [myid:] - INFO  [main:Environment@100] - Client environment:os.version=3.10.0-327.el7.x86_64
2019-09-01 00:00:07,424 [myid:] - INFO  [main:Environment@100] - Client environment:user.name=root
2019-09-01 00:00:07,424 [myid:] - INFO  [main:Environment@100] - Client environment:user.home=/root
2019-09-01 00:00:07,424 [myid:] - INFO  [main:Environment@100] - Client environment:user.dir=/opt/module/zookeeper-3.4.10
2019-09-01 00:00:07,425 [myid:] - INFO  [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@5c29bfd
2019-09-01 00:00:07,467 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
Welcome to ZooKeeper!
JLine support is enabled
2019-09-01 00:00:07,559 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@876] - Socket connection established to localhost/127.0.0.1:2181, initiating session
2019-09-01 00:00:07,588 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1299] - Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x16ce86366fb0000, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null
[zk: localhost:2181(CONNECTED) 0]

View zk node

Use ls View / root directory, not only ls output.

[zk: localhost:2181(CONNECTED) 1] ls /
[zookeeper]

Exit the client

[zk: localhost:2181(CONNECTED) 0] quit
Quitting...
2019-09-01 00:01:10,945 [myid:] - INFO  [main:ZooKeeper@684] - Session: 0x16ce86366fb0000 closed
2019-09-01 00:01:10,947 [myid:] - INFO  [main-EventThread:ClientCnxn$EventThread@519] - EventThread shut down for session: 0x16ce86366fb0000

Stop Zookeeper

[root@bigdata111 zookeeper-3.4.10]# zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /opt/module/zookeeper-3.4.10/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED

Reading configuration parameters

tickTime

tickTime = 2000: heart rate communication, the Zookeeper server heartbeat time, in milliseconds

Zookeeper basic time use, or the server is maintained between client and server heartbeat time interval, i.e. each time tickTime will send a heartbeat, the time in milliseconds.

It heartbeat mechanism is used, and set the minimum session timeout is twice the heartbeat time. (Minimum session timeout is 2 * tickTime)

initLimit

initLimit = 10: Leader and Follower initial communication time

Maximum number of heartbeats between the cluster leader and follower follower leader server initial connection, the server can tolerate (number of tickTime), which is defined by the cluster server is connected to Zookeeper Leader of time.

Voting to elect a new leader of the initialization time

Follower during startup, will synchronize all the latest data from the Leader, then we can determine the initial state of the external services.

Leader Follower allowed to complete this work within initLimit time.

syncLimit

syncLimit = 5: Leader and Follower synchronous communication time

Cluster maximum response time of units between Leader and Follower, if the response exceeded syncLimit * tickTime, Leader believes Follwer dead, Follwer deleted from the server list.

During operation, Leader responsible for communication with the ZK all the machines in the cluster, for example, through a number of heartbeat mechanism to detect the survival of the state of the machine.

After issuing a heartbeat if L package syncLimit, has not received a response from F that, then that is no longer the F line up.

dataDir

dataDir: data file directory path + data persistence

Save in-memory database snapshot information, if not stated otherwise, the update transaction log is also saved to the database.

clientPort

clientPort = 2181: Client port

Port to listen for client connections

Guess you like

Origin www.cnblogs.com/ShadowFiend/p/11445707.html