Drbd
Drbd is a block device that can be used in Ha. It is similar to a network raid-1 function. When you write data to the local file system, the data will be sent to another host on the network and recorded in the same format in one file system. Data on the local (master node) and remote (slave node) can be synchronized in real time. when the local system fails, the same data is retained on the remote host and can be used again.
The drbd function can be used in high availability (HA) instead of a shared disk array. because the data exists on both the local host and remote host, when switching, the remote host can continue to provide services as long as it uses the backup data above it.
Drbd trial
Installing: Yum install drbd83 kmod-drbd83 kmod-drbd83-xen
Resource preparation:
[Root @ localhost ~] # Pvcreate/dev/sda3
Physical Volume "/dev/sda3" successfully created
[Root @ localhost ~] # Vgcreate virvg/dev/sda3
Volume group "virvg" successfully created
[Root @ localhost ~] # Vgs
VG # PV # LV # Sn ATTR vsize vfree
Virvg 1 0 0 WZ -- n-45.00g 45.00g
[Root @ localhost ~] # Lvcreate-L 2G-N LV1 virvg
Logical volume "LV1" created
Network Configuration:
Vim/etc/sysconfig/Network
Hostname = node1.local
Vim/etc/hosts
192.168.14.215 node2.local node2
192.168.19.13 node1.local node1
#/Etc/init. d/network restart
# Uname-n
Node1.local
Configure drbd:
Vim/etc/drbd. conf:
Include "/etc/drbd. d/global_common.conf ";
Include "/etc/drbd. d/*. Res ";
# Cat/etc/drbd. d/lv1.res
Resource LV1 {
Device/dev/drbd1;
Disk/dev/virvg/LV1;
Meta-disk internal;
On node2.local {
Address 192.168.14.215: 7789;
}
On node1.local {
Address 192.168.19.13: 7789;
}
}
Create a device: # drbdadm create-MD LV1
#/Etc/init. d/drbd start
# Drbdadm up LV1
[Root @ localhost ~] # Cat/proc/drbd
Version: 8.3.8 (API: 88/proto: 86-94)
Git-Hash: d78846e52224fd00562f7c225bcc25b2d422321d build by mockbuild@builder10.centos.org, 2010-06-04 08:04:27
1: CS: connected Ro: secondary/secondary DS: inconsistent/inconsistent C r ----
NS: 0 Nr: 0 DW: 0 Dr: 0 Al: 0 BM: 0 lo: 0 PE: 0 UA: 0 AP: 0 EP: 1 WO: B OOS: 2097052
Set a master device:
# Drbdsetup/dev/drbd1 primary-o
# Cat/proc/drbd
Version: 8.3.8 (API: 88/proto: 86-94)
Git-Hash: d78846e52224fd00562f7c225bcc25b2d422321d build by mockbuild@builder10.centos.org, 2010-06-04 08:04:27
1: CS: syncsource Ro: primary/secondary DS: uptodate/inconsistent C r ----
NS: 17056 Nr: 0 DW: 0 Dr: 17056 Al: 0 BM: 1 lo: 0 PE: 0 UA: 0 AP: 0 EP: 1 WO: B OOS: 2079996
[> ......] Sync 'ed: 1.0% (2079996/2097052) K delay_probe: 5
Finish: 0:57:46 speed: 464 (320) K/sec
We can see that data synchronization is started.
Master/Slave switchover
Run drbdadm secondary LV1 on the host
Run drbdadm primary LV1 on the slave machine.
Question 1: Found ext3 filesystem which uses 2097112 KB
[Root @ S0 ~] # Drbdadm create-MD R0
Md_offset 2147438592
Al_offset 2147405824
Bm_offset 2147340288
Found ext3 filesystem which uses 2097112 KB
Current configuration leaves usable 2097012 KB
Device size wocould be truncated, which
Wocould upload upt data and result in
'Access beyond end of device' errors.
You need to either
* Use external meta data (recommended)
* Shrink that filesystem first
* Zero out of the device (destroy the filesystem)
Operation refused.
Command 'drbdmeta/dev/drbd1 v08/dev/hdb1 internal create-MD 'terminated with exit code 40 drbdadm aborting
Partition ext3 is formatted before the drbd disk is initialized. Only partitions are not formatted here. Repartition.
Question 2: Starting drbd resources: Can not load the drbd Module
Kmod-drbd is not installed. This is the kernel module and must be installed.
Question 3: How to Implement the master mode
Modify the configuration file: (required for both machines)
Resource <resource>
Net {
Allow-two-primaries;
}
...
}
After modification, execute:
Run drbdadm disconnect resource on both nodes.
Execute drbdadm connect resource on both nodes.
Finally, you may now execute drbdadm primary resource on both nodes, instead of on just one.
Temporary method: drbdadm net-options -- protocol = c -- allow-two-primaries <resource>
Add the following options to enter the primary mode at startup:
Resource <resource>
Startup {
Become-primary-on both;
}
...
}
Note:
The default maximum synchronization bandwidth (sync-max) is 250kb/sec.
Author: feiskyer published on 18:36:50 Original article link Read: 19 comment: 0 view comment