MYSQL 7*24 高可用环境的部署

配置好MM和HEARTBEAT后。主机启动heartbeat
1、trazilla:/etc/ha.d# /etc/init.d/heartbeat start
Starting High-Availability services: 
Done.

trazilla:/etc/ha.d# 
---------------message
2、trazilla:~# tail -f /var/log/messages | grep heartbeat
Aug  5 11:01:31 trazilla heartbeat[16574]: info: **************************
Aug  5 11:01:31 trazilla heartbeat[16574]: info: Configuration validated. Starting heartbeat 1.2.5
Aug  5 11:01:31 trazilla heartbeat[16575]: info: heartbeat: version 1.2.5
Aug  5 11:01:32 trazilla heartbeat[16575]: info: Heartbeat generation: 51
Aug  5 11:01:32 trazilla heartbeat[16575]: info: UDP Broadcast heartbeat started on port 694 (694) interface eth1
Aug  5 11:01:32 trazilla heartbeat[16575]: info: ping heartbeat started.
Aug  5 11:01:32 trazilla heartbeat[16575]: info: pid 16575 locked in memory.
Aug  5 11:01:32 trazilla heartbeat[16575]: info: Local status now set to: 'up'
Aug  5 11:01:33 trazilla heartbeat[16578]: info: pid 16578 locked in memory.
Aug  5 11:01:33 trazilla heartbeat[16579]: info: pid 16579 locked in memory.
Aug  5 11:01:33 trazilla heartbeat[16580]: info: pid 16580 locked in memory.
Aug  5 11:01:33 trazilla heartbeat[16575]: info: Link trazilla:eth1 up.
Aug  5 11:01:33 trazilla heartbeat[16581]: info: pid 16581 locked in memory.
Aug  5 11:01:33 trazilla heartbeat[16582]: info: pid 16582 locked in memory.
Aug  5 11:01:33 trazilla heartbeat[16575]: info: Link 192.168.1.1:192.168.1.1 up.
Aug  5 11:01:33 trazilla heartbeat[16575]: info: Status update for node 192.168.1.1: status ping

备用机启动heartbeat
3、debian:/# /etc/init.d/heartbeat start
Starting High-Availability services: 
2009/08/05_11:02:53 INFO:  Resource is stopped
Done.

debian:/# 
4、-------------------------message
Aug  5 11:02:53 debian heartbeat: [5813]: info: Configuration validated. Starting heartbeat 2.1.3
Aug  5 11:02:53 debian heartbeat: [5814]: info: heartbeat: version 2.1.3
Aug  5 11:02:53 debian heartbeat: [5814]: info: Heartbeat generation: 1249022562
Aug  5 11:02:53 debian heartbeat: [5814]: info: glib: UDP Broadcast heartbeat started on port 694 (694) interface eth1
Aug  5 11:02:53 debian heartbeat: [5814]: info: glib: UDP Broadcast heartbeat closed on port 694 interface eth1 - Status: 1
Aug  5 11:02:53 debian heartbeat: [5814]: info: glib: ping heartbeat started.
Aug  5 11:02:53 debian heartbeat: [5814]: info: G_main_add_TriggerHandler: Added signal manual handler
Aug  5 11:02:53 debian heartbeat: [5814]: info: G_main_add_TriggerHandler: Added signal manual handler
Aug  5 11:02:53 debian heartbeat: [5814]: info: G_main_add_SignalHandler: Added signal handler for signal 17
Aug  5 11:02:53 debian heartbeat: [5814]: info: Local status now set to: 'up'
Aug  5 11:02:54 debian heartbeat: [5814]: info: Link 192.168.1.1:192.168.1.1 up.
Aug  5 11:02:54 debian heartbeat: [5814]: info: Status update for node 192.168.1.1: status ping
Aug  5 11:02:54 debian heartbeat: [5814]: info: Link debian:eth1 up.
Aug  5 11:02:55 debian heartbeat: [5814]: info: Link trazilla:eth1 up.
Aug  5 11:02:55 debian heartbeat: [5814]: info: flow control disabled due to different version heartbeat
Aug  5 11:02:55 debian heartbeat: [5814]: info: Status update for node trazilla: status active
Aug  5 11:02:55 debian heartbeat: [5814]: info: Comm_now_up(): updating status to active
Aug  5 11:02:55 debian heartbeat: [5814]: info: Local status now set to: 'active'
Aug  5 11:02:55 debian heartbeat: [5814]: info: remote resource transition completed.
Aug  5 11:02:55 debian heartbeat: [5814]: info: remote resource transition completed.
Aug  5 11:02:55 debian heartbeat: [5814]: info: Local Resource acquisition completed. (none)
Aug  5 11:02:56 debian heartbeat: [5814]: info: trazilla wants to go standby [foreign]
Aug  5 11:02:56 debian heartbeat: [5814]: info: standby: acquire [foreign] resources from trazilla
Aug  5 11:02:56 debian heartbeat: [5839]: info: acquire local HA resources (standby).
Aug  5 11:02:56 debian heartbeat: [5839]: info: local HA resource acquisition completed (standby).
Aug  5 11:02:56 debian heartbeat: [5814]: info: Standby resource acquisition done [foreign].
Aug  5 11:02:56 debian heartbeat: [5814]: info: Initial resource acquisition complete (auto_failback)
Aug  5 11:02:57 debian heartbeat: [5814]: info: remote resource transition completed.

192.168.1.66为浮动IP,这里显示资源服务mysqld已经启动起来了,trazilla为主机名
5、trazilla:/etc/ha.d# ifconfig eth0:0
eth0:0    Link encap:Ethernet  HWaddr 00:1A:A0:36:60:7A  
          inet addr:192.168.1.66  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:177 

trazilla:/etc/ha.d# 

如果这时候手动停止主机的mysqld,备用机监控不到主机的服务停止了。按资料上面heartbeat是会监控主机的资源服务的,如果down掉,自动接管过来,启动资源服务,分配IP。
实际测试却没有。而只有当主机或者heartbeat停止才会接管过来。
这是怎么回事呢?
在网上查了一下资料。原来 Heartbeat目前不监视它启动的资源,查看它们是否正在运行,健康状态如何,以及客户端计算机是否能够抵达。
资料上提到采用mon来进行资源的监控,但似乎并不能达到实现资源服务的自动接管。

最后在局域网内测试成功。
资源服务的健康情况监控写脚本完成。部署到主服务器上,
如果检测到资源服务停止,那么停止主服务器上的heartbeat服务,这样备用服务器就能接管过来了。
附脚本。

trazilla:/home/scripts# cat chkmysqlservice.sh 
#/bin/bash
logfile="/home/scripts/chk.log"
pgrep="/usr/bin/pgrep"
stop_heartbeat="/etc/init.d/heartbeat stop"
# mysql daemon name
mysql_service="mysqld"
# find mysql pid
$pgrep ${mysql_service}
echo "-------------------------------------------" >> $logfile
echo $(date +"%y-%m-%d %H:%M:%S") >> $logfile
echo "--------------------------" >> $logfile
#if mysql is not running
if [ $? -ne 0 ];then
$stop_heartbeat
echo "heartbeat stop success" >> $logfile
else
echo "mysqld is already running ">>$logfile
fi
trazilla:/home/scripts#

你可能感兴趣的:(mysql)