接上篇文章:https://note.t4x.org/system/heartbeat-compile-install/
基础环境:
[root@DB1 ~]# uname -a
Linux DB1.MySQL.hz.t4x.org 2.6.32-642.4.2.el6.x86_64 #1 SMP Tue Aug 23 19:58:13 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@DB1 ~]# uname -n
DB1.mysql.hz.t4x.org
[root@DB1 ~]# uname -r
2.6.32-642.4.2.el6.x86_64
[root@DB1 ~]# cat /etc/redhat-release
CentOS release 6.8 (Final) SourceByrd's Weblog-https://note.t4x.org/system/drbd-configure-install/
IP地址规划:SourceByrd's Weblog-https://note.t4x.org/system/drbd-configure-install/
[root@DB1 ~]# ifconfig | grep "inet addr:"
inet addr:1.1.1.110 Bcast:1.1.1.255 Mask:255.255.255.0 eth0
inet addr:10.162.32.110 Bcast:10.162.47.255 Mask:255.255.240.0 eth1
inet addr:172.16.0.110 Bcast:172.16.255.255 Mask:255.255.0.0 eht2SourceByrd's Weblog-https://note.t4x.org/system/drbd-configure-install/[root@DB2 ~]# ifconfig | grep "inet addr:"
inet addr:1.1.1.111 Bcast:1.1.1.255 Mask:255.255.255.0 eth0
inet addr:10.162.32.111 Bcast:10.162.47.255 Mask:255.255.240.0 eth1
inet addr:172.16.0.111 Bcast:172.16.255.255 Mask:255.255.0.0 eht2 SourceByrd's Weblog-https://note.t4x.org/system/drbd-configure-install/
硬盘分区:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[root@DB1 /]# fdisk -l|grep /dev/sdb Disk /dev/sdb: 21.5 GB, 21474836480 bytes [root@DB2 drbd-utils-8.9.6]# fdisk -l|grep /dev/sdb Disk /dev/sdb: 53.7 GB, 53687091200 bytes [root@DB1 /]# parted /dev/sdb mklabel gpt yes && parted /dev/sdb mklabel gpt yes [root@DB1 /]# parted /dev/sdb mkpart data ext4 0 20G ignore [root@DB1 /]# parted /dev/sdb mkpart meta ext4 20G 21.5G ignore [root@DB1 /]# partprobe [root@DB1 /]# mkfs.ext4 /dev/sdb1 [root@DB1 /]# tune2fs -c -1 /dev/sdb1 [root@DB2 byrd]# parted /dev/sdb mkpart data ext4 0 52G ignore [root@DB2 byrd]# parted /dev/sdb mkpart meta ext4 52G 53.7G ignore [root@DB2 byrd]# partprobe [root@DB2 byrd]# mkfs.ext4 /dev/sdb1 |
编译安装drbd+drbd-utils:
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 |
[root@DB1 ~]# cd /byrd/tools [root@DB1 tools]# wget https://www.drbd.org/download/drbd/9.0/drbd-9.0.3-1.tar.gz [root@DB1 tools]# tar zxf drbd-9.0.3-1.tar.gz [root@DB1 tools]# cd drbd-9.0.3-1 [root@DB1 drbd-9.0.3-1]# make KDIR=/usr/src/kernels/$(uname -r)/ && make install ======================================================================= With DRBD module version 8.4.5, we split out the management tools into their own repository at http://git.linbit.com/drbd-utils.git (tarball at http://oss.linbit.com/drbd) That started out as "drbd-utils version 8.9.0", and provides compatible drbdadm, drbdsetup and drbdmeta tools for DRBD module versions 8.3, 8.4 and 9. Again: to manage DRBD 9 kernel modules and above, you want drbd-utils >= 8.9.5 from above url. ======================================================================= [root@DB1 tools]# wget http://oss.linbit.com/drbd/drbd-utils-8.9.6.tar.gz [root@DB1 tools]# tar zxf drbd-utils-8.9.6.tar.gz [root@DB1 tools]# cd drbd-utils-8.9.6 [root@DB1 drbd-utils-8.9.6]# yum install flex flex-devel libxslt parted docbook-style-xsl -y [root@DB1 drbd-utils-8.9.6]# ./configure --prefix=/byrd/service/drbd-utils-8.9.6 --mandir=/usr/share/man [root@DB1 drbd-utils-8.9.6]# make && make install [root@DB1 drbd-utils-8.9.6]# cp /byrd/service/drbd-utils-8.9.6/etc/drbd.conf /byrd/service/drbd-utils-8.9.6/etc/drbd.conf.bk [root@DB1 drbd-utils-8.9.6]# cp /byrd/service/drbd-utils-8.9.6/etc/drbd.d/global_common.conf /byrd/service/drbd-utils-8.9.6/etc/drbd.d/global_common.conf.bk |
配置drbd:
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 68 69 70 71 72 |
[root@DB1 /]# lsmod | grep drbd [root@DB1 /]# modprobe drbd [root@DB1 /]# lsmod | grep drbd drbd 485008 0 libcrc32c 1246 1 drbd [root@DB1 /]# cat /byrd/service/drbd-utils-8.9.6/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; # 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 3389; } } resource data { on DB1.mysql.hz.t4x.org { device /dev/drbd0; disk /dev/sdb1; address 172.16.0.110:7788; meta-disk /dev/sdb2 [0]; } on DB2.mysql.hz.t4x.org { device /dev/drbd0; disk /dev/sdb1; address 172.16.0.111:7788; meta-disk /dev/sdb2 [0]; } } [root@DB1 /]# drbdadm create-md data initializing activity log NOT initializing bitmap Writing meta data... New drbd meta data block successfully created. [root@DB1 /]# mkdir /byrd/service/drbd-utils-8.9.6/var/run [root@DB1 /]# drbdadm up data Device '0' is configured! Command 'drbdmeta 0 v09 /dev/sdb2 0 apply-al' terminated with exit code 20 |