原创作品,允许转载,转载时请务必以超链接形式标明文章
原始出处 、作者信息和本声明。否则将追究法律责任。
http://jerry12356.blog.51cto.com/4308715/1858243
主机名 | 角色 | IP地址 |
mylinux1.contoso.com | heartbeat+haproxy | |
mylinux2.contoso.com | heartbeat+haproxy | |
mylinux3.contoso.com | web server 1 | eth0:192.168.100.181 |
mylinux4.contoso.com | web server 2 | eth0:192.168.100.182 |
1
2
3
4
5
6
7
8
9
10
11
12
|
[root@mylinux1 ~]
# scp /etc/init.d/haproxy mylinux2:/etc/init.d/
root@mylinux2's password:
Permission denied, please try again.
root@mylinux2's password:
haproxy 100% 1567 1.5KB
/s
00:00
[root@mylinux1 ~]
# scp /usr/local/haproxy/conf/haproxy.cfg mylinux2:/usr/local/haproxy/conf/haproxy.cfg
root@mylinux2's password:
haproxy.cfg 100% 1194 1.2KB
/s
00:00
[root@mylinux2 haproxy]
# ll /etc/init.d/haproxy
-rwxr-xr-x 1 root root 1567 Oct 1 02:11
/etc/init
.d
/haproxy
[root@mylinux2 haproxy]
# ll /usr/local/haproxy/conf/haproxy.cfg
-rw-r--r-- 1 root root 1194 Oct 1 02:13
/usr/local/haproxy/conf/haproxy
.cfg
|
1
2
3
4
|
[root@mylinux1 ~]
# tail -1 /etc/ha.d/haresources
mylinux1.contoso.com IPaddr::192.168.100.120
/24/eth0
haproxy
[root@mylinux2 haproxy]
# tail -1 /etc/ha.d/haresources
mylinux1.contoso.com IPaddr::192.168.100.120
/24/eth0
haproxy
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
[root@mylinux1 ~]
# egrep -v "#|^$" /etc/ha.d/ha.cf
debugfile
/var/log/ha-debug
logfile
/var/log/ha-log
logfacilitylocal1
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport694
mcast eth1 225.0.0.1 694 1 0
auto_failback on
nodemylinux1.contoso.com
nodemylinux2.contoso.com
respawn hacluster
/usr/lib64/heartbeat/ipfail
[root@mylinux2 haproxy]
# egrep -v "#|^$" /etc/ha.d/ha.cf
debugfile
/var/log/ha-debug
logfile
/var/log/ha-log
logfacilitylocal1
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport694
mcast eth1 225.0.0.1 694 1 0
auto_failback on
node mylinux1.contoso.com
node mylinux2.contoso.com
respawn hacluster
/usr/lib64/heartbeat/ipfail
|
1
2
3
4
|
[root@mylinux1 ~]
# service haproxy stop
Stop haproxy successful.
[root@mylinux2 haproxy]
# service haproxy stop
Haproxy is not running. Stop haproxy failed!
|
1
2
3
4
5
6
|
[root@mylinux1 ~]
# /etc/init.d/heartbeat start
Starting High-Availability services: INFO: Resource is stopped
Done.
[root@mylinux2 haproxy]
# /etc/init.d/heartbeat start
Starting High-Availability services: INFO: Resource is stopped
Done.
|
1
2
3
4
|
[root@mylinux1 ~]
# ip a|grep 192.168.100.120
inet 192.168.100.120
/24
brd 192.168.100.255 scope global secondary eth0
[root@mylinux1 ~]
# service haproxy status
Haproxy (pid 3600) is running...
|
1
2
3
|
[root@mylinux2 haproxy]
# ip a |grep 192.168.100.120
[root@mylinux2 haproxy]
# service haproxy status
Haproxy is stopped.
|
1
2
|
[root@mylinux1 ~]
# /etc/init.d/heartbeat stop
Stopping High-Availability services: Done.
|
1
2
3
4
5
6
7
|
[root@mylinux1 ~]
# ip a |grep 192.168.100.120
[root@mylinux1 ~]
# service haproxy status
Haproxy is stopped.
[root@mylinux2 haproxy]
# ip a |grep 192.168.100.120
inet 192.168.100.120
/24
brd 192.168.100.255 scope global secondary eth0
[root@mylinux2 haproxy]
# service haproxy status
Haproxy (pid 3997) is running...
|