1. Node planning
Add eth0, eth1 two NIC on Master, backup node, add process, refer to "VMware-based CentOS 6.5 configuration two network card"
2. IP planning
  |
master |
backup |
eth0 |
192.168.46.128 |
Span style= "font-family: Song body; font-size:16px ">192.168.46.130 |
eth1 |
192.168.46.129 |
Span style= "font-family: Song body; font-size:16px ">192.168.46.131 |
The above table shows that the IP of the ETH0 network card in the master node is the IP of the 192.168.46.128,ETH1 network card is the 192.168.46.129;backup node eth0 the IP of the network card is 192.168.46.130,eth1 NIC IP is 192.168.4 6.131
3, VIP Planning (virtual IP planning)
IP Address |
Subnet mask |
Description |
192.168.46.150 |
255.255.255.0 |
192.168.46.150/24 |
192.168.46.150/24 is equivalent to IP is 192.168.46.150, subnet mask is 255.255.255.0
3. Network Card Planning
  |
master |
backup |
eth0 |
data nic |
data network card |
eth1 |
heartbeat network |
heartbeat network |
4, software planning
software |
version |
|
heartbeat |
3.0.4 |
automatically installed with Yum |
tomcat |
7.0.70 |
requires manual configuration |
5. Directory Planning
Software |
Directory |
tomcat-7.0.70 |
/etc/server |
6. Install Tomcat
The following is an example of configuring the master node
1, create the/etc/server directory, and switch to the directory, as follows
2. Get apache-tomcat-7.0.70.tar.gz connection (http://mirror.bit.edu.cn/apache/tomcat/tomcat-7/v7.0.70/bin/apache-tomcat-7.0.70.tar.gz)
3, use wget download, as follows
4, decompression apache-tomcat-7.0.70.tar.gz
5. Delete apache-tomcat-7.0.70.tar.gz and rename Tomcat
6. Same configuration on the backup node
7. Check if Tomcat on the two nodes can be accessed normally
7, installation Heartbeat
On the master node, enter "Yum install heartbeat-y" and install Heartbeat
In executing the above sentence, the following error may be reported
Workaround
1. Use the Yum list heartbeat to see if there are heartbeat in the source, as follows
2, appear above problem no matching Packages to list, may be the source is not heartbeat, by default, the system comes with the source, but the source is not heartbeat, as follows
3, can add Epel, to solve the problem, please refer to "Add Epel source for centos6.5 system"
operation on the backup node as well
8, configuration Heartbeat
1, heartbeat configuration file is in the/ETC/HA.D directory, by default, Haresources, Authkeys, ha.cf files in this directory is not, need to from/usr/share/doc/heartbeat-3.0.4/ Copy, the following is an example of operating on the master node, as follows
operation on the backup node as well
2. Configuring the Ha.cf File
The contents of the ha.cf file on the master node are as follows
debugfile/var/log/ha-debuglogfile/var/log/ha-log# specifies that the heartbeat interval is 2 seconds keepalive, specifies that if the standby node does not receive the heartbeat information number of the master node within 30 seconds, Immediately takes over the service resource of the primary node Deadtime 30# specifies a heartbeat delay of 10 seconds, and 10 seconds when the node cannot receive a heartbeat signal from the primary node, it writes a warning to the log, # but does not take over the service at this time. Until more than Deadtime still can't receive the heartbeat again take over warntime 10# initialization time is 120 seconds initdead 120udpport 694# Use network card eth1 to send heartbeat, the IP address should be the other IP address ucast eth1 192.168.46.129# If the primary node is restored, the master node will preempt the resource, and if it is off, the master node retrieves the resource Auto_failback on# the primary node name, and the uname-n display must be consistent with the node master. # The node noun must be consistent with the Uname-n display, node backup# in the standby node can not receive the primary node's heartbeat, ping the ping server first, will determine whether the network has problems ping 192.168.46.2
the ha.cf file on the backup node is essentially the same as in Mater, with the following differences
Ucast eth1 192.168.46.131
other configurations are the same as in master and are no longer given here
3, configuration Authkeys
Because the communication between the machine needs authentication, so need to configure the authentication file Authkeys, optional authentication has CRC, SHA1, MD5, here we choose CRC, not encryption authentication
Auth CRC
The Authkeys configuration in master and the backup node is the same as above
Note that there is a need to modify the Authkeys permissions to 600, as follows
4, Configuration Haresources
Master Ipaddr::192.168.46.150/24/eth0 Tomcat
The contents of the Haresources file in the master and backup nodes are the same as shown above
Parameter explanation:
Master is the host name, which will be tied to the VIP at startup
IPAddr is a script that comes with heartbeat, and then the IP is the parameters of the script.
192.168.46.150/24/eth0 This sentence means: When initializing, on the master host's ETH0 network adapter bound virtual IP (192.168.46.150), the subnet mask is 255.255.255.0
Tomcat is a script that can start and stop Tomcat by passing the Start/stop parameter, if there is more than one service to host to heartbeat, just use a space to separate it and add it later; If the service you want to host needs to take a different virtual IP, you have to configure it on a single line.
5. Write the Tomcat start-stop script
The script must be in the/ETC/INID.D or/ETC/HA.D/RESOURCE.D directory, and the script name is Tomcat, where we put it in the/ETC/HA.D/RESOURCE.D directory, as an example in the master node operation, as follows
Case $ instart)/etc/server/tomcat/bin/startup.sh;; stop)/etc/server/tomcat/bin/shutdown.sh;; *) echo "param (start|stop)" Exit 1;; Esacexit 0
Add executable permissions for the Tomcat script, as follows
9. Start Heartbeat
Enter "/etc/init.d/heartbeat start" on master, backup node respectively, start heartbeat
10, the implementation effect is as follows
If you think reading this blog gives you something to gain, you might as well " top "
If you want to find my new blog more easily, you may wish to " subscribe "
If you are interested in what my blog is talking about, please keep following my follow-up blog, I am " Liu Chao-ljc".
This article is copyrighted by the author and Csdn, welcome reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original link, otherwise reserves the right to pursue legal responsibility.
Heartbeat-based unicast for Tomcat high availability