In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "installation, configuration and high availability testing of ZooKeeper cluster". The explanation in this article is simple and clear, easy to learn and understand. Please follow the editor's train of thought to study and learn "installation, configuration and high availability testing of ZooKeeper cluster".
ZooKeeper and Dubbo service cluster architecture diagram
Server 1RV 192.168.1.81 Port: 2181, 2881, 3881
Server 2RV 192.168.1.82 Port: 2182, 2882, 3882
Server 3RV 192.168.1.83 Port: 2183, 2883, 3883
Modify the / etc/hosts file of the operating system and add the mapping of IP to hostname:
# zookeeper cluster servers
192.168.1.81 edu-zk-01
192.168.1.82 edu-zk-02
192.168.1.83 edu-zk-03
Download or upload zookeeper-3.4.6.tar.gz to the / home/wusc/zookeeper directory:
$cd / home/wusc/zookeeper
$wget http://apache.fayea.com/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
Extract the zookeeper installation package and rename the zookeeper directory by node number:
$tar-zxvf zookeeper-3.4.6.tar.gz
Server 1:
$mv zookeeper-3.4.6 node-01
Server 2:
$mv zookeeper-3.4.6 node-02
Server 3:
$mv zookeeper-3.4.6 node-03
Create the following directories under each zookeeper node directory:
$cd / home/wusc/zookeeper/node-0X (X represents node numbers 1, 2, 3, the same as below)
$mkdir data
$mkdir logs
Make a copy of the zoo_sample.cfg file in the zookeeper/node-0X/conf directory and name it zoo.cfg:
$cp zoo_sample.cfg zoo.cfg
Modify the zoo.cfg configuration file:
The configuration (/ home/wusc/zookeeper/node-01/conf/zoo.cfg) of zookeeper/node-01 is as follows:
TickTime=2000
InitLimit=10
SyncLimit=5
DataDir=/home/wusc/zookeeper/node-01/data
DataLogDir=/home/wusc/zookeeper/node-01/logs
ClientPort=2181
Server.1=edu-zk-01:2881:3881
Server.2=edu-zk-02:2882:3882
Server.3=edu-zk-03:2883:3883
The configuration (/ home/wusc/zookeeper/node-02/conf/zoo.cfg) of zookeeper/node-02 is as follows:
TickTime=2000
InitLimit=10
SyncLimit=5
DataDir=/home/wusc/zookeeper/node-02/data
DataLogDir=/home/wusc/zookeeper/node-02/logs
ClientPort=2182
Server.1=edu-zk-01:2881:3881
Server.2=edu-zk-02:2882:3882
Server.3=edu-zk-03:2883:3883
The configuration (/ home/wusc/zookeeper/node-03/conf/zoo.cfg) of zookeeper/node-03 is as follows:
TickTime=2000
InitLimit=10
SyncLimit=5
DataDir=/home/wusc/zookeeper/node-03/data
DataLogDir=/home/wusc/zookeeper/node-03/logs
ClientPort=2183
Server.1=edu-zk-01:2881:3881
Server.2=edu-zk-02:2882:3882
Server.3=edu-zk-03:2883:3883
Parameter description:
TickTime=2000
TickTime is used as the interval between Zookeeper servers or between clients and servers to maintain a heartbeat, that is, a heartbeat is sent at each tickTime time.
InitLimit=10
InitLimit is used to configure the Zookeeper accept client (the client here is not the client that the user connects to the Zookeeper server, but the Follower server in the Zookeeper server cluster that connects to the Leader) the maximum number of heartbeat intervals that can be tolerated when initializing the connection. When the Zookeeper server has not received a return message from the client after the length of more than 10 heartbeats (that is, tickTime), the client connection failed. The total length of time is 10 "2000" 20 seconds.
SyncLimit=5
SyncLimit this configuration item identifies the length of time for sending messages, requests and replies between Leader and Follower. The maximum length of time cannot exceed the number of tickTime. The total length of time is 5, 000, 000, 10 seconds.
DataDir=/home/wusc/zookeeper/node-01/data
DataDir, as its name implies, is the directory where Zookeeper saves the data, and by default Zookeeper keeps the log files for writing data in this directory.
ClientPort=2181
ClientPort port is the port through which the client (application) connects to the Zookeeper server, and Zookeeper listens to this port to accept client access requests.
Server.A=B:C:D
Server.1=edu-zk-01:2881:3881
Server.2=edu-zk-02:2882:3882
Server.3=edu-zk-03:2883:3883
An is a number indicating which server this is.
B is the IP address of this server (or the hostname mapped to the IP address)
C the first port is used to exchange information among cluster members, indicating the port on which the server exchanges information with the Leader servers in the cluster.
D is the port used specifically to elect leader when the leader is hung up.
Note: if it is a pseudo-cluster configuration, the communication port numbers of different Zookeeper instances cannot be the same, so assign them different port numbers.
Create a myid file under dataDir=/home/wusc/zookeeper/node-0X/data
Edit the myid file and enter the corresponding number on the corresponding IP machine. For example, on node-01, the content of the myid file is 1, the content of the file is 2, and the content of the file is 3:
$vi / home/wusc/zookeeper/node-01/data/myid # # value is 1
$vi / home/wusc/zookeeper/node-02/data/myid # # value is 2
$vi / home/wusc/zookeeper/node-03/data/myid # # value is 3
Open ports 218X, 288X, 388X to be used in the firewall
Switch to the root user rights and execute the following command:
# chkconfig iptables on
# service iptables start
Edit / etc/sysconfig/iptables
# vi / etc/sysconfig/iptables
If server 01 adds the following 3 lines:
# # zookeeper
-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 2181-j ACCEPT
-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 2881-j ACCEPT
-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 3881-j ACCEPT
Restart the firewall:
# service iptables restart
View firewall port status:
# service iptables status
Start and test zookeeper (to start with the wusc user, not root):
Use the wusc user to execute in the / home/wusc/zookeeper/node-0X/bin directory:
$/ home/wusc/zookeeper/node-01/bin/zkServer.sh start
$/ home/wusc/zookeeper/node-02/bin/zkServer.sh start
$/ home/wusc/zookeeper/node-03/bin/zkServer.sh start
Enter the jps command to view the process:
$jps
1456 QuorumPeerMain
Where QuorumPeerMain is a zookeeper process, which means the startup is normal.
View status:
$/ home/wusc/zookeeper/node-01/bin/zkServer.sh status
View the zookeeper service output information:
Because the service information output file is in / home/wusc/zookeeper/node-0X/bin/zookeeper.out
$tail-500f zookeeper.out
Stop the zookeeper process:
$zkServer.sh stop
Configure zookeeper to boot using wusc user startup:
Edit the / etc/rc.local file in node-01, node-02, node-03, and add:
Su-wusc-c'/ home/wusc/zookeeper/node-01/bin/zkServer.sh start'
Su-wusc-c'/ home/wusc/zookeeper/node-02/bin/zkServer.sh start'
Su-wusc-c'/ home/wusc/zookeeper/node-03/bin/zkServer.sh start'
2. Install the Dubbo console (the basic part is about how to link the console to the cluster):
The Dubbo console can manage services or service consumers registered with the zookeeper registry, but whether the console is normal or not has no impact on Dubbo services, and the console does not need to be highly available, so it can be deployed with a single node.
IP: 192.168.1.81
Deployment container: Tomcat7
Port: 8080
Download (or upload) the latest version of Tomcat7 (apache-tomcat-7.0.57.tar.gz) to / home/wusc/
Decompress:
$tar-zxvf apache-tomcat-7.0.57.tar.gz
$mv apache-tomcat-7.0.57 dubbo-admin-tomcat
Remove all files in the / home/wusc/dubbo-admin-tomcat/webapps directory:
$rm-rf *
Upload the Dubbo management console program dubbo-admin-2.5.3.war
To / home/wusc/dubbo-admin-tomcat/webapps
Extract and name the directory ROOT:
$unzip dubbo-admin-2.5.3.war-d ROOT
Move dubbo-admin-2.5.3.war to the / home/wusc/tools directory for backup
$mv dubbo-admin-2.5.3.war / home/wusc/tools
Configure dubbo.properties:
$vi ROOT/WEB-INF/dubbo.properties
Dubbo.registry.address= zookeeper://192.168.1.81:2181?backup=192.168.1.82:2182192.168.1.83:2183
Dubbo.admin.root.password=wusc.123
Dubbo.admin.guest.password=wusc.123
(the above password should be modified before formal production)
Firewall opens port 8080, modify / etc/sysconfig/iptables with root user
# vi / etc/sysconfig/iptables
Add:
# # dubbo-admin-tomcat:8080
-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 8080-j ACCEPT
Restart the firewall:
# service iptables restart
Start Tomat7
$/ home/wusc/dubbo-admin-tomcat/bin/startup.sh
Thank you for reading, the above is the content of "installation, configuration and High availability testing of ZooKeeper Cluster". After the study of this article, I believe you have a deeper understanding of the installation, configuration and high availability testing of ZooKeeper cluster, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.