[root@node1 ~]# vim /etc/drbd.d/web.res
1 resource web {
2 on node1.a.com {
3 device /dev/drbd0;
4 disk /dev/sda5;
5 address 192.168.145.100:7789;
6 meta-disk internal;
7 }
8
9 on node2.a.com {
10 device /dev/drbd0;
11 disk /dev/sda5;
12 address 192.168.145.200:7789;
13 meta-disk internal;
14 }
15 }
[root@node1 ~]# scp /etc/drbd.d/* node2:/etc/drbd.d/
初始化已定义的资源并启动服务:
[root@node1 ~]# drbdadm create-md web
[root@node2 ~]# drbdadm create-md web
#启动服务:
[root@node1 ~]# service drbd start
[root@node2 ~]#service drbd start
设在主机点上执行
drbdadm -- --overwrite-data-of-peer primary web
然后查看同步过程
[root@node1 ~]# cat /proc/drbd
version: 8.3.8 (api:88/proto:86-94)
GIT-hash: d78846e52224fd00562f7c225bcc25b2d422321d build by mockbuild@builder10.centos.org, 2010-06-04 08:04:16
0: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r----
ns:456904 nr:0 dw:0 dr:465088 al:0 bm:27 lo:1 pe:14 ua:256 ap:0 ep:1 wo:b oos:1503320
[===>................] sync'ed: 23.4% (1503320/1959800)K delay_probe: 44
finish: 0:00:57 speed: 26,044 (25,360) K/sec
创建文件系统(在主节点上实现)
mkfs -t ext3 -L drbdweb /dev/drbd0
[root@node1 ~]# mkdir /web
[root@node1 ~]# mount /dev/drbd0 /web/
echo "hello" >index.html
测试,把node1变成从的,node2 变成主的
root@node1 ~]# umount /web
[root@node1 ~]# drbdadm secondary web
[root@node1 ~]# drbdadm role web
Secondary/Secondary
在node2 节点上,
[root@node2 ~]# mkdir /web
[root@node2 ~]# drbdadm primary web
[root@node2 ~]# drbd-overview
0:web Connected Primary/Secondary UpToDate/UpToDate C r----
[root@node2 ~]# drbdadm role web
Primary/Secondary
[root@node2 ~]# mount /dev/drbd0 /web
[root@node2 ~]# ll /web
total 20
-rw-r--r-- 1 root root 6 May 7 00:46 index.html
drwx------ 2 root root 16384 May 7 00:45 lost+found
root@node2 ~]# cd /web
[root@node2 web]# vim test.html
[root@node2 ~]# umount /web
[root@node2 ~]# drbdadm secondary web
切换到node1上
[root@node1 ~]# drbdadm primary web
[root@node1 ~]# mount /dev/drbd0 /web
[root@node1 ~]# ll /web
total 24
-rw-r--r-- 1 root root 6 May 7 00:46 index.html
drwx------ 2 root root 16384 May 7 00:45 lost+found
-rw-r--r-- 1 root root 13 May 7 00:58 test.html
置其中一个节点为主节点