DRBD Introduction
Distributed Replicated Block Device (DRBD) is a software-implemented, non-shared, storage and replication solution for image Block Device content between servers.
Data image: Real-Time, transparent, and returned after all servers are synchronized), and returned after successful asynchronous local server)
The core function of DBRD is implemented through the Linux kernel, which is closest to the system's IO stack. However, it cannot add upper-layer functions like detecting the crash of the EXT3 file system.
DBRD is located below the file system, which is closer to the operating system kernel and IO stack than the file system.
The above information is from the Internet. Please respect copyright. Next, I will show you how to configure heartbeat + drbd instances.
Drbd Lab 1
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" clip_image002 "border =" 0 "alt =" clip_image002 "height =" 230 "src =" http://img1.51cto.com/attachment/201210/17/5558851_1350491577PGfc.jpg "/>
Initial network configuration
Configure IP addresses for node1 and start Network Services
Change the ip address to 192.168.145.99 100.
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" clip_image004 "border =" 0 "alt =" clip_image004 "height =" 288 "src =" http://www.bkjia.com/uploads/allimg/131228/032GL601-1.jpg "/>
[Root @ localhost ~] # Service network restart
Change host name node1.a.com
[Root @ localhost ~] # Vim/etc/sysconfig/network
3 HOSTNAME = node1.a.com
[Root @ localhost ~] # Hostname node1.a.com
Log out and log on again,
The high-availability cluster name must be able to parse and modify the hosts file.
[Root @ node1 ~] # Vim/etc/hosts
5 192.168.145.99 node1.a.com
6 192.168.145.100 node2.a.com
The clock of the two nodes must be consistent.
[Root @ node1 ~] # Hwclock-s
Configure IP addresses for node2 and start Network Services
Change the ip address to 192.168.145.100.
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" clip_image006 "border =" 0 "alt =" clip_image006 "height =" 305 "src =" http://www.bkjia.com/uploads/allimg/131228/032GH554-2.jpg "/>
[Root @ localhost ~] # Service network restart
Change host name node2.a.com
[Root @ localhost ~] # Vim/etc/sysconfig/network
3 HOSTNAME = node2.a.com
[Root @ localhost ~] # Hostname node2.a.com
Log out and log on again,
The high-availability cluster name must be able to parse and modify the hosts file.
[Root @ node1 ~] # Scp/etc/hosts node2.a.com:/etc
[Root @ node1 ~] # Vim/etc/hosts
5 192.168.145.99 node1.a.com
6 192.168.145.100 node2.a.com
The clock of the two nodes must be consistent.
[Root @ node2 ~] # Hwclock-s
Create an extended partition for Data Synchronization
Make sure that the disk size of the synchronization is the same for both parties.
On node1, view the remaining unpartitioned disk capacity.
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" clip_image008 "border =" 0 "alt =" clip_image008 "height =" 139 "src =" http://www.bkjia.com/uploads/allimg/131228/032GIJ5-3.jpg "/>
Create a partition for storage.
[Root @ node1 ~] # Fdisk/dev/sda
Command (m for help): n create a partition
Command action
E extended
P primary partition (1-4)
P create primary Partition
Selected partition 4
First cylinder (3954-6527, default 3954 ):
Last cylinder or + size or + sizeM or + sizeK (3954-6527, default 6527): + 1 GB size set to 1 GB
Command (m for help): p displays partition results
Disk/dev/sda: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Device Boot Start End Blocks Id System
/Dev/sda1*1 64 514048 + 83 Linux
/Dev/sda2 65 3888 30716280 83 Linux
/Dev/sda3 3889 3953 522112 + 82 Linux swap/Solaris
/Dev/sda4 3954 4076 987997 + 83 Linux
Command (m for help): w save and exit
The partition table has been altered!
[Root @ node1 ~] # Partprobe/dev/sda re-read the hard disk partition table and load it To the memory
[Root @ node1 ~] # Cat/proc/partitions
Major minor # blocks name
8, 0, 52428800, sda
8 1 514048 sda1
8 2 30716280 sda2
8, 3, 522112, sda3
8 4 987997 sda4
147 0 987928 drbd0
On node2, view the remaining unpartitioned disk capacity
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" clip_image010 "border =" 0 "alt =" clip_image010 "height =" 136 "src =" http://www.bkjia.com/uploads/allimg/131228/032GJ301-4.jpg "/>
There is an idle disk. Like node1, a 1 GB partition is created to synchronize and store data.
Install and configure the software package of drbd. install the software package on both sides in the form of INCORE modules.
[Root @ node1 ~] # Rpm-ivh drbd83-8.3.8-1.el5.centos.i386.rpm
[Root @ node1 ~] # Rpm-ivh kmod-drbd83-8.3.8-1.el5.centos.i686.rpm
Load drbd to the kernel as a module
[Root @ node1 ~] # Modprobe drbd
Check whether drbd exists in the kernel module.
[Root @ node1 ~] # Lsmod | grep drbd
Drbd 228528 0
Edit the configuration file of drbd and read the Help File in baseline mode.
[Root @ node1 ~] # Vim/etc/drbd. conf
: R/usr/share/doc/drbd83-8.3.8/drbd. conf
[Root @ node1 ~] # Cd/etc/drbd. d. Back up this file to prevent errors from being fixed.
[Root @ node1 drbd. d] # cp global_common.conf global_common.conf.bak
Edit
[Root @ node1 drbd. d] # vim global_common.conf
Run Command 1 in baseline mode and $ d to delete all rows and add the content.
Protocol
Startup various latencies
Disk error Protocol
. Net encryption algorithm key
Syncer synchronization speed
Global {
Usage-count yes;
# Minor-count dialog-refresh disable-ip-verification
}
Common {
Protocol C;
Startup {
Wfc-timeout 120;
Degr-wfc-timeout 120;
}
Disk {
On-io-error detach;
Fencing resource-only;
}
Net {
Cram-hmac-alg "sha1 ";
Shared-secret "mydrbdlab ";
}
Syncer {
Rate 100 M;
}
}
Edit the resource file, which must end with. res.
[Root @ node1 drbd. d] # vim web. res
Resource web {
On node1.a.com {
Device/dev/drbd0;
Disk/dev/sda5;
Address 192.168.145.99: 7789;
Meta-disk internal;
}
On node2.a.com {
Device/dev/drbd0;
Disk/dev/sda5;
Address 192.168.145.100: 7789;
Meta-disk internal;
}
}
Install and configure drbd on node2, which is similar to node1.
Copy all the drbd files in node1 to node2.
[Root @ node1 drbd. d] # scp * node2.a.com:/etc/drbd. d/
[Root @ node1 drbd. d] # scp/etc/drbd. conf node2.a.com:/etc/
Initialization can be completed before both sides are completed, and resources must be created on both sides.
[Root @ node1 drbd. d] # drbdadm create-md web
To start the drbd service, you must start the drbd service on both servers at the same time.
[Root @ node1 drbd. d] # service drbd start
Check who is the master device before the primary secondary device has not adjusted the priority
[Root @ node2 drbd. d] # drbd-overview
0: web Connected Secondary/Secondary Inconsistent/Inconsistent C r ----
Use the command to upgrade node1.
[Root @ node1 drbd. d] # drbdadm -- overwrite-data-of-peer primary web
Again, node1 has been upgraded to the master device.
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" clip_image012 "border =" 0 "alt =" clip_image012 "height =" 34 "src =" http://www.bkjia.com/uploads/allimg/131228/032GM440-5.jpg "/>
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" clip_image014 "border =" 0 "alt =" clip_image014 "height =" 31 "src =" http://www.bkjia.com/uploads/allimg/131228/032GK106-6.jpg "/>
View synchronization process
[Root @ node1 drbd. d] # cat/proc/drbd
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" clip_image016 "border =" 0 "alt =" clip_image016 "height =" 127 "src =" http://www.bkjia.com/uploads/allimg/131228/032GGb4-7.jpg "/>
View the synchronization process, once per second
[Root @ node1 drbd. d] # watch-n 1 'cat/proc/drbd'
Check that node 1 is the master device, and node 2 is the secondary device. Perform the write operation on node 1.
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" clip_image018 "border =" 0 "alt =" clip_image018 "height =" 59 "src =" http://www.bkjia.com/uploads/allimg/131228/032GHW6-8.jpg "/>
This experiment is a single-group model with only one master device
Format the device and mount the device.
[Root @ node1 ~] # Mkfs-t ext3-L drbdweb/dev/drbd0
[Root @ node1 ~] # Mkdir/mnt/1
[Root @ node1 ~] # Mount/dev/drbd0/mnt/1
[Root @ node1 ~] # Df-h
Filesystem Size Used Avail Use % Mounted on
/Dev/sda2 29G 2.6G 25G 10%/
/Dev/sda1 487 M 16 M 446 M 4%/boot
Tmpfs 127 M 0 127 M 0%/dev/shm
/Dev/drbd0 950 M 18 M 885 M 2%/mnt/1
Test
Make appropriate write operations to copy files
[Root @ node1 ~] # Cd/mnt/1
[Root @ node1 1] # cp/etc/passwd ./
Because node2 is a device, you cannot view the information,
You only need to downgrade node1 to the next device.
Downgrade method, unmount, Level Set to time
[Root @ node1 ~] # Umount/mnt/1
[Root @ node1 ~] # Downgrade drbdadm secondary web to a secondary device
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" clip_image020 "border =" 0 "alt =" clip_image020 "height =" 122 "src =" http://www.bkjia.com/uploads/allimg/131228/032GM355-9.jpg "/>
The secondary device cannot be mounted. You need to upgrade it to the primary device and then mount the secondary device.
[Root @ node2 drbd. d] # dir/mnt/1
[Root @ node2 drbd. d] # drbdadm primary web
[Root @ node2 drbd. d] # mount/dev/drbd0/mnt/1
Go to the Mount directory to view the synchronized data.
650) this. width = 650; "style =" border-bottom: 0px; border-left: 0px; border-top: 0px; border-right: 0px "title =" clip_image022 "border =" 0 "alt =" clip_image022 "height =" 91 "src =" http://www.bkjia.com/uploads/allimg/131228/032GL425-10.jpg "/>
In the write operation, uninstall, production depends on node1 changes
This article is from the "Shi Dawei's blog" blog, please be sure to keep this source http://shdw1999.blog.51cto.com/5558851/1030233