In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the building method of Zookeeper stand-alone environment and cluster environment, which is very detailed and has a certain reference value. Interested friends must finish reading it!
First, build a stand-alone environment #
1.1 download #
Download the corresponding version of Zookeeper, which I downloaded here, version 3.4.14. Official download address: https://archive.apache.org/dist/zookeeper/
# wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz
1.2 decompress #
# tar-zxvf zookeeper-3.4.14.tar.gz
1.3 configure environment variables #
# vim / etc/profile
Add environment variables:
Export ZOOKEEPER_HOME=/usr/app/zookeeper-3.4.14export PATH=$ZOOKEEPER_HOME/bin:$PATH
Make the configured environment variables take effect:
# source / etc/profile
1.4 modify configuration #
Go to the conf/ directory of the installation directory, copy the configuration sample and modify it:
# cp zoo_sample.cfg zoo.cfg
Specify the data storage directory and log file directory (the directory does not need to be created in advance, the program will create it automatically). The complete configuration after modification is as follows:
# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial# synchronization phase can takeinitLimit=10# The number of ticks that can pass between# sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use / tmp for storage / tmp here is just# example sakes.dataDir=/usr/local/zookeeper/datadataLogDir=/usr/local/zookeeper/log# the port at which the clients will connectclientPort=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 autopurge feature#autopurge.purgeInterval=1
Configuration parameters description:
TickTime: the basic unit of time used for computing. For example, session timeout: N*tickTime
InitLimit: for clustering, the initial connection time, expressed in multiples of tickTime, that allows connections from nodes to be synchronized to master nodes
SyncLimit: for clustering, sending messages, request and response time between master master and slave nodes (heartbeat mechanism)
DataDir: data storage location
DataLogDir: log directory
ClientPort: the port used for client connections. Default is 2181.
1.5 start #
Since the environment variable has been configured, you can start it directly using the following command:
ZkServer.sh start
1.6 Verification #
Use JPS to verify that the process has been started, and the presence of QuorumPeerMain indicates that the process has started successfully.
[root@hadoop001 bin] # jps3814 QuorumPeerMain
Second, build a cluster environment #
To ensure the high availability of the cluster, the number of nodes in the Zookeeper cluster is preferably odd, with at least three nodes, so here is a demonstration of building a three-node cluster. Here I use three hosts to build, the hostname is hadoop001,hadoop002,hadoop003.
2.1 modify configuration #
Extract a zookeeper installation package and modify its configuration file zoo.cfg, as follows. Then use the scp command to distribute the installation package to the three servers:
TickTime=2000initLimit=10syncLimit=5dataDir=/usr/local/zookeeper-cluster/data/dataLogDir=/usr/local/zookeeper-cluster/log/clientPort=2181# server.1 1 is the ID of the server, which can be any valid number, indicating which server node this is. This ID should be written to the myid file under the dataDir directory. # name the inter-cluster communication port and the election port server.1=hadoop001:2287:3387server.2=hadoop002:2287:3387server.3=hadoop003:2287:3387
2.2 identify node #
Create a new myid file under the dataDir directory of the three hosts, and write the corresponding node identity. The Zookeeper cluster identifies the cluster node through the myid file, and communicates with the node through the node communication port and election port configured above, and elects the Leader node.
Create a storage directory:
# all three hosts execute the command mkdir-vp / usr/local/zookeeper-cluster/data/
Create and write the node identity to the myid file:
# hadoop001 host echo "1" > / usr/local/zookeeper-cluster/data/myid# hadoop002 host echo "2" > / usr/local/zookeeper-cluster/data/myid# hadoop003 host echo "3" > / usr/local/zookeeper-cluster/data/myid
2.3 start the cluster #
On each of the three hosts, execute the following command to start the service:
/ usr/app/zookeeper-cluster/zookeeper/bin/zkServer.sh start
2.4 Cluster Verification #
After startup, use zkServer.sh status to view the status of each node in the cluster. As shown in the figure: all three node processes are started successfully, and hadoop002 is a leader node, and hadoop001 and hadoop003 are follower nodes.
These are all the contents of this article entitled "how to build Zookeeper stand-alone environment and cluster environment". 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.