免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2795 | 回复: 1
打印 上一主题 下一主题

[MySQL集群架构] Heartbeat + Drbd +Mysql 构建高可用的MYSQL数据库服务 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-10 22:59 |只看该作者 |倒序浏览
[MySQL集群架构] Heartbeat + Drbd +Mysql 构建高可用的MYSQL数据库服务















1,什么是DRBD
是由内核模块和相关脚本而构成,用以构建高可用性的集群。其实现方式是通过网络来镜像整个设备。您可以把它看作是一种网络RAID1

Drbd 负责接收数据,把数据写到本地磁盘,然后发送给另一个主机。另一个主机再将数据存到自己的磁盘中。其他所需的组件有集群成员服务,如TurboHA 或 心跳连接,以及一些能在块设备上运行的应用程序
环境
CentOS 5.2
Eth0:192.168.0.251
Eth1:192.168.254.4
CentOS 5.2
Eth0:192.168.0.252
Eth1:192.168.254.5

2. /etc/hosts 文件中新增加的内容,两边一样

ha1:192.168.254.4
ha2:192.168.254.5

OS:CentOS 5.2
软件:drbd8.2 kmod-8.2




安装drbd 及drbd内核模块

  1. #

  2. 01.yum -y install drbd82 kmod-drbd82
  3. 复制代码3.修改配置文件
  4. #mv /etc/drbd.conf /etc/drbd.conf.bak 备份原配置文件
  5. #vim /etc/drbd.conf

  6. 01.      global { usage-count yes; }

  7. 02.

  8. 03.       common { syncer { rate 10M; } }   //如果是100M网络,就写100

  9. 04.

  10. 05.       resource r0 {

  11. 06.

  12. 07.            protocol C;

  13. 08.            net {

  14. 09.

  15. 10.                 cram-hmac-alg sha1;

  16. 11.                 shared-secret "FooFunFactory";

  17. 12.            }

  18. 13.

  19. 14.            on ha1 {

  20. 15.

  21. 16.                 device    /dev/drbd0;

  22. 17.                 disk      /dev/sdb1;

  23. 18.

  24. 19.                 address   192.168.254.4:7898;

  25. 20.                 meta-disk  internal;

  26. 21.            }

  27. 22.            on ha2 {

  28. 23.                 device    /dev/drbd0;

  29. 24.                 disk      /dev/sdb1;

  30. 25.                 address   192.168.254.5:7898;

  31. 26.                 meta-disk  internal;

  32. 27.            }

  33. 28.       }

  34. 29.      
  35. 复制
复制代码
代码我的是很简单的,为了测试,还需要大家根据自己的需要自己修改~

好了两台机器都写完配置文件后,两边的drbd.conf 配置一模一样

在ha1和ha2上分别输入命令

#

01.drbdadm create-md r0
复制代码“r0"是我们在drbd.conf里定义
弹出的信息,敲回车,如果drbd.conf配置好的话,有的信息是不会弹出的。
  1. HA1上

  2. [root@ha1 etc]#

  3. 01.drbdadm create-md r0
  4. 复制代码v08 Magic number not found
  5. v07 Magic number not found
  6. v07 Magic number not found
  7. v08 Magic number not found
  8. Writing meta data...
  9. initialising activity log
  10. NOT initialized bitmap
  11. New drbd meta data block sucessfully created.

  12. HA2 上

  13. [root@ha2 etc]#

  14. 01.drbdadm create-md r0
  15. 复制代码v08 Magic number not found
  16. v07 Magic number not found
  17. v07 Magic number not found
  18. v08 Magic number not found
  19. Writing meta data...
  20. initialising activity log
  21. NOT initialized bitmap
  22. New drbd meta data block sucessfully created.
复制代码
现在我们可以启动DRBD了,分别在两台主机上执行:
  1. [root@ha1 etc]# /etc/init.d/drbd start
  2. Starting DRBD resources:    [ d(r0) s(r0) n(r0) ].
  3. ..........
  4. ***************************************************************
  5. DRBD's startup script waits for the peer node(s) to appear.
  6. - In case this node was already a degraded cluster before the
  7.     reboot the timeout is 0 seconds. [degr-wfc-timeout]
  8. - If the peer was available before the reboot the timeout will
  9.     expire after 0 seconds. [wfc-timeout]
  10.     (These values are for resource 'r0'; 0 sec -> wait forever)
  11. To abort waiting enter 'yes' [  23]:  //在这个时候你在HA2 上启动服务,就会马上成功启动服务,因为他在等待另一个节点


  12. [root@ha2 etc]# /etc/init.d/drbd start
  13. Starting DRBD resources:    [ d(r0) s(r0) n(r0) ].


  14. [root@ha1 etc]# cat /proc/drbd
  15. version: 8.2.6 (api:88/proto:86-88)
  16. GIT-hash: 3e69822d3bb4920a8c1bfdf7d647169eba7d2eb4 build by buildsvn@c5-i386-build, 2008-10-03 11:42:32
  17. 0: cs:Connected st:Secondary/Secondary ds:Inconsistent/Inconsistent C r---
  18.      ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 oos:8385604

  19.    
  20.     [root@ha2 etc]# cat /proc/drbd
  21. version: 8.2.6 (api:88/proto:86-88)
  22. GIT-hash: 3e69822d3bb4920a8c1bfdf7d647169eba7d2eb4 build by buildsvn@c5-i386-build, 2008-10-03 11:42:32
  23. 0: cs:Connected st:Secondary/Secondary ds:Inconsistent/Inconsistent C r---
  24.      ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 oos:8385604
复制代码
"/proc/drbd"中显示了drbd当前的状态.第一行的st表示两台主机的状态,都是"备机"状态.
ds是磁盘状态,都是"不一致"状态.
这是由于,DRBD无法判断哪一方为主机,以哪一方的磁盘数据作为标准数据.所以,我们需要初始化

一个主机.在drbd1上执行:
  1. [root@drbd1 local]#

  2. 01.drbdsetup /dev/drbd0 primary -o
复制代码
复制代码主备机状态分别是"主/备",主机磁盘状态是"实时",备机状态是"不一致".
在第3行,可以看到数据正在同步中,即主机正在将磁盘上的数据,传递到备机上.现在的进度是[>...................] sync'ed:  0.4% (1040316/1040316)K
稍等一会,在数据同步完后,再查看一下ha1的DRBD状态:


磁盘状态都是"实时",表示数据同步完成了.
你现在可以把主机上的DRBD设备挂载到一个目录上进行使用.备机的DRBD设备无法被挂载,因为它是
用来接收主机数据的,由DRBD负责操作.
在drbd1执行
root@ha1:~#
  1. 01. mkfs.ext3 /dev/drbd0  
复制代码
复制代码//网上这里有很多不同的版本,具体drbd深入我还没有研究,我现在安装的版本是只要在第一台上面格式化文件系统,他会自动传过去。如果你在ha2上格式化,他会提示出错,而且格式化要在上面相应工作做完以后才可以到这一步。
  1. root@ha1:~#

  2. 01.mount /dev/drbd0 /mnt  
  3. 复制代码root@ha1:~#

  4. 01. cd /mnt      
  5. 复制代码root@ha1:/mnt#

  6. 01. touch huzi
  7. 复制代码root@dha1:/mnt# ls
  8. huzi  lost+found
复制代码
可以看到,在主机drbd1上产生的文件huzi,也完整的保存在备机drbd2的DRBD分区上.
这就是DRBD的网络RAID-1功能. 在主机上的任何操作,都会被同步到备机的相应磁盘分区上,达到数据备份的效果.



DRBD的主备机切换有时,你需要将DRBD的主备机互换一下.可以执行下面的操作:
在主机上,先要卸载掉DRBD设备
root@drbd1~#

01.umount /mnt
复制代码将主机降级为"备机"
root@ha1~#
  1. 01.drbdadm secondary r0
  2. 复制代码[root@ha1 ~]#
复制代码
  1. 01.cat /proc/drbd
  2. 复制代码
复制代码
  1. version: 8.2.6 (api:88/proto:86-88)
  2. GIT-hash: 3e69822d3bb4920a8c1bfdf7d647169eba7d2eb4 build by buildsvn@c5-i386-build, 2008-10-03 11:42:32
  3. 0: cs:Connected st:Secondary/Primary ds:UpToDate/UpToDate C r---
  4.      ns:8650688 nr:24 dw:265108 dr:8385749 al:105 bm:584 lo:0 pe:0 ua:0 ap:0 oos:0
  5. 现在,两台主机都是"备机".
复制代码
在备机drbd2上,将它升级为"主机".
  1. [root@ha2 mnt]#

  2. 01.drbdadm primary r0
  3. 复制代码[root@ha2 etc]#

  4. 01.cat /proc/drbd
  5. 复制代码version: 8.2.6 (api:88/proto:86-88)
  6. GIT-hash: 3e69822d3bb4920a8c1bfdf7d647169eba7d2eb4 build by buildsvn@c5-i386-build, 2008-10-03 11:42:32
  7. 0: cs:Connected strimary/Secondary ds:UpToDate/UpToDate C r---
  8.      ns:0 nr:32 dw:32 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 oos:0
  9. [root@ha2 etc]#

  10. 01.mount /dev/drbd0 /mnt
  11. 复制代码[root@ha2 etc]#

  12. 01.cd /mnt
  13. 复制代码[root@ha2 mnt]#

  14. 01.ls
  15. 复制代码huzi lost+found
  16. [root@ha2 mnt]#

  17. 01. ll
  18. 复制代码
复制代码
total 16
-rw-r--r-- 1 root root     0 Mar 19 11:02 huzi
drwx------ 2 root root 16384 Mar 19 11:01 lost+found
现在drbd2成为主机了。


DRBD相关切换命令

DRBD切换

drbdadm secondary r0  //把主机切换成备机

drbdadm primary r0   //把主机切换成主机


注意,在我测试的情况。DRBD只有主机可以读写,备机不能够挂载,也就是说不能够读。可能是我的drbd.conf文件配置方面的原因 ,我会继续找一些文章来读,这样对于数据库是可以满足的,如果想做WEB。可以有些台只是用来读取的,不过我们这里只讨论数据库
------------------------------------------------------------------



上面的DRBD已经成功配置完成,可以正常切换,现在我们让两台成为高可用,所谓高可用,就是双机热备,互备。这里我不解释太多,相应搞过HA的人都清楚,不清楚的上www.linux-ha.org 上面看看文档。

主机ha1和ha2上安装heartbeat
  1. 01.yum ?y install heartbeat && yum ?y install heartbeat
  2. 复制代码
复制代码
//这里我也不清楚为什么要运行两次他才给我安装heartbeat ,嘿嘿,哪位知道告诉我为什么,我是每次都要晕两次才可以我安装

在主机ha1和ha2 上安装mysql mysql-server
  1. 01.yum ?y install mysql mysql-server
  2. 复制代码
复制代码
以下只在ha1上进行操作
在ha1上启动mysql
  1. 01.service mysqld start
  2. 复制代码
复制代码
//初始化数据库数据文件

再停止数据库
  1. 01.service mysqld stop
  2. 复制代码
复制代码
  1. 01.mount /dev/drbd0 /mnt
  2. 复制代码
复制代码
  1. 01.cp /var/lib/mysql/* /mnt -ar
  2. 复制代码
复制代码

  1. 01.umount /mnt
  2. 复制代码
复制代码
配置heartbeat

拷呗 cp /usr/share/doc/heartbeat-2.1.3/ 下面的 ha.cf,authkeys,haresources 到/etc/ha.d 目录下面
  1. 01.cp /usr/share/doc/heartbeat-2.1.3/haresources /etc/ha.d

  2. 02.cp /usr/share/doc/heartbeat-2.1.3/ha.cf /etc/ha.d

  3. 03.cp /usr/share/doc/heartbeat-2.1.3/authkeys /etc/ha.d
  4. 复制代码
复制代码
  1. 01.cd /etc/ha.d

  2. 02.

  3. 03.chmod 600 authkeys
  4. 复制代码
复制代码
authkeys文件中下面两行前面的#号去掉
  1. vi authkeys

  2. 01.auth 1

  3. 02.1 crc
  4. 复制代码
复制代码
配置ha.cf 内容如下,我就不一一解释了,有英语注释,注意的地方我会加注释
  1. 01.debugfile /var/log/ha-debug

  2. 02.logfile /var/log/ha-log

  3. 03.logfacility     local0

  4. 04.keepalive 2

  5. 05.deadtime 10

  6. 06.warntime 5

  7. 07.initdead 120

  8. 08.ucast eth1 192.168.254.5   //这里是对方的ip 主要用于HA的相互检测 网络接口要注意了,我用的是专用接口,ha2主机改为192.168.254.4

  9. 09.auto_failback on

  10. 10.watchdog /dev/watchdog

  11. 11.node    ha1

  12. 12.node    ha2

  13. 13.ping 192.168.254.1

  14. 14.respawn hacluster /usr/lib/heartbeat/ipfail

  15. 15.apiauth ipfail gid=haclient uid=hacluster
复制代码
复制代码添加自动加载drbd 及持载文件系统的脚本,放在/etc/ha.d/resource.d 目录下面
  1. vi mysqld_umount

  2. 01.#!/bin/sh

  3. 02.#

  4. 03.#       High-Availability Pre-Startup/Shutdown Script

  5. 04.#

  6. 05.# Description:  Runs on Startup or shutdown of heartbeat (not resource based).

  7. 06.#               Also runs before start, after start or before stop,

  8. 07.#               and after stop.

  9. 08.#

  10. 09.# Author:       Matthew Soffen

  11. 10.#

  12. 11.# Support:      linux-ha@lists.linux-ha.org

  13. 12.#

  14. 13.# License:      GNU Lesser General Public License (LGPL)

  15. 14.#

  16. 15.# Copyright:    (C) 2002 Matthew Soffen

  17. 16.#

  18. 17.#

  19. 18.unset LC_ALL; export LC_ALL

  20. 19.unset LANGUAGE; export LANGUAGE

  21. 20.

  22. 21.prefix=/usr

  23. 22.exec_prefix=/usr

  24. 23.. /etc/ha.d/shellfuncs

  25. 24.

  26. 25.case "$1" in

  27. 26.'start')

  28. 27.#/sbin/drbdadm -- --do-what-I-say primary all

  29. 28./sbin/drbdadm  primary all

  30. 29.#drbdsetup /dev/drbd1 primary -o

  31. 30./bin/mount /dev/drbd0 /var/lib/mysql

  32. 31.        ;;

  33. 32.'pre-start')

  34. 33.        ;;

  35. 34.'post-start')

  36. 35.        ;;

  37. 36.'stop')

  38. 37./bin/umount /var/lib/mysql

  39. 38./sbin/drbdadm  secondary all

  40. 39.;;

  41. 40.'pre-stop')

  42. 41.        ;;

  43. 42.'post-stop')

  44. 43.        ;;

  45. 44.*)

  46. 45.        echo "Usage: $0 { start | pre-start | post-start | stop | pre-stop | post-stop }"

  47. 46.        ;;

  48. 47.                                                                       

  49. 48.esac

  50. 49.exit 0
  51. 复制代码
复制代码
配置haresource

添加如下一行
  1. 01.ha1 IPaddr::192.168.0.253/24/eth0:1 mysqld_umount mysqld
复制代码
复制代码工作完成,把/etc/ha.d目录全部覆盖到ha2上面去

  1. 01.scp -r /etc/ha.d 192.168.254.5:/etc
复制代码
复制代码提示输入对方root用户的密码,全部转输完以后,注意修改/etc/ha.d/ha.cf 中的ucast eth1 192.168.254.5 为对方的IP也就是HA1主机的ETH1的IP 改为ucast eth1 192.168.254.4


两边同时启动heartbeat 观察日志

HA1上 HA的日志

  1. heartbeat[4039]: 2009/03/19_15:11:25 info: heartbeat: version 2.1.3
  2. heartbeat[4039]: 2009/03/19_15:11:25 info: Heartbeat generation: 1237438269
  3. heartbeat[4039]: 2009/03/19_15:11:25 info: glib: ucast: write socket priority set to IPTOS_LOWDELAY on eth1
  4. heartbeat[4039]: 2009/03/19_15:11:25 info: glib: ucast: bound send socket to device: eth1
  5. heartbeat[4039]: 2009/03/19_15:11:25 info: glib: ucast: bound receive socket to device: eth1
  6. heartbeat[4039]: 2009/03/19_15:11:25 info: glib: ucast: started on port 694 interface eth1 to 192.168.254.5
  7. heartbeat[4039]: 2009/03/19_15:11:25 info: glib: ping heartbeat started.
  8. heartbeat[4039]: 2009/03/19_15:11:25 info: G_main_add_TriggerHandler: Added signal manual handler
  9. heartbeat[4039]: 2009/03/19_15:11:25 info: G_main_add_TriggerHandler: Added signal manual handler
  10. heartbeat[4039]: 2009/03/19_15:11:25 notice: Using watchdog device: /dev/watchdog
  11. heartbeat[4039]: 2009/03/19_15:11:25 info: G_main_add_SignalHandler: Added signal handler for signal 17
  12. heartbeat[4039]: 2009/03/19_15:11:25 info: Local status now set to: 'up'
  13. heartbeat[4039]: 2009/03/19_15:11:26 info: Link ha2:eth1 up.
  14. heartbeat[4039]: 2009/03/19_15:11:26 info: Status update for node ha2: status active
  15. heartbeat[4039]: 2009/03/19_15:11:26 info: Link 192.168.254.1:192.168.254.1 up.
  16. heartbeat[4039]: 2009/03/19_15:11:26 info: Status update for node 192.168.254.1: status ping
  17. harc[4048]:     2009/03/19_15:11:26 info: Running /etc/ha.d/rc.d/status status
  18. heartbeat[4039]: 2009/03/19_15:11:27 info: Comm_now_up(): updating status to active
  19. heartbeat[4039]: 2009/03/19_15:11:27 info: Local status now set to: 'active'
  20. heartbeat[4039]: 2009/03/19_15:11:27 info: Starting child client "/usr/lib/heartbeat/ipfail" (498,496)
  21. heartbeat[4065]: 2009/03/19_15:11:27 info: Starting "/usr/lib/heartbeat/ipfail" as uid 498  gid 496 (pid 4065)
  22. heartbeat[4039]: 2009/03/19_15:11:27 info: remote resource transition completed.
  23. heartbeat[4039]: 2009/03/19_15:11:27 info: remote resource transition completed.
  24. heartbeat[4039]: 2009/03/19_15:11:27 info: Local Resource acquisition completed. (none)
  25. heartbeat[4039]: 2009/03/19_15:11:28 info: ha2 wants to go standby [foreign]
  26. heartbeat[4039]: 2009/03/19_15:11:30 info: standby: acquire [foreign] resources from ha2
  27. heartbeat[4068]: 2009/03/19_15:11:30 info: acquire local HA resources (standby).
  28. ResourceManager[4081]:  2009/03/19_15:11:30 info: Acquiring resource group: ha1 IPaddr::192.168.0.253/24/eth0:1 mysqld_umount mysqld
  29. IPaddr[4108]:   2009/03/19_15:11:31 INFO:  Resource is stopped
  30. ResourceManager[4081]:  2009/03/19_15:11:31 info: Running /etc/ha.d/resource.d/IPaddr 192.168.0.253/24/eth0:1 start
  31. IPaddr[4206]:   2009/03/19_15:11:31 INFO: Using calculated netmask for 192.168.0.253: 255.255.255.0
  32. IPaddr[4206]:   2009/03/19_15:11:32 INFO: eval ifconfig eth0:0 192.168.0.253 netmask 255.255.255.0 broadcast 192.168.0.255
  33. IPaddr[4177]:   2009/03/19_15:11:32 INFO:  Success
  34. ResourceManager[4081]:  2009/03/19_15:11:32 info: Running /etc/ha.d/resource.d/mysqld_umount  start
  35. ResourceManager[4081]:  2009/03/19_15:11:33 info: Running /etc/ha.d/resource.d/mysqld  start
  36. ipfail[4065]: 2009/03/19_15:11:34 info: Ping node count is balanced.
  37. heartbeat[4068]: 2009/03/19_15:11:35 info: local HA resource acquisition completed (standby).
  38. heartbeat[4039]: 2009/03/19_15:11:35 info: Standby resource acquisition done [foreign].
  39. heartbeat[4039]: 2009/03/19_15:11:35 info: Initial resource acquisition complete (auto_failback)
  40. heartbeat[4039]: 2009/03/19_15:11:35 info: remote resource transition completed.
复制代码
通过以上观察,资源全部加载成功,我们来验证一下

网络加载
  1. eth0:0    Link encap:Ethernet  HWaddr 00:0C:29:39:A8:2B  
  2.            inet addr:192.168.0.253  Bcast:192.168.0.255  Mask:255.255.255.0
  3.            UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  4.            Interrupt:169 Base address:0x2000
复制代码
文件系统加载
  1. [root@ha1 resource.d]#
复制代码
  1. 01.mount
  2. 复制代码[
复制代码
code]/dev/sda3 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda5 on /data type ext3 (rw)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/drbd0 on /var/lib/mysql type ext3 (rw)
[root@ha1 resource.d][/code]

  1. version: 8.2.6 (api:88/proto:86-88)
  2. GIT-hash: 3e69822d3bb4920a8c1bfdf7d647169eba7d2eb4 build by buildsvn@c5-i386-build, 2008-10-03 11:42:32
  3. 0: cs:Connectedst:Primary/Secondaryds:UpToDate/UpToDate C r---
  4.      ns:512 nr:1008 dw:1520 dr:5950 al:9 bm:8 lo:0 pe:0 ua:0 ap:0 oos:0
复制代码
DRBD是在主机状态 ,MYSQL我就不贴出来,验证MYSQL就没有必要了,大家自己去验证吧,我已经验证过了,其实大家都知道,文件系统都过来了,还验证个啥子



资源的状态,HA处在备机状态
  1. heartbeat[4412]: 2009/03/19_13:30:43 info: foreign HA resource release completed (standby).
  2. heartbeat[3795]: 2009/03/19_13:30:43 info: Local standby process completed [foreign].
  3. ipfail[3820]: 2009/03/19_13:30:44 info: No giveup timer to abort.
  4. heartbeat[3795]: 2009/03/19_13:30:45 WARN: 1 lost packet(s) for [ha1] [16:18]
  5. heartbeat[3795]: 2009/03/19_13:30:45 info: remote resource transition completed.
  6. heartbeat[3795]: 2009/03/19_13:30:45 info: No pkts missing from ha1!
  7. heartbeat[3795]: 2009/03/19_13:30:45 info: Other node completed standby takeover of foreign resources.
  8. [root@ha2 ha.d]#
复制代码
[root@ha2 ha.d]#
  1. 01.cat /proc/drbd
  2. 复制代码
复制代码
  1. version: 8.2.6 (api:88/proto:86-88)
  2. GIT-hash: 3e69822d3bb4920a8c1bfdf7d647169eba7d2eb4 build by buildsvn@c5-i386-build, 2008-10-03 11:42:32
  3. 0: cs:Connected st:Secondary/Primary ds:UpToDate/UpToDate C r---
  4.      ns:392 nr:832 dw:1224 dr:2989 al:9 bm:8 lo:0 pe:0 ua:0 ap:0 oos:0
复制代码
切换测试
HA1上停止HA服务
  1. [root@ha1 resource.d]#

  2. 01.service heartbeat stop
  3. 复制代码
复制代码
Stopping High-Availability services:
                                                           [  OK  ]
[root@ha1 resource.d]#

在HA2上观察
  1. [root@ha2 ha.d]# tail /var/log/ha-log -f
  2. heartbeat[3795]: 2009/03/19_13:55:21 info: Standby resource acquisition done [foreign].
  3. harc[4636]:     2009/03/19_13:55:21 info: Running /etc/ha.d/rc.d/status status
  4. mach_down[4652]:        2009/03/19_13:55:21 info: Taking over resource group IPaddr::192.168.0.253/24/eth0:1
  5. ResourceManager[4678]:  2009/03/19_13:55:21 info: Acquiring resource group: ha1 IPaddr::192.168.0.253/24/eth0:1 mysqld_umount mysqld
  6. IPaddr[4705]:   2009/03/19_13:55:22 INFO:  Resource is stopped
  7. ResourceManager[4678]:  2009/03/19_13:55:22 info: Running /etc/ha.d/resource.d/IPaddr 192.168.0.253/24/eth0:1 start
  8. IPaddr[4803]:   2009/03/19_13:55:22 INFO: Using calculated netmask for 192.168.0.253: 255.255.255.0
  9. IPaddr[4803]:   2009/03/19_13:55:22 INFO: eval ifconfig eth0:0 192.168.0.253 netmask 255.255.255.0 broadcast 192.168.0.255
  10. IPaddr[4774]:   2009/03/19_13:55:23 INFO:  Success
  11. ResourceManager[4678]:  2009/03/19_13:55:23 info: Running /etc/ha.d/resource.d/mysqld_umount  start
  12. ResourceManager[4678]:  2009/03/19_13:55:23 info: Running /etc/ha.d/resource.d/mysqld  start
  13. mach_down[4652]:        2009/03/19_13:55:25 info: /usr/share/heartbeat/mach_down: nice_failback: foreign resources acquired
  14. mach_down[4652]:        2009/03/19_13:55:25 info: mach_down takeover complete for node ha1.
  15. heartbeat[3795]: 2009/03/19_13:55:25 info: mach_down takeover complete.
复制代码
验证不贴出来了,通过上面已经正常切换了,在10秒内

服务启动的顺序,drbd让系统自动加载,heartbeat 放在/etc/rc.local里面,不然会出错,为什么自己去想,因为heartbeat 在drbd前面启动,你可以调整他们两的启动顺序。MYSQLD不要开机自动加载启动,这里我把注意的地方写一下,自己快半年没弄HA啦。今天做起来有点问题,HA通信的IP是相互对方的IP地址,fence ip 一定要存在,因为我是虚拟机测试的,开始没注意,花了点时间来查找问题
这个对比AB复制,备机不可以用来读,但保证了高可用性。DRBD在生产上已经有人使用,如果想达到AB复制效果,再加一台做复制就行了。这个相信大家可以加一台做复制?。有什么问题请跟帖哈
参考
http://deidara.blog.51cto.com/400447/105875
http://blog.chinaunix.net/u2/66227/showart_1018701.html

论坛徽章:
0
2 [报告]
发表于 2011-12-22 18:51 |只看该作者
学习鸟  谢谢分享
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP