1
2
3
4
5
|
[root@web1 ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.200.132 web1.daphne.com web1
192.168.200.133 web2.daphne.com web2
|
1
|
[root@web1 ~]# ntpdate ntp.api.bz
|
1
2
3
4
|
[root@web1 ~]# ssh-keygen -t rsa -f ~/.ssh/id_rsa -P
''
[root@web1 ~]# ssh-copy-id -i .ssh/id_rsa.pub root@web2.daphne.com
[root@web1 ~]# ssh web2
[root@web2 ~]#
|
1
|
|
1
2
3
4
|
[root@web2 ~]# ssh-keygen -t rsa -f ~/.ssh/id_rsa -P
''
[root@web2 ~]# ssh-copy-id -i .ssh/id_rsa.pub root@web1.daphne.com
[root@web2 ~]# ssh web1
[root@web2 ~]#
|
- heartbeat 核心组件
- heartbeat-gui 图形管理接口
- heartbeat-ldirectord 为lvs高可用提供规则自动生成及后端realserver健康状态检查组件
- heartbeat-pils 装载库插件接口
- heartbeat-stonith
1
2
3
4
|
yum install PyXML libnet pygtk2-libglade net-snmp-libs
yum install libtool-ltd( 注 要从源库安装 ,不可以epel)
lyum install libnet
rpm -ivh heartbeat-*
|
1
2
3
4
5
|
[root@web1 ~]# yum install httpd
[root@web1 ~]# cd /
var
/www/html/
[root@web1 html]# vim index.html
web1
[root@web1 ~]# service httpd start
|
1
2
3
4
|
[root@web1 ~]# serivce httpd off
[root@web1 ~]# chkconfig httpd of
[root@web1 ~]# chkconfig --list httpd
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
|
1
2
3
4
|
[root@web1 ~]# cd /etc/ha.d/
[root@web1 ha.d]# ls
authkeys harc rc.d resource.d
ha.cf haresources README.config shellfuncs
|
1
2
3
4
5
6
7
8
9
|
[root@web1 ha.d]# cd /usr/share/doc/heartbeat-2.1.4/
[root@web1 heartbeat-2.1.4]# ls
apphbd.cf faqntips.html haresources Requirements.html
authkeys faqntips.txt hb_report.html Requirements.txt
AUTHORS GettingStarted.html hb_report.txt rsync.html
ChangeLog GettingStarted.txt heartbeat_api.html rsync.txt
COPYING ha.cf heartbeat_api.txt startstop
COPYING.LGPL HardwareGuide.html logd.cf
DirectoryMap.txt HardwareGuide.txt README
|
1
|
<font face=
"微软雅黑"
>我们需要 authkeys ha.cf haresources 三个配置文件</font>
|
1
|
[root@web1 heartbeat-2.1.4]# cp authkeys ha.cf haresources /etc/ha.d/
|
1
2
3
4
5
6
7
8
|
[root@web1 ha.d]# openssl rand -hex 8 >> authkeys
[root@web1 ha.d]# vim authkeys
auth 2
#1 crc
#2 sha1 HI!
#3 md5 Hello!
2 sha1 7c0f241959ee845d
[root@web1 ha.d]# chmod 600 authkeys
|
1
|
[root@web1 ha.d]# vim ha.cf
|
1
|
bcast eth0
|
1
2
|
node web1.daphne.com
node web2.daphne.com
|
1
2
|
[root@web1 ha.d]# vim haresources
web1.daphne.com 192.168.200.10/24/eth0 httpd
|
1
|
[root@web1 ha.d]# scp authkeys ha.cf haresources web2:/etc/ha.d/
|
1
2
|
[root@web2 ~]# service heartbeat start
[root@web1 ~]# service heartbeat start
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
[root@web1 ha.d]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:7D:C1:D7
inet addr:192.168.200.132 Bcast:192.168.200.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe7d:c1d7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9069 errors:0 dropped:0 overruns:0 frame:0
TX packets:9159 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1707993 (1.6 MiB) TX bytes:1846141 (1.7 MiB)
eth0:0 Link encap:Ethernet HWaddr 00:0C:29:7D:C1:D7
inet addr:192.168.200.10 Bcast:192.168.200.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
|
1
|
<a target=
"\"_blank\""
href=
"http://img1.51cto.com/attachment/201407/6/158322_14046367318BZw.png"
><img onload=
"if(this.width>650) this.width=650;"
style=
"background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; border-top: 0px; border-right: 0px; padding-top: 0px"
title=
"image_thumb12"
border=
"0"
alt=
"image_thumb12"
src=
"http://img1.51cto.com/attachment/201407/6/158322_1404636731GD3u.png"
"861"
=
""
height=
"131"
onabort=
""
onblur=
""
onchange=
""
onclick=
""
ondblclick=
""
onerror=
""
onfocus=
""
onkeydown=
""
onkeypress=
""
onkeyup=
""
onmousedown=
""
onmousemove=
""
onmouseout=
""
onmouseover=
""
onmouseup=
""
onreset=
""
onresize=
""
onselect=
""
onsubmit=
""
onunload=
""
width=
"650"
></a>
|
1
|
|
1
|
<font face=
"微软雅黑"
>故障演示</font>
|
1
|
<font face=
"微软雅黑"
>关闭web1上的heartbeat</font>
|
1
2
3
|
[root@web1 ~]# service heartbeat stop
Stopping High-Availability services:
Done.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:61:E4:6B
inet addr:192.168.200.133 Bcast:192.168.200.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe61:e46b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8230 errors:0 dropped:0 overruns:0 frame:0
TX packets:8164 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1698974 (1.6 MiB) TX bytes:1680369 (1.6 MiB)
eth0:0 Link encap:Ethernet HWaddr 00:0C:29:61:E4:6B
inet addr:192.168.200.10 Bcast:192.168.200.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
|
1
|
|
1
2
3
4
5
6
7
8
9
10
|
[root@bogon ~]# yum install nfs*
[root@bogon ~]# mkdir -pv /web/html/
[root@bogon ~]# vim /web/html/index.html
[root@bogon ~]# vim /etc/exports
/web/html/ 192.168.200.0/24(rw,async)
[root@bogon ~]# service rpcbind start
[root@bogon ~]# service nfs start
|
1
2
3
4
5
|
[root@web1 ~]# mount -t nfs 192.168.200.138:/web/html /mnt
[root@web1 ~]# cd /mnt
[root@web1 mnt]# ls
index.html
[root@web1 ~]# umount /mnt
|
1
2
|
[root@web1 ha.d]# vim /etc/ha.d/haresources
web1.daphne.com 192.168.200.10/24/eth0 Filesystem::192.168.200.138:/web/html::/
var
/www/html::nfs httpd
|
1
2
|
[root@web1 ha.d]# cd /etc/ha.d/
[root@web1 ha.d]# scp haresources web2:/etc/ha.d/
|
1
2
|
[root@web2 ~]# service heartbeat restart
[root@web1 ~]# service heartbeat restart
|
1
|
|