default=1 timeout=10 splashimage=(hd0,0)/boot/grub/splash.xpm.gz title Red Hat Linux (2.4.20-19.8custom) root (hd0,0) kernel /boot/vmlinuz-2.4.20-19.8custom ro root=LABEL=/ initrd /boot/initrd-2.4.20-19.8custom.img title Red Hat Linux (2.4.20-18.8bigmem) root (hd0,0) kernel /boot/vmlinuz-2.4.20-18.8bigmem ro root=LABEL=/ initrd /boot/initrd-2.4.20-18.8bigmem.img title Red Hat Linux-smp (2.4.18-14smp) root (hd0,0) kernel /boot/vmlinuz-2.4.18-14smp ro root=LABEL=/ initrd /boot/initrd-2.4.18-14smp.img title Red Hat Linux-up (2.4.18-14) root (hd0,0) kernel /boot/vmlinuz-2.4.18-14 ro root=LABEL=/ initrd /boot/initrd-2.4.18-14.img
11、重新开机(shutdown -i 6 now)
12、选择linux_new(lilo)或Red Hat Linux (2.4.20-19.8custom)开机,看看开机过程有没有错误发生。然后检查/proc/sys/net/ipv4/conf/all/hidden是不是存在?
13、如果都没有错误,安装下列rpm
rpm -ivh ipvsadm-1.21-4.i386.rpm
14、试验一下 输入:
[root@nbaa boot]# ipvsadm IP Virtual Server version 1.0.9 (size=65536) Prot LocalAddressort Scheduler Flags -> RemoteAddressort Forward Weight ActiveConn InActConn
出现上面画面就是成功啦!!!
15、后续的动作就依照你的网络状态,去作规划了,后续进行中。
PART II:LVS设定
系统架构
一、简易设定:
1、IP Tunnel的设定:
Load Balance : 10.144.43.175(nb804 Real Server:10.144.43.142(linux142)、10.144.43.187(linux187) Virtual IP :10.144.43.185(VIP)
Nb8048上面的设定:
1、先建立一个Subinterface
# ifconfig eth0:0 10.144.43.185 netmask 255.255.255.255 broadcast || 10.144.43.185 up
2、建立IP Tunnel的Rule
2.1、先打开IP Forwarding
# echo 1 > /proc/sys/net/ipv4/ip_forward
2.2、建立IP Tunnel的Rule,先建立Service
# ipvsadm -A -t 10.144.43.185:23 -s wlc
2.3、加入两台Real Server的IP
# ipvsadm -a -t 10.144.43.185:23 -r 10.144.43.187 -i # ipvsadm -a -t 10.144.43.185:23 -r 10.144.43.142 -i
#!/usr/bin/perl # # lvs.alert - Linux Virtual Server alert for mon # # It can be activated 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:V:R:W:F:u"; $ipvsadm = "/sbin/ipvsadm"; $protocol = $opt_P; $virtual_services = $opt_V; $remote = $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"; }
o Web servers o LVS director servers o Mail servers o Database servers o Firewalls o File servers o DNS servers o DHCP servers o Proxy Caching servers o etc.
我们这里的重点是要做LVS Director Servers的Failover机制,也就是要做HA(High availability)架构。所以对于heartbeat-ldirectord这个套件不作介绍,有兴趣的人请自行研究(一文。
#!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if you don't # want to do the full Sys V style init stuff.
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost 10.144.43.142 linux142 10.144.43.187 Linux187 10.144.43.175 nb8048
4.3、修改/etc/ha.d/authkeys内容如下:
auth 1 1 sha1 doss123
其中doss123为重要的key。然后 # chmod 600 authkeys
4.4、修改/etc/ha.d/ha.cf内容如下:
logfacility local0 # 使用syslogd keepalive 2 # 每隔几秒送一次heartbeat讯号 deadtime 40 # 多长时间就认定Primary Server Dead initdead 240 # hopfudge maximum hop count minus number of nodes in config nice_failback on # 如果Service转移到Secondary,就不要再转移回Primary hopfudge 1 # ??? udpport 1001 # 使用哪一个udp port ucast eth0 10.144.43.142 # Primary用unicast送给Secondary,如果在 Secondary则送给Primary node Linux187 # 给定cluster中的节点 node linux142 # 给定cluster中的节点
# # On Linux the Alias is named ethx:y # This will remove the "extra" interface Data # leaving us with just ethx # case $SYSTYPE in *BSD) IFEXTRA="" ;; *) IFEXTRA=`echo " $ifinfo" | cut -f2-` ;; esac
#!/usr/bin/perl # heartbeat.alert - Linux Virtual Server alert for mon # # It can be activated 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("u"; $service ="/sbin/service"; $u = $opt_u; if( $opt_u){ # 重新激活heartbeat服务 system(" $service heartbeat restart"; }else{ # 停止lvs server system("/etc/init.d/lvs stop"; }