转:http://blog.chinaunix.net/uid-25452915-id-3224246.html
http://www.admin5.com/article/20130825/521633.shtml
http://www.360doc.com/content/12/0308/16/2660674_192777008.shtml
http://blog.chinaunix.net/uid-16728139-id-3260466.html 用Heartbeat配置Linux高可用性集群
http://xuwensong.elastos.org/2013/11/27/linux%E4%B8%8B%E5%9F%BA%E4%BA%8Eheartbeat-%E5%8F%8C%E6%9C%BA%E7%83%AD%E5%A4%87%E4%B9%8B%E9%85%8D%E7%BD%AE%E8%AF%A6%E8%A7%A3/
Linux下基于HeartBeat 双机热备之配置详解重启主自动接管
实践
apt-get install heartbeat
root@test-VirtualBox:/etc/ha.d# ifconfig
eth0 Link encap:以太网 硬件地址 08:00:27:f6:59:a1
inet 地址:10.77.50.68 广播:10.77.50.255 掩码:255.255.255.0
inet6 地址: fe80::a00:27ff:fef6:59a1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 跃点数:1
接收数据包:361083 错误:0 丢弃:0 过载:0 帧数:0
发送数据包:176164 错误:0 丢弃:0 过载:0 载波:0
碰撞:0 发送队列长度:1000
接收字节:137127950 (137.1 MB) 发送字节:76501570 (76.5 MB)
lo Link encap:本地环回
inet 地址:127.0.0.1 掩码:255.0.0.0
inet6 地址: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 跃点数:1
接收数据包:16497 错误:0 丢弃:0 过载:0 帧数:0
发送数据包:16497 错误:0 丢弃:0 过载:0 载波:0
碰撞:0 发送队列长度:0
接收字节:6756252 (6.7 MB) 发送字节:6756252 (6.7 MB)
root@test-VirtualBox:/etc/ha.d# cat ha.cf
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 5
udpport 694
bcast eth0
auto_failback on
node test-virtualbox //一台电脑的主机名
node db3 //另一台电脑的主机名
root@test-VirtualBox:/etc/ha.d# cat haresources
test-virtualbox IPaddr::10.77.50.118/24/eth0
接收字节:6758652 (6.7 MB) 发送字节:6758652 (6.7 MB)
[root@db3 ha.d]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:24:81:83:AD:C7
inet addr:10.77.50.111 Bcast:10.77.50.255 Mask:255.255.255.0
inet6 addr: fe80::224:81ff:fe83:adc7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:251711746 errors:0 dropped:0 overruns:0 frame:0
TX packets:158376572 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:114223977068 (106.3 GiB) TX bytes:86048140952 (80.1 GiB)
Interrupt:50
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:24713432 errors:0 dropped:0 overruns:0 frame:0
TX packets:24713432 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:13019412520 (12.1 GiB) TX bytes:13019412520 (12.1 GiB)
[root@db3 ha.d]# pwd
/etc/ha.d
[root@db3 ha.d]# ls
authkeys ha.cf harc haresources rc.d README.config resource.d shellfuncs
[root@db3 ha.d]# cat ha.cf
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 5
udpport 694
bcast eth0
auto_failback on
node test-VirtualBox //主
node db3 //从
[root@db3 ha.d]# cat authkeys
auth 1
1 sha1 ok.
[root@db3 ha.d]# cat haresources
db3 IPaddr::10.77.50.118/24/eth0
root@test-VirtualBox:/etc/ha.d# ps aux|grep heartbeat
root 18013 0.0 1.0 5520 5480 ? SLs 16:05 0:00 heartbeat: master control process
root 18016 0.0 1.0 5352 5348 ? SL 16:05 0:00 heartbeat: FIFO reader
root 18017 0.0 1.0 5348 5344 ? SL 16:05 0:00 heartbeat: write: bcast eth0
root 18018 0.0 1.0 5348 5344 ? SL 16:05 0:00 heartbeat: read: bcast eth0
root 18359 0.0 0.1 5812 844 pts/2 S+ 16:12 0:00 grep --color=auto heartbeat
root@test-VirtualBox:/etc/ha.d# kill -9 18013
root@test-VirtualBox:/etc/ha.d# ps aux|grep heartbeat
root 18361 0.0 0.1 5812 844 pts/2 S+ 16:12 0:00 grep --color=auto heartbeat
[root@db3 ha.d]# service heartbeat restart
Stopping High-Availability services:
[ OK ]
Waiting to allow resource takeover to complete:
[ OK ]
Starting High-Availability services:
2015/09/17_16:21:39 INFO: Running OK
2015/09/17_16:21:39 CRITICAL: Resource IPaddr::10.77.50.118/24/eth0 is active, and should not be!
2015/09/17_16:21:39 CRITICAL: Non-idle resources can affect data integrity!
2015/09/17_16:21:39 info: If you don't know what this means, then get help!
2015/09/17_16:21:39 info: Read the docs and/or source to /usr/share/heartbeat/ResourceManager for more details.
CRITICAL: Resource IPaddr::10.77.50.118/24/eth0 is active, and should not be!
CRITICAL: Non-idle resources can affect data integrity!
info: If you don't know what this means, then get help!
info: Read the docs and/or the source to /usr/share/heartbeat/ResourceManager for more details.
2015/09/17_16:21:39 CRITICAL: Non-idle resources will affect resource takeback!
2015/09/17_16:21:39 CRITICAL: Non-idle resources may affect data integrity!
[ OK ]
[root@db3 ha.d]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:24:81:83:AD:C7
inet addr:10.77.50.111 Bcast:10.77.50.255 Mask:255.255.255.0
inet6 addr: fe80::224:81ff:fe83:adc7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:251717539 errors:0 dropped:0 overruns:0 frame:0
TX packets:158379136 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:114224585597 (106.3 GiB) TX bytes:86048422678 (80.1 GiB)
Interrupt:50
eth0:0 Link encap:Ethernet HWaddr 00:24:81:83:AD:C7
inet addr:10.77.50.118 Bcast:10.77.50.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:50
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:24713432 errors:0 dropped:0 overruns:0 frame:0
TX packets:24713432 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:13019412520 (12.1 GiB) TX bytes:13019412520 (12.1 GiB)
由于在CentOS 6 (6.0以及6.2)上没有找到Linux Heartbeat的源,所以最终选择在Ubuntu 8.04上安装。
点击(此处)折叠或打开
点击(此处)折叠或打开
点击(此处)折叠或打开
点击(此处)折叠或打开
点击(此处)折叠或打开
点击(此处)折叠或打开
点击(此处)折叠或打开
点击(此处)折叠或打开
点击(此处)折叠或打开
点击(此处)折叠或打开
点击(此处)折叠或打开
点击(此处)折叠或打开
点击(此处)折叠或打开
点击(此处)折叠或打开
如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术
转载请注明:heartbeat安装与配置 出自老鄢博客 | 欢迎分享