Dbabc.net 利用heartbeat + drbd搭建my sql高可用环境

Embed Size (px)

DESCRIPTION

Heartbeat + DRBDMySQL.pdf

Text of Dbabc.net 利用heartbeat + drbd搭建my sql高可用环境

  • http://dbabc.net Email:webpdf@dbabc.net Heartbeat + DRBD MySQL http://dbabc.net
  • http://dbabc.net Email:webpdf@dbabc.netDRBD ............................................................................................. 3 1................................................................................................................. 3 2 .................................................................................................................... 4 3............................................................................................................. 4Heartbeat+DRBD+MySQL .................................................................................. 5 1............................................................................................................. 5 2 ......................................................................................................... 5 3 drbdheartbeat............................................................................................. 7 4 DRBD .............................................................................................................. 8 5 drbd resource .......................................................................... 9 6 heartbeat ...................................................................................................... 12 Mysql HA ........................................................................................................ 14 1 Node ..................................................................................................... 14 2 Master .................................................................. 17HA ................................................................................................... 17 1 ....................................................................................................... 17 2 ....................................................................................................... 17
  • http://dbabc.net Email:webpdf@dbabc.netDRBD 1DRBD ,(HA) . RAID -1 ,()(),,
  • http://dbabc.net Email:webpdf@dbabc.net2 Mysql Master HA/dev/drbd0 /dev/drbd0 DRBD Primary Secondary /data /data Heartbeat Primary Secondary mysql-n1 mysql-n2 VIP:10.20.50.250 AP1 AP2 AP33Node1 mysql-n1 CentOS release 5.8 (Final) 2.6.18-308 DRBD drbd83-8.3.12-2 (yum ) heartbeat heartbeat-2.1.3-3(yum ) eth0 IP: 10.20.50.221 eth1 IP: 192.168.18.1
  • http://dbabc.net Email:webpdf@dbabc.netNode2 mysql-n2 CentOS release 5.8 (Final) 2.6.18-308 DRBD drbd83-8.3.12-2 (yum ) heartbeat heartbeat-2.1.3-3(yum ) eth0 IP: 10.20.50.222 eth1 IP: 192.168.18.2VIP: eth0:0:10.20.50.250DRBD : /dataHeartbeat+DRBD+MySQL 1Node1Node2 # vi /etc/hosts10.20.50.221 mysql-n110.20.50.222 mysql-n22Node1Node2 sdb MySQL [root@mysql-n1 ~]# fdisk -lDisk /dev/sda: 42.9 GB, 42949672960 bytes255 heads, 63 sectors/track, 5221 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System/dev/sda1 * 1 13 104391 83 Linux/dev/sda2 14 5221 41833260 8e Linux LVMDisk /dev/sdb: 17.1 GB, 17179869184 bytes
  • http://dbabc.net Email:webpdf@dbabc.net255 heads, 63 sectors/track, 2088 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesDisk /dev/sdb doesnt contain a valid partition table #fdisk /dev/sdbn --> p -->1 -->-->w [root@mysql-n1 ~]# fdisk /dev/sdbDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel. Changes will remain in memory only,until you decide to write them. After that, of course, the previouscontent wont be recoverable.The number of cylinders for this disk is set to 2088.There is nothing wrong with that, but this is larger than 1024,and could in certain setups cause problems with:1) software that runs at boot time (e.g., old versions of LILO)2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)Command (m for help): nCommand action e extended p primary partition (1-4)pPartition number (1-4): 1First cylinder (1-2088, default 1):Using default value 1Last cylinder or +size or +sizeM or +sizeK (1-2088, default 2088):Using default value 2088Command (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks. fdisk -l partition talbe [root@mysql-n1 ~]# fdisk -l
  • http://dbabc.net Email:webpdf@dbabc.netDisk /dev/sda: 42.9 GB, 42949672960 bytes255 heads, 63 sectors/track, 5221 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System/dev/sda1 * 1 13 104391 83 Linux/dev/sda2 14 5221 41833260 8e Linux LVMDisk /dev/sdb: 17.1 GB, 17179869184 bytes255 heads, 63 sectors/track, 2088 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System/dev/sdb1 1 2088 16771828+ 83 Linux3 drbdheartbeatNode1Node2 yum install -y drbd83 kmod-drbd83yum install -y heartbeat heartbeat-ldirectord heartbeat-pils heartbeat-stonith[root@mysql-n2 ~]# yum install -y drbd83 kmod-drbd83Loaded plugins: fastestmirror, securityLoading mirror speeds from cached hostfile * base: mirrors.btte.net * extras: mirrors.btte.net * updates: mirrors.btte.netSetting up Install ProcessResolving Dependencies--> Running transaction check---> Package drbd83.x86_64 0:8.3.12-2.el5.centos set to be updated---> Package kmod-drbd83.x86_64 0:8.3.12-1.el5.centos set to be installed--> Finished Dependency ResolutionDependencies Resolved=========================================================================== Package Arch Version Repository Size
  • http://dbabc.net Email:webpdf@dbabc.net===========================================================================Installing: drbd83 x86_64 8.3.12-2.el5.centos extras 236 k kmod-drbd83 x86_64 8.3.12-1.el5.centos extras 136 kTransaction Summary===========================================================================Install 2 Package(s)Upgrade 0 Package(s)Total download size: 371 kDownloading Packages:(1/2): kmod-drbd83-8.3.12-1.el5.centos.x86_64.rpm | 136 kB 00:00(2/2): drbd83-8.3.12-2.el5.centos.x86_64.rpm | 236 kB 00:00---------------------------------------------------------------------------Total 1.3 MB/s | 371 kB 00:00Running rpm_check_debugRunning Transaction TestFinished Transaction TestTransaction Test SucceededRunning Transaction Installing : drbd83 1/2 Installing : kmod-drbd83 2/2Installed: drbd83.x86_64 0:8.3.12-2.el5.centos kmod-drbd83.x86_64 0:8.3.12-1.el5.centosComplete!4 DRBDNode1Node2 drbd /etc drbd.conf # please have a a look at the example configuration file in# /usr/share/doc/drbd83/drbd.conf/usr/share/doc/drbd83-8.3.12/drbd.conf
  • http://dbabc.net Email:webpdf@dbabc.net/etc/drbd.conf,Master Node:# vi /etc/drbd.conf## please have a a look at the example configuration file in# /usr/share/doc/drbd83/drbd.conf#include "drbd.d/global_common.conf";include "drbd.d/*.res";/etc/drbd.d/ ha.res# vi /etc/drbd.d/ha.resresource ha { on mysql-n1 { device /dev/drbd1; disk /dev/sdb1; address 192.168.18.1:7898; meta-disk internal; } on mysql-n2 { device /dev/drbd1; disk /dev/sdb1; address 192.168.18.2:7898; meta-disk internal; }}/etc/drbd.conf /etc/drbd.d/ scp Node2.5 drbd resourceNode1Node2 modprobe drbd drbdadm create-md drbd resource drbd resource ha ha#modprobe drbd // drbd #lsmod|grep drbd // drbd
  • http://dbabc.net Email:webpdf@dbabc.net[root@mysql-n1 ~]# lsmod|grep drbddrbd 298760 0#drbdadm create-md ha // drbd resource[root@mysql-n1 ~]# drbdadm create-md haWriting meta data...initializing activity logNOT initialized bitmapNew drbd meta data b