In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Zookeeper introduction
ZooKeeper is a centralized service for maintaining configuration information, naming, and providing distributed synchronization and group services. All these types of services are used in the form of distributed applications. It has a reliable, scalable, distributed and configurable coordination mechanism to unify the state of the system.
Server planning
At least three servers are needed in the zookeeper cluster. Because of the limited resources, let's take three servers as an example.
Zookeeper deployment model
There are three ways to install Zookeeper, stand-alone mode, cluster mode and pseudo-cluster mode.
Stand-alone mode: Zookeeper runs on only one server, which is suitable for test environment
Pseudo-cluster mode: running multiple Zookeeper instances on a single physical machine
Cluster mode: Zookeeper runs on a cluster that is suitable for production environments. This computer cluster is called a "ensemble".
Zookeeper profile
The official configuration file template is zoo_sample.cfg, which we need to change to zoo.cfg when we use it in the real environment. Operate on 192.168.2.177
[root@rocketmq-nameserver1 conf] # vim zoo.cfgtickTime=2000initLimit=10syncLimit=5dataDir=/wdata/zookeeperdataLogDir=/wdata/zookeeper/logsclientPort=2181#maxClientCnxns=60#autopurge.snapRetainCount=3#autopurge.purgeInterval=1server.1=192.168.2.177:2888:3888server.2=192.168.2.178:2888:3888server.3=192.168.2.180:2888:3888
Profile description:
Server.X=A:B:C
Where X is the server number, An is the IP address of the node server, B is the Leader communication port, and C is the Zookeeper Leader election port
DataLogDir:zookeeper transaction log directory
DataDir:zookeeper data storage directory
ClientPort: client listening port
SyncLimit: the maximum number of heartbeats that can be tolerated between the flower server (F) and the leader (L) server in the cluster.
InitLimit: the maximum number of heartbeats (number of tickTime) that can be tolerated during the initial connection between the flower server (F) and the leader server (L) in the cluster.
TickTime:CS communication heartbeat time, the heartbeat is maintained between the client and the server or between the server and the server, that is, a heartbeat is sent every tickTime time. Not only can the heartbeat be used to monitor the working state of the machine, but also the communication time between Flower and Leader can be controlled by heartbeat. By default, FL sessions are often twice the heartbeat interval.
Zookeeper cluster
Before building a Zookeeper cluster, we need to modify the environment variables of the system
Modified on 192.168.2.177, 192.168.2.178 and 192.168.2.180 respectively
[root@rocketmq-nameserver1 ~] # vim .bash _ profileexport JAVA_HOME=/usr/local/jdk1.8.0_201export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.13export PATH=$PATH:$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin
Copy Profil
We distributed the configured configuration files to two other servers (178 and 180)
For i in 178 180; do scp zoo.cfg root@192.168.2.$i; done
We add the server number file to the three servers. The content in the file is the server number, and the server number must correspond to the number in the configuration file, otherwise the cluster cannot be started.
[root@rocketmq-nameserver1 zookeeper] # vim myid
The other two servers are numbered 2 and 3, respectively.
At this point, the configuration is complete, and then we start the zookeeper service.
Run on three servers
[root@rocketmq-nameserver1 ~] # zkServer.sh start
View zookeeper service startup status
[root@rocketmq-nameserver1 ~] # zkServer.sh status
At this point, the zookeeper cluster has been built.
Here are the common commands for zookeeper
Conf: outputs the details of the relevant service configuration.
Cons: lists the full connection / session details of all clients connected to the server. Includes information about the number of packets "accepted / sent", session id, operation delay, last operation execution, and so on.
Dump: lists unhandled sessions and temporary nodes.
Envi: outputs detailed information about the service environment (different from the conf command).
Reqs: lists unprocessed requests
Ruok: test whether the service is in the correct state. If so, the service returns "imok", otherwise no response is made.
Stat: outputs a list of performance and connected clients.
Wchs: lists the details of the server watch.
Wchc: lists the details of the server watch through session, and its output is a list of watch-related sessions.
Wchp: lists the details of the server watch by path. It outputs a path related to session.
Zookeeper command line tool
Connect to the zookeeper service through zkCli.sh, as follows
[root@rocketmq-nameserver2 ~] # zkCli.sh-server 192.168.2.178VR 2181
After a successful connection, it will be shown in the following figure:
Here we can enter the zookeeper command to do the relevant operations. You can use help for help queries. Here are all the commands under the zookeeper command line
Stat path [watch]
Set path data [version]
Ls path [watch]
Delquota [- n |-b] path
Ls2 path [watch]
SetAcl path acl
Setquota-n |-b val path
History
Redo cmdno
Printwatches on | off
Delete path [version]
Sync path
Listquota path
Rmr path
Get path [watch]
Create [- s] [- e] path data acl
Addauth scheme auth
Quit
GetAcl path
Close
Connect host:port
For the use of specific commands, please refer to the official documentation, which is not described too much here.
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.