Heartbeat+drbd+mysql High-availability
1. Planning
vip:192.168.1.30
Myhost1:
Intranet ip:192.168.1.11
Heartbeat Heartbeat ip:192.168.74.11
DRBD Transport ip:192.168.223.11
Myhost2:
Intranet ip:192.168.1.12
Heartbeat Heartbeat ip:192.168.74.12
DRBD Transport ip:192.168.223.12
2. Installing Heartbeat
Yum Install Heartbeat-y
If the RPM package installation requires the following packages installed:
libnet-1.1.6-7.el5.x86_64.rpm
Libtool-ltdl
Openhpi-libs
Heartbeat-stonith
Heartbeat-pils
3. Configuration files in the/ETC/HA.D directory:
CP/USR/SHARE/DOC/HEARTBEAT-2.1.4/HA.CF./
Cp/usr/share/doc/heartbeat-2.1.4/authkeys./
Cp/usr/share/doc/heartbeat-2.1.4/haresources./
chmod 600/etc/ha.d/authkeys
Configure HA.CF
Debugfile/var/log/ha-debug
Logfile/var/log/ha-log
Logfacility local0
KeepAlive 2
Deadtime 30
Warntime 10
Initdead 120
Udpport 694
Ucast eth2 192.168.74.12
Auto_failback on
Node Myhost1
Node Myhost2
CRM No
Authkey
Auth 1
1 SHA1 63d40e84c4748d6a7b8ec3581a374a3c
Haresource
Myhost1 ipaddr::192.168.1.30/24/eth0 drbddisk::mdata filesystem::/dev/drbd0::/dbdata::ext3 rsdata
#每段的具体执行命令说明:
#/etc/ha.d/resource.d/ipaddr 192.168.1.30/24/eth0 Stop/start
#/etc/ha.d/resource.d/drbddisk Mdata Stop/start
#/etc/ha.d/resource.d/filesystem/dev/drbd0/dbdata ext3 Stop/start
#/etc/init.d/rsdata Stop/start
4. Disable power-on self-booting:
Chkconfig Heartbeat off
5. Installing DRBD (redhat 5.8 environment)
wget wget http://oss.linbit.com/drbd/8.4/drbd-8.4.6.tar.gz
TAR-ZXVF drbd-8.4.6.tar.gz
CD drbd-8.4.6
Make
Make install
wget http://oss.linbit.com/drbd/drbd-utils-8.9.2.tar.gz
TAR-ZXVF drbd-utils-8.9.2
CD drbd-utils-8.9.2
./configure--prefix=/usr/local/drbd-utils-8.9.2--sysconfdir=/etc--with-xen
Make && make install
If it is a CentOS 6 version of the system, you can execute the following command:
Yum Install drbd83 kmod-drbd83-y
6. Format the partition:
Mkfs.ext3/dev/sdb1
Tune2fs-c -1/DEV/SDB1
Meta partition can not be formatted, general allocation of 1g-2g space in production environment;
7. Configure DRBD
Modprobe DRBD
Lsmod |grep DRBD
MKNOD/DEV/DRBD0 B 147 0
#配置开机加载:
echo "Modprobe drbd >/dev/null 2>&1" >>/etc/sysconfig/modules/drbd.modules
chmod 755/etc/sysconfig/modules/drbd.modules
Mkdir-p/USR/LOCAL/DRBD-UTILS-8.9.2/VAR/RUN/DRBD
#调整配置文件
[Email protected] ~]# cat/etc/drbd.conf
Global {
# Minor-count 64;
# Dialog-refresh 5; # 5 Seconds
# disable-ip-verification;
Usage-count No;
}
Common {
Protocol C;
Disk {
On-io-error detach;
No-disk-flushes;
No-md-flushes;
}
NET {
Sndbuf-size 512k;
# timeout 60; # 6 seconds (unit = 0.1 seconds)
# Connect-int 10; # seconds (unit = 1 second)
# Ping-int 10; # seconds (unit = 1 second)
# ping-timeout 5; # MS (unit = 0.1 seconds)
Max-buffers 8000;
Unplug-watermark 1024;
Max-epoch-size 8000;
# Ko-count 4;
# allow-two-primaries;
Cram-hmac-alg "SHA1";
Shared-secret "hdhwxes23syehart8t";
After-sb-0pri Disconnect;
After-sb-1pri Disconnect;
After-sb-2pri Disconnect;
Rr-conflict Disconnect;
# DATA-INTEGRITY-ALG "MD5";
# no-tcp-cork;
}
Syncer {
Rate 630M;
Al-extents 517;
}
}
Resource Mdata {
On Myhost1 {
device/dev/drbd0;
DISK/DEV/SDB1;
Address 192.168.223.11:7788;
META-DISK/DEV/SDB2 [0];
}
On Myhost2 {
device/dev/drbd0;
DISK/DEV/SDB1;
Address 192.168.223.12:7788;
META-DISK/DEV/SDB2 [0];
}
}
#两个节点同时执行
Drbdadm CREATE-MD Mdata
#两个节点执行
Drbdadm up All
#仅主节点执行
DRBDADM----Overwrite-data-of-peer primary mdata
#仅主节点执行
Drbdadm Primary All
PS Aux|grep DRBD
Mount/dev/drbd0/dbdata
Cat/proc/drbd
8.heartbeat Boot order:
1. Start VIP
/etc/ha.d/resource.d/ipaddr 192.168.1.30/24/eth0 Start
2. Configuring the DRBD Resource
/etc/ha.d/resource.d/drbddisk Mdata Start
3. Mount the DRBD partition
/etc/ha.d/resource/drbddisk/dev/drbd0/dbdata ext3 Start
4. Start MySQL:
/etc/ha.d/resource/rsdata start
5. View the information for DRBD:
Cat/proc/drbd
6. Verify that the checkpoint is normal:
VIP, role, partition mount
9. Primary and Standby switching
/usr/lib64/heartbeat/hb_standby
/usr/lib64/heartbeat/hb_takeover
This article is from the "Webseven" blog, make sure to keep this source http://webseven.blog.51cto.com/4388012/1651795
Heartbeat+drbd+mysql High-availability deployments