DRBD

参考 URL
http://www.drbd.jp/doc_biginer.html
http://www.drbd.jp/users-guide/users-guide.html

---------------------------------------
192.168.84.130 51.domain.com -- service
192.168.17.131 51.domain.com -- DRBD

192.168.84.129 52.domain.com -- service
192.168.17.132 52.domain.com -- DRBD
---------------------------------------

/etc/drbd.conf
---------------------------------------
global {
usage-count no;
}

common {
syncer { rate 10M; }
}


resource r0 {

protocol C;

handlers {
pri-on-incon-degr "echo o > /proc/sysrq-trigger ; halt -f";
}

startup {
wfc-timeout 120;
degr-wfc-timeout 120; # 2 minutes.
}

disk {
on-io-error detach;
}


on 51.domain.com {
device /dev/drbd0;
disk /dev/sdb2;
address 192.168.17.131:7788;
meta-disk /dev/sdb1[0];
}

on 52.domain.com {
device /dev/drbd0;
disk /dev/sdb2;
address 192.168.17.132:7788;
meta-disk /dev/sdb1[0];
}
}
---------------------------------------


メタデータの作成

[root@51 ~]# drbdadm create-md r0
v08 Magic number not found
v07 Magic number not found
Writing meta data...
initialising activity log
NOT initialized bitmap
New drbd meta data block sucessfully created.
[root@51 ~]#

[root@52 ~]#
[root@52 ~]# drbdadm create-md r0
v08 Magic number not found
v07 Magic number not found
Writing meta data...
initialising activity log
NOT initialized bitmap
New drbd meta data block sucessfully created.
[root@52 ~]#


・サービス起動
(1) プライマリ側

[root@51 ~]# service drbd start
Starting DRBD resources: [ d(r0) s(r0) n(r0) ].
..........
***************************************************************
DRBD's startup script waits for the peer node(s) to appear.
- In case this node was already a degraded cluster before the
reboot the timeout is 120 seconds. [degr-wfc-timeout]
- If the peer was available before the reboot the timeout will
expire after 120 seconds. [wfc-timeout]
(These values are for resource 'r0'; 0 sec -> wait forever)
To abort waiting enter 'yes' [ 119]:
[root@51 ~]# service drbd status
drbd driver loaded OK; device status:
version: 8.2.6 (api:88/proto:86-88)
GIT-hash: 3e69822d3bb4920a8c1bfdf7d647169eba7d2eb4 build by buildsvn@c5-x8664-build, 2008-10-03 11:30:17
m:res cs st ds p mounted fstype
0:r0 WFConnection Secondary/Unknown Inconsistent/DUnknown C
接続状態★^^^^^^ ^^^^^^^^^^^^^^^^^^^★DRBD の状態
[root@51 ~]#


(2) セカンダリ側

[root@52 ~]# service drbd start
Starting DRBD resources: [ d(r0) s(r0) n(r0) ].
[root@52 ~]#
[root@52 ~]# service drbd status
drbd driver loaded OK; device status:
version: 8.2.6 (api:88/proto:86-88)
GIT-hash: 3e69822d3bb4920a8c1bfdf7d647169eba7d2eb4 build by buildsvn@c5-x8664-build, 2008-10-03 11:30:17
m:res cs st ds p mounted fstype
0:r0 Connected Secondary/Secondary Inconsistent/Inconsistent C
接続状態★^^^^^^ ^^^^^^^^^^^^^^^^^^^★DRBD の状態
[root@52 ~]#


(3) プライマリ側

[root@51 ~]# service drbd status
drbd driver loaded OK; device status:
version: 8.2.6 (api:88/proto:86-88)
GIT-hash: 3e69822d3bb4920a8c1bfdf7d647169eba7d2eb4 build by buildsvn@c5-x8664-build, 2008-10-03 11:30:17
m:res cs st ds p mounted fstype
0:r0 Connected Secondary/Secondary Inconsistent/Inconsistent C
接続状態★^^^^^^ ^^^^^^^^^^^^^^^^^^^★DRBD の状態
[root@51 ~]#


・プライマリ側を Primary に移行 (初期フル同期作業の実行)

[root@51 ~]# drbdadm -- --overwrite-data-of-peer primary all
[root@51 ~]# service drbd status
drbd driver loaded OK; device status:
version: 8.2.6 (api:88/proto:86-88)
GIT-hash: 3e69822d3bb4920a8c1bfdf7d647169eba7d2eb4 build by buildsvn@c5-x8664-build, 2008-10-03 11:30:17
m:res cs st ds p mounted fstype
0:r0 SyncSource Primary/Secondary UpToDate/Inconsistent C
... sync'ed: 0.8% (8024/8087)M
[root@51 ~]#
[root@51 ~]# service drbd status
drbd driver loaded OK; device status:
version: 8.2.6 (api:88/proto:86-88)
GIT-hash: 3e69822d3bb4920a8c1bfdf7d647169eba7d2eb4 build by buildsvn@c5-x8664-build, 2008-10-03 11:30:17
m:res cs st ds p mounted fstype
0:r0 SyncSource Primary/Secondary UpToDate/Inconsistent C
... sync'ed: 3.0% (7851/8087)M
[root@51 ~]#

[root@52 ~]# service drbd status
drbd driver loaded OK; device status:
version: 8.2.6 (api:88/proto:86-88)
GIT-hash: 3e69822d3bb4920a8c1bfdf7d647169eba7d2eb4 build by buildsvn@c5-x8664-build, 2008-10-03 11:30:17
m:res cs st ds p mounted fstype
0:r0 SyncTarget Secondary/Primary Inconsistent/UpToDate C
... sync'ed: 45.3% (4431/8087)M
[root@52 ~]#


[root@51 ~]# service drbd status
drbd driver loaded OK; device status:
version: 8.2.6 (api:88/proto:86-88)
GIT-hash: 3e69822d3bb4920a8c1bfdf7d647169eba7d2eb4 build by buildsvn@c5-x8664-build, 2008-10-03 11:30:17
m:res cs st ds p mounted fstype
0:r0 Connected Primary/Secondary UpToDate/UpToDate C
[root@51 ~]#


[root@52 ~]# service drbd status
drbd driver loaded OK; device status:
version: 8.2.6 (api:88/proto:86-88)
GIT-hash: 3e69822d3bb4920a8c1bfdf7d647169eba7d2eb4 build by buildsvn@c5-x8664-build, 2008-10-03 11:30:17
m:res cs st ds p mounted fstype
0:r0 Connected Secondary/Primary UpToDate/UpToDate C
[root@52 ~]#


ファイルシステムの作成

(1) プライマリ側

[root@51 ~]# mke2fs -j /dev/drbd0
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1036288 inodes, 2070376 blocks
103518 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2122317824
64 block groups
32768 blocks per group, 32768 fragments per group
16192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@51 ~]#
[root@51 ~]# mkdir /data
[root@51 ~]# mount /dev/drbd0 /data/
[root@51 ~]# df
Filesystem 1K-ブロック 使用 使用可 使用% マウント位置
/dev/mapper/VolGroup00-LogVol00
7237104 3280888 3582664 48% /
/dev/sda1 101086 13038 82829 14% /boot
tmpfs 189116 0 189116 0% /dev/shm
/dev/drbd0 8151384 149412 7587900 2% /data
[root@51 ~]#


(2) セカンダリ側 (こちらでの作業は NG)

[root@52 ~]# mke2fs -j /dev/drbd0
mke2fs 1.39 (29-May-2006)
mke2fs: 不正なメディア形式です while trying to determine filesystem size
[root@52 ~]#
[root@52 ~]#
[root@52 ~]#
[root@52 ~]# df
Filesystem 1K-ブロック 使用 使用可 使用% マウント位置
/dev/mapper/VolGroup00-LogVol00
7237104 3276596 3586956 48% /
/dev/sda1 101086 13037 82830 14% /boot
tmpfs 189116 0 189116 0% /dev/shm
[root@52 ~]# mkdir /data
[root@52 ~]#
[root@52 ~]# mount /dev/drbd0 /data/
mount: ブロックデバイス /dev/drbd0 は書き込み禁止です、読込み専用でマウントします
mount: 不正なメディア形式です
[root@52 ~]#
[root@52 ~]#
[root@52 ~]# df
Filesystem 1K-ブロック 使用 使用可 使用% マウント位置
/dev/mapper/VolGroup00-LogVol00
7237104 3276600 3586952 48% /
/dev/sda1 101086 13037 82830 14% /boot
tmpfs 189116 0 189116 0% /dev/shm
[root@52 ~]#
[root@52 ~]#