[root@node1 drbd.d]# vim web.res
1resource web {
2 on node1.a.com {
3 device /dev/drbd0;
4 disk /dev/sdb;
5 address 192.168.3.10:7789;
6 meta-disk internal;
7 }
8
9 on node2.a.com {
10 device /dev/drbd0;
11 disk /dev/sdb;
12 address 192.168.3.20:7789;
13 meta-disk internal;
14 }
15 }
在启动DRBD之前,需要创建供DRBD记录信息的数据块.分别在两台主机上执行
[root@node1 ~]# drbdadm create-md web
启动DRBD
[root@node1 ~]# service drbd start
[root@node1 ~]# chkconfig drbd on
到此,在node2上重复以上的过程,这里不再列出
查看DRBD的状态
[root@node1 ~]# cat /proc/drbd
version: 8.3.8(api:88/proto:86-94)
GIT-hash: d78846e52224fd00562f7c225bcc25b2d422321d build bymockbuild@builder10.CentOS.org, 2010-06-04 08:04:16
0:cs:Connected ro:Secondary/Secondary ds:Inconsistent/Diskless 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:5242684
也可以用下面这种方式查看
[root@node1 ~]# drbd-overview
0:web Connected Secondary/Secondary Inconsistent/Diskless C r----
现在两台主机都是备机状态,都是”不一致”状态,这是由于DRBD无法判断哪一方为主机,以哪一方的磁盘数据作为标准数据。所以我们需要初始化,在node1上执行:
[root@node1 ~]# drbdsetup /dev/drbd0 primary -o
[root@node1 ~]# cat /proc/drbd
version: 8.3.8(api:88/proto:86-94)
GIT-hash: d78846e52224fd00562f7c225bcc25b2d422321d build bymockbuild@builder10.centos.org, 2010-06-04 08:04:16
0:cs:Connected ro:Primary/Secondary ds:UpToDate/Diskless C r----
ns:0 nr:0 dw:0dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:b oos:5242684
将硬盘格式化
[root@node1 ~]# mkfs -t ext3 -L drbdweb /dev/drbd0
挂载到web默认站点目录下
[root@node1 ~]# mount /dev/drbd0 /var/www/html/
[root@node1 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 9920624 2671432 6737124 29% /
/dev/sda1 101086 11373 84494 12% /boot
tmpfs 30264 0 30264 0% /dev/shm
/dev/drbd0 5160380 141440 4756808 3% /var/www/html