First, use background
The project needs to realize the function of automatic switchover between main and standby dual heat to ensure that the system runs continuously 7*24 hours; now there is Two IBM servers with dual network cards, in order not to increase the cost of purchasing independent external storage devices and dual-system hot backup software, use the open source HA software under Linux for deployment, that is, the heartbeat+monit method.
1. Use heartbeat for heartbeat monitoring and resource takeover. Heartbeat monitoring can be performed through network links and serial ports. Network links are used here, and redundant links are supported. They send reports to each other. The text tells the other party their current status. If the message sent by the other party is not received within the specified time, then the other party is considered invalid. At this time, the resource takeover module needs to be activated to take over the resources or services running on the other party’s host.
2. Use monit to monitor and restart the application service process. Monit is a very versatile process, file, directory and device monitoring software for Unix platforms. It can automatically repair those programs that have stopped functioning, and the special envoy is suitable for handling software errors caused by a variety of reasons.
3. Improvement points: Since there is no shared storage device to store data and application services, it is necessary to use DRBD to synchronize data between the two servers, that is, data mirroring. Due to time constraints, there is no time to study the mirroring technology of DRBD, so follow-up considerations will be added.
4. The application program of the project is divided into three independent processes: data collection process, data processing process, and data communication service process. These three processes are managed in a Linux service mode, namely: servicemyprocess start this way
Use HeartBeat+Monit to implement a main and standby dual hot backup system
3. System topology diagram and expression (as shown above)
The eth0 network card in the two servers is used for external communication, and the eth1 network card is used for heartbeat detection.
OS: ubunt12.04
VIP virtual IP: 192.168.134
Master node:
Eth0: IP (external network) : 192.168.1.132
Eth1: IP (intranet): 192.168.2.2
Standby node:
Eth0: IP (external network): 192.168.1.133
Eth1: IP (Intranet): 192.168.2.3
————————————– Dividing line—————————— ——–
Based on Heartbeat V1 to realize web service dual-system hot backup http://www.linuxidc.com/Linux/2014-04/100635.htm
Heartbeat to realize web service High-availability cluster http://www.linuxidc.com/Linux/2014-04/99503.htm
Heartbeat+LVS+Ldirectord high-availability load balancing solution http://www.linuxidc.com /Linux/2014-04/99502.htm
DRBD+Heartbeat+NFS high availability configuration notes http://www.linuxidc.com/Linux/2014-04/99501.htm
< p>Heartbeat is highly available for MySQL based on CRM and using NFS http://www.linuxidc.com/Linux/2014-03/98674.htm
Heartbeat is highly available httpd based on Resources simple configuration http://www .linuxidc.com/Linux/2014-03/98672.htm
————————————– Dividing line————————————–< /p>
Second, install monit
1. Because heartbeat is only responsible for the function of heartbeat and communication between the two servers, it cannot automatically restart when its service process hangs. Because I am more familiar with monit, I used monit to monitor the service process and used it in conjunction with heartbeat. In fact, other methods, such as mon, can also be used.
Sudo apt-getinstall monit
2, edit the monit startup script, location: /etc/init.d/monit, add your own process (red font part), its role is to When heartbeat is switching, you can stop the application service on the current server, and start the application service program on the standby server after the switch is completed (because there is no soft mirroring and no shared storage, application services and data have one on each of the two servers. This can be done in my use scenario)
………
stop) log_daemon_msg "Stopping $ DESC""$NAME" if start-stop-daemon --retry TERM/< span class="hljs-number">5/KILL/5--oknodo --stop --quiet \ --pidfile $PID --exec $DAEMON then log_end_msg 0 else log_end_msg < span class="hljs-number">1 fi########### ###################### #Add the service process to be monitored here service DataCollection stop service DataProcss stop service RsServer stop ################################ ;; reload) …………….
3. Edit /etc/monit/monitrc configuration file, you can refer to more information in this area on the Internet, add the process you need to monitor in it, and finally modify the edited monitrc file permissions to 700
………… ……
Process configuration to be monitored
##### ####Start checkDataCollection######################## ## check process DataCollection with pidfile/tmp/kd_data_collection_filename.pid start program ="/etc/init.d/DataCollection start" stop program ="/etc/init.d/DataCollection stop" #########End checkDataCollect ion###################################Start checkDataProcss#### #################< span class="hljs-comment">##### check process DataProcss with pidfile/tmp/kd_data_process_filename.pid start program ="/etc/init.d/DataProcss start" stop program ="/etc/init.d/ DataProcss stop" #########End checkDataProcss###### span>#############################Start checkRsServer#####################< /span>##### check process RsServer with pidfile/tmp/kd_data_server_filename.pid start program = "/etc/init.d/RsServerstart" stop program = "/etc/init .d/RsServerstop" #########End checkRsServer###### ########################## ##########Startcheck heartbeat#####################< /span># check process heartbeat with pidfile/var< /span>/run/heartbeat.pid start program ="/etc/init.d/heartbeat start" stop program = "/etc/init.d/heartbeatstop" ############ ####Endcheck heartbeat###############< /span>############### ###############< /span>##############################< /span>##############################< /span>#### ## Includes ############################## ############################## ################### ## ## It is possible to include additional configuration parts from other files or ## directories. # include /etc/monit/conf.d/* #. ………………
A screenshot of the installed monit management process through the web method:
Three, install heartbeat
Sudo apt-get install heartbeat
Edit the following three files:
ha.cf The main configuration file, most of the configuration information is in this file
haresources Resource configuration file
authkeys permission configuration]
1, ha.cf configuration
logfile /var/log/ha-loglogfacility local0keepalive 2deadtime 30warntime 10initdead 120udpport 694bcast eth1 #Linuxauto_failback onnode UbuntuAnode ubuntuBping 192.168.1 .1 2, haresources…………ubuntuA192.168.1.134 monit#node-nameresource1 resource2 ... resourceN…………3, authkeysauth 11 crc#2 sha1 HI!#3 md5 Hello!
Put the above Copy the three configuration files to the /etc/ha.d directory on the primary and standby servers respectively, and change the authkeys permissions to 600
Start heartbeat on the primary and standby servers respectively, and you can Check the log through tail -f /var/log/ha-log for testing
http://www.linuxidc.com/Linux/2014-12/110769.htm
1. Use background
The project needs to realize the function of automatic switchover between main and standby dual heat to ensure the uninterrupted operation of the system 7*24 hours; there are now two dual The network card of the IBM server, in order to no longer increase the cost of purchasing independent external storage devices and dual-system hot backup software, adopts the open source HA software under Linux for deployment, that is, the heartbeat+monit method.
1. Use heartbeat for heartbeat monitoring and resource takeover. Heartbeat monitoring can be performed through network links and serial ports. Network links are used here, and redundant links are supported. They send reports to each other. The text tells the other party their current status. If the message sent by the other party is not received within the specified time, then the other party is considered invalid. At this time, the resource takeover module needs to be activated to take over the resources or services running on the other party’s host.
2. Use monit to monitor and restart the application service process. Monit is a very versatile process, file, directory and device monitoring software for Unix platforms. It can automatically repair those programs that have stopped functioning, and the special envoy is suitable for handling software errors caused by a variety of reasons.
3. Improvement points: Since there is no shared storage device to store data and application services, it is necessary to use DRBD to synchronize data between the two servers, that is, data mirroring. Due to time constraints, there is no time to study the mirroring technology of DRBD, so follow-up considerations will be added.
4. The application program of the project is divided into three independent processes: data collection process, data processing process, and data communication service process. These three processes are managed in a Linux service mode, namely: servicemyprocess start this way
Use HeartBeat+Monit to implement a main and standby dual hot backup system
3. System topology diagram and expression (as shown above)
The eth0 network card in the two servers is used for external communication, and the eth1 network card is used for heartbeat detection.
OS: ubunt12.04
VIP virtual IP: 192.168.134
Master node:
Eth0: IP (external network) : 192.168.1.132
Eth1: IP (intranet): 192.168.2.2
Standby node:
Eth0: IP (external network): 192.168.1.133
Eth1: IP (Intranet): 192.168.2.3
————————————– Dividing line—————————— ——–
Based on Heartbeat V1 to realize web service dual-system hot backup http://www.linuxidc.com/Linux/2014-04/100635.htm
Heartbeat to realize web service High-availability cluster http://www.linuxidc.com/Linux/2014-04/99503.htm
Heartbeat+LVS+Ldirectord high-availability load balancing solution http://www.linuxidc.com /Linux/2014-04/99502.htm
DRBD+Heartbeat+NFS high availability configuration notes http://www.linuxidc.com/Linux/2014-04/99501.htm
< p>Heartbeat is highly available for MySQL based on CRM and using NFS http://www.linuxidc.com/Linux/2014-03/98674.htm
Heartbeat is highly available httpd based on Resources simple configuration http://www .linuxidc.com/Linux/2014-03/98672.htm
————————————– Dividing line————————————–< /p>
Second, install monit
1. Because heartbeat is only responsible for the function of heartbeat and communication between the two servers, it cannot automatically restart when its service process hangs. Because I am more familiar with monit, I used monit to monitor the service process and used it in conjunction with heartbeat. In fact, other methods, such as mon, can also be used.
Sudo apt-getinstall monit
2, edit the monit startup script, location: /etc/init.d/monit, add your own process (red font part), its role is to When heartbeat is switching, you can stop the application service on the current server, and start the application service program on the standby server after the switch is completed (because there is no soft mirroring and no shared storage, application services and data have one on each of the two servers. This can be done in my use scenario)
………
stop) log_daemon_msg "Stopping $ DESC""$NAME" if start-stop-daemon --retry TERM/< span class="hljs-number">5/KILL/5--oknodo --stop --quiet \ --pidfile $PID --exec $DAEMON then log_end_msg 0 else log_end_msg < span class="hljs-number">1 fi########### #################### ## #Add the service process to be monitored here service DataCollection stop service DataProcss stop service RsServer stop ######################## ######## ;; reload) …………….
3. Edit /etc/monit /monitrc configuration file, you can refer to more information in this area on the Internet, add the processes you need to monitor in it, and finally modify the permissions of the edited monitrc file to 700
………………
p>
Process configuration to be monitored
#########Start checkDataCollection########################## check process DataCollection with pidfile/tmp/kd_data_collection_filename.pid start program ="/etc/init.d/DataCollection start" stop program ="/etc/init.d/DataCollection stop" #########End checkDataCollection############## #####################Start checkDataProcss####### ################### check process DataProcss with pidfile/tmp/kd_data_process_filename.pid start program ="/etc/init.d/DataProcss start" stop program ="/etc/init.d/DataProcss stop" #########End checkDataProcss######< span class="hljs-comment">############# ################Start checkRsServer###### #################### check process RsServer with pidfile/tmp/kd_data_server_filename.pid start program = "/etc/init.d/RsServerstart" stop program = "/etc/init.d/RsServerstop" # ########End checkRsServer#################### ######################Startcheck heartbeat###### ################ check process heartbeat with pidfile/var/run/ heartbeat.pid start program ="/etc/init.d/heartbeat start" stop program = "/etc/init.d/heartbeatstop"############### #Endcheck heartbeat############### ############ ### ############### ############ ################## ############ ################## #### ## Includes ################################# span>############################## span>################ ## ## It is possible to include additional configuration parts from other files or ## directories. # include /etc/monit/conf.d/* #. ………………< /pre> A screenshot of the installed monit management process through the web method:
Three, install heartbeat
Sudo apt-get install heartbeat
< p>Edit the following three files: ha.cf The main configuration file, most of the configuration information is in this file
haresources resource configuration file
< br /> authkeys permission configuration]
1, ha.cf configuration
logfile /var/ log/ha-loglogfacility local0keepalive 2 deadtime 30warntime 10initdead 120udpport < span class="hljs-number">694
bcast eth1 #Linuxauto_failback onnode UbuntuAnode ubuntuBping 192.168.1.1 2, haresources…………ubuntuA192.168.1 span>.134 monit#node-nameresource1 resourc e2 ... resourceN…………3, authkeysauth 11 crc#2 sha1 HI! #3 md5 Hello!
Compose the above three configurations Copy the files to the /etc/ha.d directory on the primary and standby servers respectively, and change the authkeys permission to 600
Start heartbeat on the primary and standby servers separately, you can use tail -f /var/log/ha-log View the log and test it
http://www.linuxidc.com/Linux/2014-12/110769.htm