[root@test01 ~]# mkfs.ext4/dev/drbd0
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
..
...
Writing superblocks andfilesystem accounting information: 完成
This filesystem will beautomatically checked every 33 mounts or
180 days, whichever comesfirst. Use tune2fs -c or -i to override.
[root@test01 ~]# tune2fs -c -1/dev/drbd0
tune2fs 1.41.12 (17-May-2010)
Setting maximal mount count to-1
1.2.5 挂载测试
[root@test01 ~]# mkdir /data
[root@test01 ~]# mount -t ext4/dev/drbd0 /data
[root@test01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 9.4G 1.5G 7.4G 17% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 190M 36M 145M 20% /boot
/dev/drbd0 991M 1.3M 939M 1% /data
[root@test01 ~]# touch/data/drbd.test
[root@test01 ~]# ls /data/
drbd.test lost+found
手动切换连个节点状态,并进行挂载测试
[root@test01 ~]# umount /data
[root@test01 ~]# drbdadmsecondary r1
[root@test01 ~]# cat/proc/drbd
version: 8.4.6(api:1/proto:86-101)
GIT-hash:833d830e0152d1e457fa7856e71e11248ccf3f70 build by root@test01, 2015-12-0710:40:31
0: cs:Connected ro:Secondary/Secondaryds:UpToDate/UpToDate C r-----
ns:1080828 nr:0 dw:33344 dr:1048921 al:10bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
将test01手动提升至primary。并将/dev/drbd0进行格式化以供挂在使用
[root@test02drbd-utils-8.9.2]# drbdadm primary r1
[root@test02drbd-utils-8.9.2]# cat /proc/drbd
version: 8.4.6(api:1/proto:86-101)
GIT-hash:833d830e0152d1e457fa7856e71e11248ccf3f70 build by root@test02, 2015-12-0710:40:31
0: cs:Connected ro:Primary/Secondaryds:UpToDate/UpToDate C r-----
ns:0 nr:1080828 dw:1080828 dr:664 al:0 bm:0lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
[root@test02 ~]# mkdir /data
[root@test02 ~]# mount -t ext4/dev/drbd0 /data
[root@test02 ~]# ls /data/
drbd.test lost+found
[root@test01 ~]# umount /data
[root@test01 ~]# drbdadmsecondary r1
现在drbd两个节点已经配置成功,并手动测试成功。drbd的两个节点,同时时间只有primary状态的节点提供服务。
1.3 配置nfs服务
test01 test02 web配置nfs的共享目录为/data ,test01 test02同时/dev/drbd0的挂载目录也是/data
1.3.1 将test01 drbd状态提升为primary并将/dev/drbd0挂载至/data,编辑/etc/exports文件,并本地测试。
[root@test01 ~]# cat/proc/drbd
version: 8.4.6(api:1/proto:86-101)
GIT-hash: 833d830e0152d1e457fa7856e71e11248ccf3f70build by root@test01, 2015-12-07 10:40:31
0: cs:Connected ro:Secondary/Secondaryds:UpToDate/UpToDate C r-----
ns:1080828 nr:8 dw:33352 dr:1048921 al:10bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
[root@test01 ~]# drbdadmprimary r1
[root@test01 ~]# mount -t ext4/dev/drbd0 /data
[root@test01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 9.4G 1.5G 7.4G 17% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 190M 36M 145M 20% /boot
/dev/drbd0 991M 1.3M 939M 1% /data
[root@test01 ~]# cat/etc/exports
/data172.16.1.0/24(rw,sync,all_squash)
[root@test01 ~]#/etc/init.d/rpcbind start
[root@test01 ~]#/etc/init.d/nfs start
[root@test01 ~]# chown -R nfsnobody.nfsnobody/data
[root@test01 ~]# showmount -e172.16.1.111
Export list for 172.16.1.111:
/data 172.16.1.0/24
[root@test01 ~]# mount -t nfs172.16.1.111:/data /mnt
[root@test01 ~]# ls /mnt
drbd.test lost+found
[root@test01 ~]# touch/mnt/test01.test
[root@test01 ~]# ls /mnt
drbd.test lost+found test01.test
1.3.2 将test01状态降为secondary,将test02状态提升为primary,并将/dev/drbd0挂载至/data,编辑/etc/exports文件,并本地测试
[root@test01 ~]# umount /mnt
[root@test01 ~]#/etc/init.d/nfs stop
[root@test01 ~]# umount /data
[root@test01 ~]# drbdadmsecondary r1
[root@test01 ~]# cat/proc/drbd
version: 8.4.6(api:1/proto:86-101)
GIT-hash:833d830e0152d1e457fa7856e71e11248ccf3f70 build by root@test01, 2015-12-0710:40:31
0: cs:Connected ro:Secondary/Secondaryds:UpToDate/UpToDate C r-----
ns:1080952 nr:8 dw:33476 dr:1049979 al:10bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0
[root@test02 ~]# drbdadm primary r1
[root@test02 ~]# mount -t ext4/dev/drbd0 /data
[root@test02 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 9.4G 1.5G 7.4G 17% /
tmpfs 495M 0 495M 0% /dev/shm
/dev/sda1 190M 36M 145M 20% /boot
/dev/drbd0 991M 1.3M 939M 1% /data
[root@test02 ~]# cat/etc/exports
/data172.1.6.0/24(rw,sync,all_squash)