In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the distributed system how to achieve zookeeper installation, the article is very detailed, has a certain reference value, interested friends must read it!
ZooKeeper is a distributed, open source distributed application coordination service, which contains a simple set of primitives based on which distributed applications can implement synchronization services, configuration maintenance and naming services.
Design purpose
1. Ultimate consistency: no matter which Server client connects to, it is shown to be the same view, which is the most important performance of zookeeper.
2. Reliability: with simple, robust, good performance, if message m is accepted by one server, it will be accepted by all servers.
3. Real-time: Zookeeper ensures that the client will get the update information of the server or the information of server failure within a time interval. However, due to network delay and other reasons, Zookeeper can not guarantee that two clients can get the newly updated data at the same time. If the latest data is needed, the sync () interface should be called before reading the data.
4. Wait irrelevant (wait-free): slow or invalid client must not interfere with fast client requests so that each client can wait effectively.
5. Atomicity: updates can only succeed or fail, with no intermediate state.
6. Ordering: including global order and partial order: global order means that if message an is published before message b on a server, message a will be published before message b on all Server; partial order means that if a message b is released by the same sender after message a, a will be before b.
ZK installation is divided into stand-alone installation, pseudo-distributed installation and distributed installation.
I. stand-alone installation
[root@node1 bin] # wget http://apache.opencas.org/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
[root@node1 zk] # ls
Zookeeper-3.4.6.tar.gz
[root@node1 zk] # tar-zxvf zookeeper-3.4.6.tar.gz
[root@node1 zk] # ls
Zookeeper-3.4.6 zookeeper-3.4.6.tar.gz
[root@node1 zk] # mv zookeeper-3.4.6 zookeeper
[root@node1 zk] # cd zookeeper
[root@node1 zookeeper] # ls
Bin CHANGES.txt contrib docs ivy.xml LICENSE.txt README_packaging.txt recipes zookeeper-3.4.6.jar zookeeper-3.4.6.jar.md5
Build.xml conf dist-maven ivysettings.xml lib NOTICE.txt README.txt src zookeeper-3.4.6.jar.asc zookeeper-3.4.6.jar.sha1
[root@node1 zookeeper] # cd conf/
[root@node1 conf] # ls
Configuration.xsl log4j.properties zoo_sample.cfg
[root@node1 conf] # cp zoo_sample.cfg zoo.cfg
[root@node1 conf] # cat zoo.cfg
# The number of milliseconds of each tick
TickTime=2000
# The number of ticks that the initial
# synchronization phase can take
InitLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
SyncLimit=5
# the directory where the snapshot is stored.
# do not use / tmp for storage, / tmp here is just
# example sakes.
DataDir=/tmp/zookeeper
# the port at which the clients will connect
ClientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
# maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
# autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
# autopurge.purgeInterval=1
[root@node1 conf] # java-version
Java version "1.7.045"
OpenJDK Runtime Environment (rhel-2.4.3.3.el6-i386 u45-b15)
OpenJDK Client VM (build 24.45-b08, mixed mode, sharing)
[root@node1 conf] # cd.. /
[root@node1 zookeeper] # cd bin/
[root@node1 bin] # ls
README.txt zkCleanup.sh zkCli.cmd zkCli.sh zkEnv.cmd zkEnv.sh zkServer.cmd zkServer.sh
[root@node1 bin] #. / zkServer.sh
JMX enabled by default
Using config: / opt/zk/zookeeper/bin/../conf/zoo.cfg
Usage:. / zkServer.sh {start | start-foreground | stop | restart | status | upgrade | print-cmd}
[root@node1 bin] #. / zkServer.sh start
JMX enabled by default
Using config: / opt/zk/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper... STARTED
[root@node1 bin] # jps
4341 Jps
4325 QuorumPeerMain
2. Pseudo-distributed installation
Installation tips: pay attention to modify the port number of clientPort. it is recommended to change it to 2181, 2182 and 2183 in turn, and write it to the myId file, which must correspond to the serial number in Server.X.
Server.1=127.0.0.1:2888:3888
Server.2=127.0.0.1:2889:3889
Server.3=127.0.0.1:2890:3890
[root@node1 conf] # vi zoo.cfg
# The number of milliseconds of each tick
TickTime=2000
# The number of ticks that the initial
# synchronization phase can take
InitLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
SyncLimit=5
# the directory where the snapshot is stored.
# do not use / tmp for storage, / tmp here is just
# example sakes.
DataDir=../zkdata
# the port at which the clients will connect
ClientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
# maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
# autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
# autopurge.purgeInterval=1
Server.1=127.0.0.1:2888:3888
Server.2=127.0.0.1:2889:3889
Server.3=127.0.0.1:2890:3890
~
"zoo.cfg" 33L, 1007C written
[root@node1 conf] # cd.. /
[root@node1 zookeeper] # mkdir zkdata
[root@node1 zookeeper] # cd.. /
[root@node1 zk] # clear
[root@node1 zk] # ls
Zookeeper zookeeper-3.4.6.tar.gz
[root@node1 zk] # cp-R zookeeper zookeeper2
[root@node1 zk] # cp-R zookeeper zookeeper3
[root@node1 zk] # jps
4372 Jps
4325 QuorumPeerMain
[root@node1 zk] # kill-9 4325
[root@node1 zk] # jps
4381 Jps
[root@node1 zk] # echo 1 > zookeeper/zkdata/myid
[root@node1 zk] # echo 2 > zookeeper2/zkdata/myid
[root@node1 zk] # echo 3 > zookeeper3/zkdata/myid
[root@node1 zk] # echo 2 > zookeeper2/zkdata/myid
[root@node1 zk] # cat zookeeper3/zkdata/myid
three
[root@node1 zk] # cat zookeeper2/zkdata/myid
two
[root@node1 zk] # cat zookeeper/zkdata/myid
one
[root@node1 zk] #
Initiate verification
/ opt/zk/zookeeper/bin/zkServer.sh start-foreground
/ opt/zk/hadoop/zookeeper2/bin/zkServer.sh start-foreground
/ opt/zk/hadoop/zookeeper3/bin/zkServer.sh start-foreground
After enabling successfully, type jps to see the progress.
III. Distributed installation
Modify the zoo.cfg file of the stand-alone installation, as shown in the following figure. Because it is a distributed installation, you only need to modify the corresponding IP address in the red part of the chart below to [root@node1 conf] # vi zoo.cfg.
# The number of milliseconds of each tick
TickTime=2000
# The number of ticks that the initial
# synchronization phase can take
InitLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
SyncLimit=5
# the directory where the snapshot is stored.
# do not use / tmp for storage, / tmp here is just
# example sakes.
DataDir=../zkdata
# the port at which the clients will connect
ClientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
# maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
# autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
# autopurge.purgeInterval=1
Server.1=192.168.1.1:2888:3888
Server.2=192.168.1.2:2888:3888
Server.3=192.168.1.3:2888:3888
~
Step 2. Distribute the files to the other two machines through the Scp command
Step 3. Modify the respective myid files, which must correspond to the server.1=192.168.1.1 numbers and IP configured in the zoo.cfg.
[root@node1 zk] # echo 1 > zookeeper/zkdata/myid
Step 4. Start verification / opt/zk/zookeeper/bin/zkServer.sh start-foreground
4. Zookeeper listens on three ports
2181: used to monitor zookeeper client connections
2888: if it is a leader, it is used to monitor follower connections
3888: used to monitor connections to other servers during the election leadership phase.
These are all the contents of the article "how to implement zookeeper installation in distributed Systems". Thank you for reading! Hope to share the content to help you, more related 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.