【一】 装置前环境设定
两台主机硬件环境(不用完全共同):
CPU: Xeon 3G *2 (EM64T)
MEM: 2G
NIC: Intel 1G *2
eth0: 对外IP
eth1: 对内IP(HA专用)
两台主机的eth1运用双机对联线直接衔接。
分区方法:
Filesystem 容量 挂载点
/dev/sda2 9.7G /
/dev/sda6 45G /Datas
/dev/sda1 99M /boot
none2.0G /dev/shm
/dev/sda3 9.7G /opt
别的每台主机应预留500M的raw空间或许更多来作为共用空间被HA运用。
操作体系:
RedHat Enterprise 4 Update2 (2.6.9-22 EL)
预装置软件:
@ X Window System
@ GNOME Desktop Environment
@ KDE Desktop Environment
@ Editors
@ Engineering and Scientific
@ Graphical Internet
@ Text-based Internet
@ Authoring and Publishing
@ Server Configuration Tools
@ Development Tools
@ Kernel Development
@ X Software Development
@ GNOME Software Development
@ KDE Software Development
@ Administration Tools
@ System Tools
【二】装置前网络环境设定:
node1: 主机名:servers201 ( HA01 )
eth0: 192.168.10.201 //对外IP地址
eth1: 10.0.0.201 //HA心跳运用地址
node2: 主机名:servers202 ( HA02 )
eth0: 192.168.10.202 //对外IP地址
eth1: 10.0.0.202 //HA心跳运用地址
特别注意要查看以下几个文件:
/etc/hosts
/etc/host.conf
/etc/resolv.conf
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth1
/etc/nsswitch.conf
#vi /etc/hosts
node1的hosts内容如下:
127.0.0.1 localhost.localdomain localhost
192.168.10.201 servers201 HA01
10.0.0.201 HA01
10.0.0.202 HA02
192.168.10.202 server202
node2的hosts内容如下:
127.0.0.1 localhost.localdomain localhost
192.168.10.202 servers202 HA02
10.0.0.202 HA02
10.0.0.201 HA01
192.168.10.201 server201
#cat /etc/host.conf
order hosts,bind
#cat /etc/resolv.conf
nameserver 61.139.2.69 //DNS地址
#cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=servers201 //主机名
GATEWAY=192.168.10.1 //网关
GATEWAY=eth0 //网关运用网卡
ONBOOT=YES //发动时加载
FORWARD_IPV4=yes //只允许IPV4
#cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.10.201
NETMASK=255.255.255.0
GATEWAY=192.168.10.1
TYPE=Ethernet
IPV6INIT=no
#cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
IPADDR=10.0.0.201
NETMASK=255.255.255.0
TYPE=Ethernet
[node1] 与 [node2] 在上面的装备中,除了
/etc/hosts
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth1
要各自修正外,其他共同。
装备完成后,试试在各自主机上ping对方的主机名,应该能够ping通:
/root#ping HA02
PING HA02 (10.0.0.202) 56(84) bytes of data.
64 bytes from HA02 (10.0.0.202): icmp_seq=0 ttl=64 time=0.198 ms
64 bytes from HA02 (10.0.0.202): icmp_seq=1 ttl=64 time=0.266 ms
64 bytes from HA02 (10.0.0.202): icmp_seq=2 ttl=64 time=0.148 ms
— HA02 ping statistics —
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.148/0.204/0.266/0.048 ms, pipe 2
【三】装置HA 与HA依靠包
rpm -Uvh libnet-1.1.2.1-1.rh.el.um.1.i386.rpm //能够不装
rpm -Uvh heartbeat-pils-2.0.4-1.el4.i386.rpm
rpm -Uvh heartbeat-stonith-2.0.4-1.el4.i386.rpm
rpm -Uvh heartbeat-2.0.4-1.el4.i386.rpm
rpm -Uvh ipvsadm-1.24-5.i386.rpm
【四】 装备 HA的各装备文件
装备心跳的加密方法:authkeys
#vi /etc/ha.d/authkeys
假如运用双机对联线(双绞线),能够装备如下:
#vi /etc/hc.d/authkeys
auth 1
1 crc
存盘退出,然后
#chmod 600 authkeys
装备心跳的监控:haresources
#vi /etc/ha.d/haresources
各主机这部分应完全相同。
server201 IPaddr::192.168.10.200 ipvsadm httpd
指定 server201调用ipvsadm发动http服务,体系附加一个虚拟IP 192.168.10.200 给eth0:0
这儿假如server201宕机后,server202能够主动发动http服务,并新分配IP 192.168.10.200给server202的eth0:0
装备心跳的装备文件:ha.cf
#vi /etc/ha.d/ha.cf
logfile /var/log/ha_log/ha-log.log ## ha的日志文件记载方位。如没有该目录,则需求手动增加
bcast eth1 ##运用eth1做心跳监测
keepalive 2 ##设定心跳(监测)时刻时刻为2秒
warntime 10
deadtime 30
initdead 120
hopfudge 1
udpport 694 ##运用udp端口694 进行心跳监测
auto_failback on