http://www.oss-d.net/index.php?NFS%2FHA
マシン構成
- ホスト1
- 役割 : プライマリサーバ
- ホスト名 : c5-dev01
- IPアドレス : 192.168.0.201
- ホスト2
- 役割 : セカンダリサーバ
- ホスト名 : c5-dev02
- IPアドレス : 192.168.0.202
[root@c5-dev01 ~]# yum install drbd83
[root@c5-dev01 ~]# yum install kmod-drbd83
[root@c5-dev01 ~]# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = シリンダ数 of 16065 * 512 = 8225280 bytes
デバイス Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 982 7783492+ 83 Linux
/dev/sda3 983 1047 522112+ 82 Linux swap / Solaris
[root@c5-dev01 ~]# fdisk /dev/sda
このディスクのシリンダ数は 1305 に設定されています。
間違いではないのですが、1024 を超えているため、以下の場合
に問題を生じうる事を確認しましょう:
1) ブート時に実行するソフトウェア (例. バージョンが古い LILO)
2) 別の OS のブートやパーティション作成ソフト
(例. DOS FDISK, OS/2 FDISK)
コマンド (m でヘルプ): p
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = シリンダ数 of 16065 * 512 = 8225280 bytes
デバイス Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 982 7783492+ 83 Linux
/dev/sda3 983 1047 522112+ 82 Linux swap / Solaris
コマンド (m でヘルプ): n
コマンドアクション
e 拡張
p 基本領域 (1-4)
e
Selected partition 4
最初 シリンダ (1048-1305, default 1048):
Using default value 1048
終点 シリンダ または +サイズ または +サイズM または +サイズK (1048-1305, default 1305):
Using default value 1305
コマンド (m でヘルプ): p
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = シリンダ数 of 16065 * 512 = 8225280 bytes
デバイス Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 982 7783492+ 83 Linux
/dev/sda3 983 1047 522112+ 82 Linux swap / Solaris
/dev/sda4 1048 1305 2072385 5 拡張領域
コマンド (m でヘルプ): n
最初 シリンダ (1048-1305, default 1048):
Using default value 1048
終点 シリンダ または +サイズ または +サイズM または +サイズK (1048-1305, default 1305): +200M
コマンド (m でヘルプ): p
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = シリンダ数 of 16065 * 512 = 8225280 bytes
デバイス Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 982 7783492+ 83 Linux
/dev/sda3 983 1047 522112+ 82 Linux swap / Solaris
/dev/sda4 1048 1305 2072385 5 拡張領域
/dev/sda5 1048 1072 200781 83 Linux
コマンド (m でヘルプ): n
最初 シリンダ (1073-1305, default 1073):
Using default value 1073
終点 シリンダ または +サイズ または +サイズM または +サイズK (1073-1305, default 1305):
Using default value 1305
コマンド (m でヘルプ): w
領域テーブルは交換されました!
ioctl() を呼び出して領域テーブルを再読込みします。
警告: 領域テーブルの再読込みがエラー 16 で失敗しました: デバイスもしくはリソースがビジー状態です 。
カーネルはまだ古いテーブルを使っています。
新しいテーブルは次回リブート時に使えるようになるでしょう。
ディスクを同期させます。
[root@c5-dev01 ~]# cat /proc/partitions
major minor #blocks name
8 0 10485760 sda
8 1 104391 sda1
8 2 7783492 sda2
8 3 522112 sda3
[root@c5-dev01 ~]# shutdown -r now
[root@c5-dev01 ~]# cat /proc/partitions
major minor #blocks name
8 0 10485760 sda
8 1 104391 sda1
8 2 7783492 sda2
8 3 522112 sda3
8 4 1 sda4
8 5 200781 sda5
8 6 1871541 sda6
[root@c5-dev01 etc]# dd if=/dev/zero bs=1M count=1 of=/dev/sda5 ; sync
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.0246319 seconds, 42.6 MB/s
[root@c5-dev01 etc]# drbdadm create-md r0
'r0' ignored, since this host (c5-dev01) is not mentioned with an 'on' keyword.
[root@c5-dev01 etc]# uname -n
c5-dev01
[root@c5-dev01 etc]# vim drbd.conf
[root@c5-dev01 etc]# drbdadm create-md r0
Writing meta data...
initializing activity log
NOT initialized bitmap
New drbd meta data block successfully created.
[root@c5-dev01 etc]# /etc/init.d/drbd start
Starting DRBD resources: [
r0
Found valid meta data in the expected location, 0 bytes into /dev/sda5.
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 0 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' [ 20]:
To abort waiting enter 'yes' [ 24]:yes
[root@c5-dev01 etc]# chkconfig drbd on
[root@c5-dev01 etc]# scp /etc/drbd.conf 192.168.0.202:/etc/100% 609 0.6KB/s 00:00
root@192.168.0.202's password:
drbd.conf
[root@c5-dev01 etc]# /etc/init.d/drbd status
drbd driver loaded OK; device status:
version: 8.3.8 (api:88/proto:86-94)
GIT-hash: d78846e52224fd00562f7c225bcc25b2d422321d build by mockbuild@builder10.centos.org, 2010-06-04 08:04:16
m:res cs ro ds p mounted fstype
0:r0 Connected Secondary/Secondary Inconsistent/Inconsistent B
root@c5-dev02 ~]# /etc/init.d/drbd status
drbd driver loaded OK; device status:
version: 8.3.8 (api:88/proto:86-94)
GIT-hash: d78846e52224fd00562f7c225bcc25b2d422321d build by mockbuild@builder10.centos.org, 2010-06-04 08:04:16
m:res cs ro ds p mounted fstype
0:r0 Connected Secondary/Secondary Inconsistent/Inconsistent B
[root@c5-dev01 etc]# drbdadm -- --overwrite-data-of-peer primary r0
[root@c5-dev01 etc]# /etc/init.d/drbd status
drbd driver loaded OK; device status:
version: 8.3.8 (api:88/proto:86-94)
GIT-hash: d78846e52224fd00562f7c225bcc25b2d422321d build by mockbuild@builder10.centos.org, 2010-06-04 08:04:16
m:res cs ro ds p mounted fstype
0:r0 SyncSource Primary/Secondary UpToDate/Inconsistent B
... sync'ed: 0.9% (1855512/1871544)K delay_probe:
[root@c5-dev01 etc]# /etc/init.d/drbd status
drbd driver loaded OK; device status:
version: 8.3.8 (api:88/proto:86-94)
GIT-hash: d78846e52224fd00562f7c225bcc25b2d422321d build by mockbuild@builder10.centos.org, 2010-06-04 08:04:16
m:res cs ro ds p mounted fstype
0:r0 Connected Primary/Secondary UpToDate/UpToDate B
[root@c5-dev01 etc]# 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)
234240 inodes, 467885 blocks
23394 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=482344960
15 block groups
32768 blocks per group, 32768 fragments per group
15616 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information:
done
This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@c5-dev01 etc]# mkdir /data
[root@c5-dev01 etc]# mount -t ext3 /dev/drbd0 /data/
[root@c5-dev01 etc]# df -h
Filesystem サイズ 使用 残り 使用% マウント位置
/dev/sda2 7.2G 2.6G 4.3G 38% /
/dev/sda1 99M 23M 72M 24% /boot
tmpfs 125M 0 125M 0% /dev/shm
/dev/drbd0 1.8G 35M 1.7G 3% /data
[root@c5-dev01 etc]# /etc/init.d/drbd status
drbd driver loaded OK; device status:
version: 8.3.8 (api:88/proto:86-94)
GIT-hash: d78846e52224fd00562f7c225bcc25b2d422321d build by mockbuild@builder10.centos.org, 2010-06-04 08:04:16
m:res cs ro ds p mounted fstype
0:r0 Connected Primary/Secondary UpToDate/UpToDate B /data ext3
[root@c5-dev01 etc]# echo test > /data/test.txt
[root@c5-dev01 etc]# umount /data
[root@c5-dev01 etc]# drbdadm secondary r0
[root@c5-dev02 ~]# drbdadm primary r0
[root@c5-dev02 ~]# /etc/init.d/drbd status
drbd driver loaded OK; device status:
version: 8.3.8 (api:88/proto:86-94)
GIT-hash: d78846e52224fd00562f7c225bcc25b2d422321d build by mockbuild@builder10.centos.org, 2010-06-04 08:04:16
m:res cs ro ds p mounted fstype
0:r0 Connected Primary/Secondary UpToDate/UpToDate B
[root@c5-dev02 ~]# mkdir /data
[root@c5-dev02 ~]# mount -t ext3 /dev/drbd0 /data/
[root@c5-dev02 ~]# cat /data/test.txt
test