In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, Xiaobian will bring you about how to build ZK clusters in Java. The article is rich in content and analyzed and described from a professional perspective. After reading this article, I hope you can gain something.
(1) Decompression, installation and synchronization
We have installed zk on hadoop100. Now we will extract the package and distribute it to hadoop101 and hadoop102 servers. The command is as follows:
[root@hadoop100 dev]# xsync zookeeper-3.4.10/
After synchronization, go to the opt/dev directory of the other two servers respectively to check whether the synchronization is successful, and when synchronizing, because we have made a secret login, is it not password required?
(2) Configuration server
① Create zkData in/opt/module/zookeeper-3.4.10/(if it has already been created, it does not need to be created again)
② Under/opt/dev/zookeeper-3.4.10/zkData, create a myid file as follows:
[root@hadoop100 zkData]# touch myid
③ Edit the myid file and add the number corresponding to server (starting from 1) to the file.
[root@hadoop100 zkData]# vi myid
④ Add and view as follows
Syncing files to other machines
[root@hadoop100 zkData]# xsync myid
Modify the myid file contents of hadoop101 and hadoop102 to 2 and 3 respectively.
③ Configure zoo.cfg file, in stand-alone installation, we have changed the name and modified the path of dataDir, then just add the following configuration:
#######################cluster##########################server.1=hadoop100:2888:3888server.2=hadoop101:2888:3888server.3=hadoop102:2888:3888
Sync zoo.cfg configuration file
[root@hadoop100 conf]# xsync zoo.cfg
Parameter interpretation:
server.A=B:C:D
A is a number, indicating which server this is; in cluster mode, configure a file myid, which is in the dataDir directory. There is a data in this file that is the value of A. Zookeeper reads this file when it starts, and compares the data in it with the configuration information in zoo.cfg to determine which server it is.
B is the IP address of this server.
C is the port on which this server exchanges information with the Leader server in the cluster.
D is in case the Leader server in the cluster hangs, a port is needed to re-elect and select a new Leader, and this port is the port used to communicate with each other during the election.
(3) Cluster startup
Note: Be sure to turn off the firewall
① Start ZK of three servers with the following commands:
[root@hadoop100 zookeeper-3.4.10]# bin/zkServer.sh start[root@hadoop101 zookeeper-3.4.10]# bin/zkServer.sh start[root@hadoop102 zookeeper-3.4.10]# bin/zkServer.sh start
② View status
[root@hadoop100 bin]# ./ zkServer.sh statusZooKeeper JMX enabled by defaultUsing config: /opt/dev/zookeeper-3.4.10/bin/../ conf/zoo.cfgMode: follower [root@hadoop101 bin]# ./ zkServer.sh statusZooKeeper JMX enabled by defaultUsing config: /opt/dev/zookeeper-3.4.10/bin/../ conf/zoo.cfgMode: follower [root@hadoop102 bin]# ./ zkServer.sh statusZooKeeper JMX enabled by defaultUsing config: /opt/dev/zookeeper-3.4.10/bin/../ conf/zoo.cfgMode: leader
Attachment: Client Command Line Operations
The above is how to build ZK clusters in Java shared by Xiaobian. If there is a similar doubt, please refer to the above analysis for understanding. If you want to know more about it, please pay attention to 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.