环境同heartbeat环境:
部署:
1:modprobe drbd #开启内核brbd模块
2:drbdadm create-md data #建立data
3:drbdadm up data #启动data
4:drbdadm -- --overwrite-data-of-peer primary data #传输覆盖,确定master
6:mkdir /data && mount /dev/drbd0 /data #挂载数据盘,特备说明drbdmeta不能格式文件系统!
6:mount /dev/drbd0 /data/ #挂载 SourceByrd's Weblog-https://note.t4x.org/service/distributed-replicated-block-device-install/
drdb安装:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
[root@Heartbeat-Master ~]# cd /byrd/tools/ [root@Heartbeat-Master tools]# wget http://oss.linbit.com/drbd/8.4/drbd-8.4.4.tar.gz [root@Heartbeat-Master tools]# tar zxf drbd-8.4.4.tar.gz [root@Heartbeat-Master tools]# cd drbd-8.4.4 [root@Heartbeat-Master drbd-8.4.4]# export LC_ALL=C [root@Heartbeat-Master drbd-8.4.4]# mkdir /byrd/service [root@Heartbeat-Master drbd-8.4.4]# ./configure --prefix=/byrd/service/drbd-8.4.4 --with-km --with-heartbeat --sysconfdir=/etc/ --mandir=/usr/share/man [root@Heartbeat-Master drbd-8.4.4]# yum install kernel kernel-devel -y #uname -r结果不一致,需要reboot [root@Heartbeat-Master drbd-8.4.4]# make #make KDIR=/usr/src/kernels/$(uname -r)/ [root@Heartbeat-Master drbd-8.4.4]# make install [root@Heartbeat-Master drbd-8.4.4]# lsmod | grep drbd [root@Heartbeat-Master drbd-8.4.4]# modprobe drbd [root@Heartbeat-Master drbd-8.4.4]# lsmod | grep drbd drbd 327242 0 libcrc32c 1246 1 drbd [root@Heartbeat-Master etc]# drbdadm create-md data Writing meta data... initializing activity log NOT initializing bitmap New drbd meta data block successfully created. [root@Heartbeat-Master etc]# drbdadm up data Device '0' is configured! Command 'drbdmeta 0 v08 /dev/sdb2 0 apply-al' terminated with exit code 20 [root@Heartbeat-Master etc]# cat /proc/drbd version: 8.4.4 (api:1/proto:86-101) GIT-hash: 74402fecf24da8e5438171ee8c19e28627e1c98a build by root@Heartbeat-Master, 2016-05-25 14:34:01 0: cs:WFConnection ro:Secondary/Unknown 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:d oos:3156744 [root@Heartbeat-Master etc]# mkdir /data [root@Heartbeat-Master etc]# mount /dev/drbd0 /data [root@Heartbeat-Master etc]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 28G 4.1G 23G 16% / tmpfs 238M 0 238M 0% /dev/shm /dev/sda1 477M 47M 406M 11% /boot /dev/drbd0 3.0G 4.6M 2.8G 1% /data |
配置:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
[root@Heartbeat-Slave etc]# cat 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; # 10 seconds (unit = 1 second) # ping-int 10; # 10 seconds (unit = 1 second) # ping-timeout 5; # 500 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 330M; al-extents 517; } } resource data { on Heartbeat-Master { device /dev/drbd0; disk /dev/sdb1; address 1.1.1.80:7788; meta-disk /dev/sdb2 [0]; } on Heartbeat-Slave { device /dev/drbd0; disk /dev/sdb1; address 1.1.1.81:7788; meta-disk /dev/sdb2 [0]; } } |
测试:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
[root@Heartbeat-Master data]# time dd if=/dev/zero of=./55m.img bs=1M count=1024 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 3.09343 s, 347 MB/s real 0m3.150s user 0m0.001s sys 0m1.303s [root@Heartbeat-Master data]# ll total 1048596 -rw-r--r--. 1 root root 1073741824 May 25 21:19 55m.img [root@Heartbeat-Slave etc]# drbdadm up data [root@Heartbeat-Slave etc]# drbdadm down data [root@Heartbeat-Slave etc]# mount /dev/sdb1 /mnt [root@Heartbeat-Slave etc]# ll /mnt/ total 1048596 -rw-r--r--. 1 root root 1073741824 May 25 21:16 55m.img drwx------. 2 root root 16384 May 25 14:02 lost+found |
分区:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
[root@Heartbeat-Master ~]# fdisk -l Disk /dev/sdb: 4294 MB, 4294967296 bytes 255 heads, 63 sectors/track, 522 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/sdb: 4294 MB, 4294967296 bytes 255 heads, 63 sectors/track, 522 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0096e3f6 Device Boot Start End Blocks Id System Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-522, default 1): 1 Last cylinder, +cylinders or +size{K,M,G} (1-522, default 522): +3G Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (394-522, default 394): Using default value 394 Last cylinder, +cylinders or +size{K,M,G} (394-522, default 522): Using default value 522 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@Heartbeat-Master ~]# fdisk /dev/sdb WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): p Disk /dev/sdb: 4294 MB, 4294967296 bytes 255 heads, 63 sectors/track, 522 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0096e3f6 Device Boot Start End Blocks Id System /dev/sdb1 1 393 3156741 83 Linux /dev/sdb2 394 522 1036192+ 83 Linux [root@Heartbeat-Master ~]# partprobe Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only. [root@Heartbeat-Master ~]# yum install parted [root@Heartbeat-Master ~]# mkfs.ext4 /dev/sdb1 [root@Heartbeat-Master ~]# tune2fs -c -1 /dev/sdb1 [root@Heartbeat-Master ~]# mount /dev/sdb2 /mnt mount: you must specify the filesystem type |
parted分区:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
[root@Heartbeat-Slave ~]# parted /dev/sdb mklabel gpt yes Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue? Information: You may need to update /etc/fstab. [root@Heartbeat-Slave ~]# parted /dev/sdb mkpart primary ext4 0 3000 ignore Warning: The resulting partition is not properly aligned for best performance. Information: You may need to update /etc/fstab. [root@Heartbeat-Slave ~]# parted /dev/sdb p Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 4295MB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 17.4kB 3000MB 3000MB primary [root@Heartbeat-Slave ~]# parted /dev/sdb mkpart primary ext4 3001 4000 ignore Warning: The resulting partition is not properly aligned for best performance. Information: You may need to update /etc/fstab. [root@Heartbeat-Slave ~]# parted /dev/sdb p Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 4295MB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 17.4kB 3000MB 3000MB primary 2 3001MB 4295MB 1294MB primary [root@Heartbeat-Slave ~]# parted /dev/sdb #删除方法 GNU Parted 2.1 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) rm 2 (parted) quit |
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!