Second, the advancement setting:
After reading the settings, if you have a successful test, you will find what if Real Server is dead. The DR responsible for the transfer package does not know that Real Server has failed, or will send the package to the fault REAL Server, which affects the user's rights, and has several solutions on the official website of the LVS, and I have installed Piranha (method) and "Mon, Heartbeat, Fake, Coda" method, found that Piranha-GUI needs Apache 1.3 RPM file, and the PHP module is also installed above, but Redhat 8.0 presets only Apache 2.0 .40 (httpd-2.0.40), so I can't install it when I install Piranha-gui, I also tried to install Apache 1.3, but there is another need to install a pile of no RPM, so I decided Abandon No Piranha is used to use "Mon, Heartbeat, Fake, Coda" (http://www.linuxvirtualserver.org/highavailability.html) solution.
So because I only have three machines, and only one thing to be Director, so hearbeat, fake is not needed for me, and my file doesn't need to be put in the same place, so CODA is for me. It is not used, and finally I only need to install MON this service (daemon).
Mon's official website, at http://www.kernel.org/software/mon/, interested in see. Not much nonsense, start installation.
1, installation service
The installation can be installed with Tarball or RPM, but because Tarball installation needs to spend more time, in order to save time, all RPM installations are used, and only the Perl-Mon module is installed with Tarball installation.
2, download the source code
First, go to http://rpmfind.net to search for the following files, where MON-0.11.TAR.GZ is arrested from the official website of Mon.
FPING-2.2B1-2.I386.rpm ----------------------- can be pulled once multiple IPs
Perl-convert-Ber-1.31-3.i386.rpm ---------- Perl Convert :: Ber Module
Perl-net-telnet-3.01-9.i386.rpm -------------- Perl Net :: Telnet Module
Mon-0.11.tar.gz -------------------------------- Perl Mon Module
Perl-period-1.20-9.i386.rpm ----------------- Perl Period Module
Mon-0.99.2-8.i386.rpm ------------------------ Mon daemon rpm
then
# rpm -ivh fping-2.2b1-2.i386.rpm
# rpm -ivh perl-convert-Ber-1.31-3.i386.rpm
# rpm -ivh perl-net-telnet-3.01-9.i386.rpm
# rpm -ivh perl-period-1.20-9.i386.rpm
# gzip -dc mon-0.11.tar.gz | TAR XVF -
# CD MON-0.11
# Perl makefile.pl && make && make test && make install # cd ..
# rpm -ivh -nodeps mon-0.99.2-8.i386.rpm
Check if there is MON daemon with chkconfig -list mon.
3, so that this is installed, then the MON is set.
3.1, configure MON
Mon's setting file is placed in /etc/mon/mon.cf, and in our example, you need to write a (lvs.alert) program for LVS. This program is mainly used to add ROUTING RULE that removes Director, as in the basic configuration (this time the Director is changed to 10.144.43.142 this machine), our setting:
IPvsadm -a -t 10.144.43.185:23 -s rr
IPvsadm -a -t 10.144.43.185:23 -r 10.144.43.175 -g
IPvsadm -a -t 10.144.43.185: 23 -R 10.144.43.142 -g
IPvsadm -a -t 10.144.43.185: 23 -R 10.144.43.187 -g
Now suppose 10.144.43.175 network disconnection, or machine can't work properly, this time MON DAEMON will automatically call lvs.alert,
IPVSADM -D -T 10.144.43.185: 23 -r 10.144.43.175
Take this, then continue to monitor until 10.144.43.175 works normally, then call lvs.Alart to add 10.144.43.175 to ROUTE.
#! / usr / bin / perl
#
# lvs.alert - Linux Virtual Server Alert for Mon
#
# It can be actid by mon to remove a real server when the
# Service is down, or add the server when the service is up
#
#
Use getopt :: std;
Getopts ("s: g: h: t: l: p: v: r: w: f: u");
$ IPVSADM = "/ sbin / ipvsadm";
$ protocol = $ OPT_P;
$ Virtual_Services = $ OPT_V;
$ transote = $ OPT_R;
IF ($ OPT_U) {
$ weight = $ OPT_W;
IF ($ OPT_F EQ "NAT") {
$ forwarding = "-m";
} Elsif ($ OPT_F EQ "Tun") {
$ forwarding = "-i";
} else {
$ forwarding = "-g";
}
IF ($ Protocol EQ "TCP") {
SYSTEM
"$ IPVSADM-A -T $ Virtual_Services -R $ Remote -w $ Weight $ Forwarding");
} else {
SYSTEM
"$ IPVSADM -A -U $ VIRTUAL_SERVICES -R $ Remote -w $ Weight $ Forwarding");
}
} else {
IF ($ Protocol EQ "TCP") {
System ("$ IPVSADM -D -T $ Virtual_Services -R $ Remote");} else {
System ("$ IPVSADM -D -U $ VIRTUAL_SERVICES -R $ Remote");
}
}
3.2, Mon daem setting
Because I am using Telnet's service as test example, the system I really online will be the Web Server monitoring, so the following settings are only for Telnet to set, requiring other services, and please go Look at some of MON's settings, this is just briefly explaining the meaning of the following.
#
# Extremely Basic Mon.cf file
# In addition to lvs.alert, it can also send email, but I took him away.
# Because my Server does not activate Sendmail .. :)
# Global Options
#
Cfbasedir = / etc / mon
pidfile = /VAR/run/mon.pid
StateDir = /VAR/Run/mon/state.d
Logdir = /VAR/Run/mon/log.d
Dtlogfile = /VAR/run/mon/log.d/downtime.log
Alertdir = /usr/lib/mon/alert.d
Mondir = /usr/lib/mon/mon.d
MAXPROCS = 20
Histlength = 100
Randstart = 60S
Authtype = Userfile
Userfile = / etc / mon / userfile
#
# Group definitions (Hostnames or IP Addresses)
# To monitor the machine, one can be more
# In order to reduce trouble, and I don't have much equipment, so I set a group only a server.
Hostgroup Server1 10.144.43.175
Hostgroup Server2 10.144.43.187
# 监 监 10.144.43.175
Watch Server1
# The name of the TELNET behind the service is not the name of / etc / services, not
Service telnet
# Test once the interval, which sets 20 seconds, or sets 10M, 1H.
Interval 20S
# Which Monitor program is used to do, basically Telnet.monitor is a process written with Perl.
# So if you have your own Monitor program, you can also apply it.
Monitor telnet.monitor
# # 监 时间
Period WD {MON-FRI} HR {7 AM-10PM}
# Alert: When you have a connection failure, you will call this Event, and the LVS.Alert program is executed.
Alert lvs.alert -P TCP -V 10.144.43.185:23 -R 10.144.43.175 -W 5 -F DR
# UPLAERT: When the online failed, I found that the other party lives, I will call this Event.
Upalert lvs.alert -P TCP -V 10.144.43.185:23 -R 10.144.43.175 -W 5 -F DR -U 1
Watch Server2
Service telnet
Interval 20S
Monitor telnet.monitor
Period WD {Mon-Fri} HR {7 AM-10PM} alert lvs.alert -P TCP -V 10.144.43.185:23 -r 10.144.43.187 -w 5 -f DR
Upalert lvs.alert -P TCP -V 10.144.43.185:23 -R 10.144.43.187 -W 5 -F DR -U 1
# See / usr / doc for the Original Example ...
3.3 After the modification is complete, you can use Service Mon Start to activate MON DAEMON to monitor.
4, you can do some tests yourself, for example, unplug the network cable, turn off the service on the RealServer, and there is a problem. (Call! Finally, you can explain the boss. ^ _ ^)