Storage » StorageDRBD
Read this: https://services.ibb.gatech.edu/wiki/index.php/Howto:Software:DRBD
Even better: http://marksitblog.blogspot.com/2007/07/mysql-5-high-availability-with-drbd-8.html
Heartbeat: http://www.linuxjournal.com/article/5862 http://www.linux-ha.org/GettingStarted
DRBD
Download and install
Download drbd from http://www.drbd.orgBuild the kernel module
cd drbd-0.8.6/drbd make clean all cd .. make tools make install modprobe drbd lsmod | grep drbd
Preparing the storage sub-system
For DRBD, one can choose to use internal meta-data, or store meta-data on a separate partition. I'll use an external meta-data partition. The size of that partition is roughly DATA_PARTITION/32768+1. That's roughly 0.008% of the data partition. The actual formula can be found at http://www.drbd.org/users-guide/ch-internals.html#s-meta-data-sizeConfiguration and initialization
On node11. edit /etc/drbd.conf
2. modprobe drbd
3. drbdadm -d adjust mydata # check your config with -d (dry-run) option
4. drbdadm create-md mydata #create meta data partition
5. drbdadm adjust mydata # activate your config
To activate any configuration changes, do a "drbdadm adjust mydata"
On node2
Repeat step 1-5 above
Bring up the primary on node 1
*be warned, the -o option will remove ANY data on secondary node.
drbdsetup /dev/drbd0 primary -o
Then on both node, start the drbd service. Make sure the ports defined in drbd.conf are accessible. On freshly installed redhat/centos, iptables may stand in your way. Do what you need to.
service drbd start
Check /proc/drbd for progress, it should look like:
version: 8.0.6 (api:86/proto:86) SVN Revision: 3048 build by root@prod01xxx.org, 2007-09-06 12:42:29 0: cs:SyncTarget st:Secondary/Primary ds:Inconsistent/UpToDate C r--- ns:0 nr:920864 dw:920736 dr:0 al:0 bm:56 lo:5 pe:251 ua:4 ap:0 [>...................] sync'ed: 3.0% (29771/30670)M finish: 2:21:08 speed: 3,456 (11,508) K/sec resync: used:1/31 hits:57744 misses:57 starving:0 dirty:0 changed:57 act_log: used:0/257 hits:0 misses:0 starving:0 dirty:0 changed:0
Now just format the drbd volume as if it's another block device
mkfs.ext3 -j -Lmydata /dev/drbd0
Testing fail-over
Mount the partition on primary, write some data, then see if it comes up on node2...1. On node1 mount and write data
2. On node1> drbdadm secondary mydata
3. On node2> drbdadm primary mydata
4. On node2, mount and read !
Testing fail-back
1. On node1> drbdadm invalidate mydata2. On node2> restart drbd
3. synchronization will start automatically
Testbed
Platform: ES4 U5 32-bitVersion: DRBD 8.0.6
Partitions: c0d0p5 200M, c0d0p6 30G
Sample drbd.conf
drbd-8.2.conf
global {
usage-count yes;
}
common {
protocol C;
syncer {
rate 20M;
verify-alg md5;
}
handlers {
# shutdown heartbeat, if installed, on degrade to prevent failback to prevent data inconsistency
pri-on-incon-degr "logger -t HEARTBEAT: Primary inconsistent; service heartbeat stop";
}
startup {
wfc-timeout 30;
degr-wfc-timeout 60;
}
}
resource mydata {
disk {
on-io-error detach;
}
net {
max-buffers 8000;
max-epoch-size 8000;
}
device /dev/drbd0;
disk /dev/vg0/dr_data;
flexible-meta-disk /dev/vg0/dr_meta;
on db01.prod.xxx.com {
address 10.0.0.231:7789;
}
on db02.prod.xxx.com {
address 10.0.0.232:7789;
}
}
usage-count yes;
}
common {
protocol C;
syncer {
rate 20M;
verify-alg md5;
}
handlers {
# shutdown heartbeat, if installed, on degrade to prevent failback to prevent data inconsistency
pri-on-incon-degr "logger -t HEARTBEAT: Primary inconsistent; service heartbeat stop";
}
startup {
wfc-timeout 30;
degr-wfc-timeout 60;
}
}
resource mydata {
disk {
on-io-error detach;
}
net {
max-buffers 8000;
max-epoch-size 8000;
}
device /dev/drbd0;
disk /dev/vg0/dr_data;
flexible-meta-disk /dev/vg0/dr_meta;
on db01.prod.xxx.com {
address 10.0.0.231:7789;
}
on db02.prod.xxx.com {
address 10.0.0.232:7789;
}
}
drbd-8.1.conf
resource mydata {
protocol C;
# shutdown heartbeat, if installed, on degrade to prevent failback to prevent data inconsistency
incon-degr-cmd "service heartbeat stop";
startup {
wfc-timeout 0;
degr-wfc-timeout 60;
}
disk {
on-io-error detach;
}
net {
# timeout 60;
# connect-int 10;
# ping-int 10;
# max-buffers 2048;
# max-epoch-size 2048;
}
syncer {
rate 20M;
al-extents 257;
}
on prod02.xxx.org {
device /dev/drbd0;
disk /dev/cciss/c0d0p6;
address 10.0.0.2:7789;
meta-disk /dev/cciss/c0d0p5[0];
}
on prod01.xxx.org {
device /dev/drbd0;
disk /dev/cciss/c0d0p6;
address 10.0.0.1:7789;
meta-disk /dev/cciss/c0d0p5[0];
}
}
protocol C;
# shutdown heartbeat, if installed, on degrade to prevent failback to prevent data inconsistency
incon-degr-cmd "service heartbeat stop";
startup {
wfc-timeout 0;
degr-wfc-timeout 60;
}
disk {
on-io-error detach;
}
net {
# timeout 60;
# connect-int 10;
# ping-int 10;
# max-buffers 2048;
# max-epoch-size 2048;
}
syncer {
rate 20M;
al-extents 257;
}
on prod02.xxx.org {
device /dev/drbd0;
disk /dev/cciss/c0d0p6;
address 10.0.0.2:7789;
meta-disk /dev/cciss/c0d0p5[0];
}
on prod01.xxx.org {
device /dev/drbd0;
disk /dev/cciss/c0d0p6;
address 10.0.0.1:7789;
meta-disk /dev/cciss/c0d0p5[0];
}
}
Force a rebuild / verify consistency
Version 8.2.4 added online validation. Prior to that, one can only invalidate the failed node and force a full resync.Prior to 8.2.4
bad node# drbdadm disconnect all; drbdadm invalidate all; drbdadm connect all good node# drbdadm connect all
On 8.2.4
On secondary: # detects inconsistency - requires verify-alg option in syncer section drbdadm verify resource cat /proc/drbd # recover inconsistency drbdadm disconnect resource drbdadm connect resource # To maximize thruput for resync temporarily: drbdsetup /dev/drbd0 syncer -r 50M # To revert the changes drbdadm adjust mydata
There are 19 comments on this page. [Display comments]