系统环境:
0 1 2 3 4 5 |
[root@imgbk01 ~]# uname -n imgbk01.t4x.org [root@imgbk01 ~]# uname -r 2.6.32-642.el6.x86_64 [root@imgbk01 ~]# cat /etc/redhat-release CentOS release 6.4 (Final) |
IP分配:
0 1 2 3 4 5 6 7 |
VIP=1.1.1.180 MASTER=X.X.X.80 SLAVE=X.X.X.81 [root@imgbk01 ~]# ifconfig | grep "inet add" inet addr:1.1.1.80 模拟外网IP inet addr:10.162.32.80 模拟内网 eth1 inet addr:10.0.0.80 模拟心跳线 eth2 inet addr:172.28.0.80 DRBD数据传输 eth3 |
准备工作:
一、配置时间同步
0 1 2 |
[root@imgbk01 ~]# /usr/sbin/ntpdate time.windows.com #通过yum install ntpdate安装 [root@imgbk02 ~]# /usr/sbin/ntpdate time.windows.com 29 May 00:51:45 ntpdate[1639]: step time server 40.69.40.157 offset 4.223058 sec |
二、配置/etc/hosts文件【主、备同时】
0 1 2 3 4 |
[root@imgbk01 ~]# echo "10.0.0.80 imgbk01.t4x.org" >>/etc/hosts [root@imgbk01 ~]# echo "10.0.0.81 imgbk02.t4x.org" >>/etc/hosts [root@imgbk01 ~]# tail -2 /etc/hosts 10.0.0.80 imgbk01.t4x.org 10.0.0.81 imgbk02.t4x.org |
三、配置心跳线、数据传输主机路由
0 1 2 3 4 5 6 7 8 9 |
[root@imgbk01 ~]# echo "/sbin/route add -host 10.0.0.81 dev eth2" >>/etc/rc.local [root@imgbk01 ~]# echo "/sbin/route add -host 172.28.0.81 dev eth3" >>/etc/rc.local [root@imgbk02 ~]# echo "/sbin/route add -host 10.0.0.80 dev eth2" >>/etc/rc.local [root@imgbk02 ~]# echo "/sbin/route add -host 172.28.0.80 dev eth3" >>/etc/rc.local [root@imgbk02 ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 10.0.0.80 0.0.0.0 255.255.255.255 UH 0 0 0 eth2 172.28.0.80 0.0.0.0 255.255.255.255 UH 0 0 0 eth3 |
四、安装heartbeat【主、备同时】
0 1 2 3 4 |
[root@imgbk01 ~]# yum install epel-release -y [root@imgbk01 ~]# cp /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.bk [root@imgbk01 ~]# sed -i "s#\#baseurl#baseurl#g" /etc/yum.repos.d/epel.repo [root@imgbk01 ~]# sed -i "s#mirrorlist#\#mirrorlist#" /etc/yum.repos.d/epel.repo [root@imgbk01 ~]# yum install heartbeat -y |
配置:
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 |
[root@imgbk01 ~]# echo "auth 1" >/etc/ha.d/authkeys [root@imgbk01 ~]# echo "1 sha1 635b557bdcbfcdfb9c7e0e32c537e95aa192d02f" >>/etc/ha.d/authkeys [root@imgbk01 ~]# cat /etc/ha.d/ha.cf # Heartbeat Config debugfile /var/log/ha-debug logfile /var/log/ha-log logfacility local1 keepalive 2 deadtime 30 warntime 10 initdead 60 #bcast eth2 mcast eth2 225.0.0.99 695 1 0 auto_failback on node imgbk01.t4x.org node imgbk02.t4x.org crm no [root@imgbk01 ~]# echo "imgbk01.t4x.org IPaddr::1.1.1.180/24/eth0" >/etc/ha.d/haresources [root@imgbk01 ~]# chmod 600 /etc/ha.d/authkeys [root@imgbk01 ~]# chkconfig --list | grep heartbeat heartbeat 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@imgbk01 ~]# chkconfig heartbeat off [root@imgbk01 ~]# chkconfig nfs off [root@imgbk01 ~]# chkconfig rpcbind off [root@imgbk01 ~]# /usr/share/heartbeat/hb_standby #释放资源 [root@imgbk01 ~]# /usr/share/heartbeat/hb_takeover local #接管资源 |
五、分区、安装drbd
分区master:
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 |
[root@imgbk01 drbd-8.4.7-1]# parted /dev/sdb GNU Parted 2.1 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) mklabel New disk label type? gpt (parted) print free Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 1100GB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 17.4kB 1100GB 1100GB Free Space (parted) mkpart Partition name? []? data File system type? [ext2]? ext4 Start? 0 End? 1098000M Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? I (parted) print free Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 1100GB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 17.4kB 1098GB 1098GB data 1098GB 1100GB 1512MB Free Space (parted) mkpart Partition name? []? meta File system type? [ext2]? ext4 Start? 1098001M End? 1100G (parted) print free Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 1100GB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 17.4kB 1098GB 1098GB data 1098GB 1098GB 629kB Free Space 2 1098GB 1100GB 1510MB meta 1100GB 1100GB 1032kB Free Space (parted) q Information: You may need to update /etc/fstab. [root@imgbk01 drbd-8.4.7-1]# partprobe [root@imgbk01 drbd-8.4.7-1]# mkfs.ext4 /dev/sdb1 [root@imgbk01 drbd-8.4.7-1]# tune2fs -c -1 /dev/sdb1 |
分区slave:
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 |
(parted) mklabel New disk label type? gpt (parted) print free Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 2147GB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 17.4kB 2147GB 2147GB Free Space (parted) mkpart Partition name? []? data File system type? [ext2]? ext4 Start? 0 End? 2145G Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? I (parted) print free Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 2147GB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 17.4kB 2145GB 2145GB data 2145GB 2147GB 2484MB Free Space (parted) mkpart Partition name? []? meta File system type? [ext2]? ext4 Start? 2145G End? 2147G (parted) print free Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 2147GB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 17.4kB 2145GB 2145GB data 2145GB 2145GB 620kB Free Space 2 2145GB 2147GB 2482MB meta 2147GB 2147GB 1032kB Free Space |
安装drbd:新版本drbdadm已经和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 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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
[root@imgbk01 ~]# yum install flex flex-devel libxslt parted docbook-style-xsl -y [root@imgbk01 ~]# cd /byrd/tools/ [root@imgbk01 tools]# wget http://oss.linbit.com/drbd/drbd-utils-8.9.6.tar.gz [root@imgbk01 tools]# tar zxf drbd-utils-8.9.6.tar.gz [root@imgbk01 tools]# cd drbd-utils-8.9.6 [root@imgbk01 drbd-utils-8.9.6]# ./configure --prefix=/byrd/service/drbd-utils-8.9.6 --mandir=/usr/share/man [root@imgbk02 drbd-utils-8.9.6]# make && make install [root@imgbk01 tools]# wget http://oss.linbit.com/drbd/9.0/drbd-9.0.0.tar.gz [root@imgbk01 tools]# tar zxf drbd-9.0.0.tar.gz [root@imgbk01 tools]# cd drbd-9.0.0 [root@imgbk01 drbd-9.0.0]# make KDIR=/usr/src/kernels/$(uname -r) [root@imgbk01 drbd-9.0.0]# make install [root@imgbk01 drbd-9.0.0]# cp /byrd/service/drbd-utils-8.9.6/etc/drbd.conf /byrd/service/drbd-utils-8.9.6/etc/drbd.conf.bk [root@imgbk01 drbd-9.0.0]# 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 [root@imgbk01 /]# cat /byrd/service/drbd-utils-8.9.6/etc/drbd.conf # You can find an example in /usr/share/doc/drbd.../drbd.conf.example 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 imgbk01.t4x.org { device /dev/drbd0; disk /dev/sdb1; address 172.28.0.80:7788; meta-disk /dev/sdb2 [0]; } on imgbk02.t4x.org { device /dev/drbd0; disk /dev/sdb1; address 172.28.0.81:7788; meta-disk /dev/sdb2 [0]; } } [root@imgbk01 drbd-9.0.0]# vim /byrd/service/drbd-utils-8.9.6/etc/drbd.conf [root@imgbk01 drbd-9.0.0]# scp /byrd/service/drbd-utils-8.9.6/etc/drbd.conf root@1.1.1.81:/byrd/service/drbd-utils-8.9.6/etc/drbd.conf [root@imgbk01 drbd-9.0.0]# drbdadm create-md data initializing activity log NOT initializing bitmap Writing meta data... New drbd meta data block successfully created. [root@imgbk01 drbd-9.0.0]# mkdir /byrd/service/drbd-utils-8.9.6/var/run/drbd -p [root@imgbk01 drbd-9.0.0]# drbdadm up data Device '0' is configured! Command 'drbdmeta 0 v08 /dev/sdb2 0 apply-al' terminated with exit code 20 [root@imgbk01 drbd-9.0.0]# cat /proc/drbd version: 8.4.7-1 (api:1/proto:86-101) GIT-hash: 3a6a769340ef93b1ba2792c6461250790795db49 build by root@imgbk01.t4x.org, 2016-05-29 02:41:32 0: cs:StandAlone ro:Secondary/Unknown ds:Inconsistent/DUnknown r----s ns:0 nr:0 dw:0 dr:0 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:d oos:1072265612 [root@imgbk01 drbd-9.0.0]# drbdadm down data [root@imgbk01 drbd-9.0.0]# drbdadm up data [root@imgbk01 drbd-9.0.0]# cat /proc/drbd version: 8.4.7-1 (api:1/proto:86-101) GIT-hash: 3a6a769340ef93b1ba2792c6461250790795db49 build by root@imgbk01.t4x.org, 2016-05-29 02:41:32 0: 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:d oos:1072265612 [root@imgbk01 drbd-9.0.0]# drbdadm -- --overwrite-data-of-peer primary data [root@imgbk01 drbd-9.0.0]# cat /proc/drbd version: 8.4.7-1 (api:1/proto:86-101) GIT-hash: 3a6a769340ef93b1ba2792c6461250790795db49 build by root@imgbk01.t4x.org, 2016-05-29 02:41:32 0: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r----- ns:10608 nr:0 dw:0 dr:26901 al:0 bm:0 lo:0 pe:1 ua:69 ap:0 ep:1 wo:d oos:1072255372 [>....................] sync'ed: 0.1% (1047124/1047132)M finish: 28:38:21 speed: 10,240 (10,240) K/sec |
六、安装nfs:安装heartbeat时候yum自动安装rpcbind和nfs
0 |
错误:
0 1 2 3 4 5 |
make[1]: Entering directory `/byrd/tools/drbd-utils-8.9.6/documentation/v9' xsltproc -o drbdsetup.xml drbdsetup.xsl drbdsetup.xml.in make[1]: xsltproc: Command not found make[1]: *** [drbdsetup.xml] Error 127 make[1]: Leaving directory `/byrd/tools/drbd-utils-8.9.6/documentation/v9' make: *** [doc] Error 2 |
解决:
0 |
[root@imgbk01 drbd-utils-8.9.6]# yum install libxslt |
错误:
0 1 2 3 4 5 |
error : Operation in progress warning: failed to load external entity "http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl" cannot parse http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl make[1]: *** [drbdsetup.8] Error 4 make[1]: Leaving directory `/byrd/tools/drbd-utils-8.9.6/documentation/v9' make: *** [doc] Error 2 |
解决:
0 |
docbook-style-xsl |
错误:
0 1 2 3 4 5 |
[root@imgbk01 ~]# drbdadm create-md data /byrd/service/drbd-utils-8.9.6/etc/drbd.conf:25: Parse error: 'an option keyword' expected, but got 'unplug-watermark' [root@imgbk01 ~]# drbdadm create-md data /byrd/service/drbd-utils-8.9.6/etc/drbd.conf:41: Parse error: 'a syncer option keyword' expected, but got 'rate' |
解决:这个问题没有解决掉!!!
0 |
禁用相关模块 |
参考文档:
1:http://os.51cto.com/art/201412/461533_all.htm
2:http://blog.chinaunix.net/uid-25266990-id-3803277.html
3: SourceByrd's Weblog-https://note.t4x.org/system/heartbeat-drbd-nfs-config/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!