LinuxServer RAIDについて その7
前回はRAIDのテストなどについて記載した。
今回は不良になったディスクをRAIDグループから削除したり、
新たにディスクを追加する方法を記載する
RAIDグループに参加するディスクの操作
RAIDグループからディスクの削除
強制的にRAIDグループから(F)のついたパーティションを削除する場合は以下のコマンドでできる。
1 | [root@gestos01 ~] # mdadm --manage /dev/md0 --remove /dev/xvdb1 |
新規ディスクの追加
XenのDom0側で以下のコマンドで新たなディスクを追加する
今回は1Gのディスクを追加してみる
1 2 3 | [root@hostos01 images] # dd if=/dev/zero of=/var/lib/xen/images/gestos01_d4.img bs=1M count=1 seek=1M [root@hostos01 images] # xm block-attach gestos01 file://var/lib/xen/images/gestos01_d4.img /dev/xvdd w |
追加されたディスクの確認
XenのDom0側から新たにディスクをアタッチ(/dev/xvdd)してこれをRAID1グループに追加してみる。
まずディスクの状態を確認する
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | [root@charlie images] # fdisk -l Disk /dev/xvda : 8388 MB, 8388608000 bytes 255 heads, 63 sectors /track , 1019 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/xvda1 * 1 13 104391 83 Linux /dev/xvda2 14 1019 8080695 8e Linux LVM Disk /dev/xvdb : 1074 MB, 1074790400 bytes 255 heads, 63 sectors /track , 130 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/xvdb1 1 130 1044193+ 83 Linux Disk /dev/xvdc : 2148 MB, 2148532224 bytes 255 heads, 63 sectors /track , 261 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/xvdc1 1 261 2096451 83 Linux Disk /dev/md0 : 1069 MB, 1069154304 bytes 2 heads, 4 sectors /track , 261024 cylinders Units = cylinders of 8 * 512 = 4096 bytes Disk /dev/md0 doesn't contain a valid partition table Disk /dev/xvdd : 1074 MB, 1074790400 bytes 255 heads, 63 sectors /track , 130 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/xvdd doesn't contain a valid partition table |
パーティションの作成
追加したディスク(/dev/xvdd)に新たなパーティションを作成する
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | [root@gestos01 ~] # fdisk /dev/xvdd Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-130, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-130, default 130): Using default value 130 Command (m for help): p Disk /dev/xvdd : 1074 MB, 1074790400 bytes 255 heads, 63 sectors /track , 130 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/xvdd1 1 130 1044193+ 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re- read partition table. Syncing disks. |
新たに追加したパーティションをRAIDアレイに参加させる。
参加させる前のRAIDの状態
1 2 3 4 5 6 | [root@gestos01 ~] # cat /proc/mdstat Personalities : [raid1] md0 : active raid1 xvdc1[1] 1044096 blocks [2 /1 ] [_U] unused devices: <none> |
以下のコマンドでRAIDアレイにディスクを追加できる。
ちなみに/dev/md0がマウントをしているディレクトリをアンマウントする必要はない
1 2 3 4 5 6 7 8 9 10 | [root@gestos01 ~] # mdadm /dev/md0 -a /dev/xvdd1 mdadm: added /dev/xvdd1 [root@gestos01 ~] # [root@gestos01 ~] # cat /proc/mdstat Personalities : [raid1] md0 : active raid1 xvdd1[2] xvdc1[1] 1044096 blocks [2 /1 ] [_U] [=>...................] recovery = 9.9% (103884 /1044096 ) finish=0.4min speed=34628K /sec unused devices: <none> |
追加コマンドを入力してから下記のコマンドをすぐに実行すると、ディスクが追加される様子がうかがえる。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | [root@gestos01 ~] # cat /proc/mdstat Personalities : [raid1] md0 : active raid1 xvdd1[2] xvdc1[1] 1044096 blocks [2 /1 ] [_U] [====>................] recovery = 22.6% (237292 /1044096 ) finish=0.4min speed=29661K /sec unused devices: <none> [root@gestos01 ~] # cat /proc/mdstat Personalities : [raid1] md0 : active raid1 xvdd1[2] xvdc1[1] 1044096 blocks [2 /1 ] [_U] [========>............] recovery = 41.8% (437844 /1044096 ) finish=0.3min speed=27365K /sec unused devices: <none> [root@gestos01 ~] # cat /proc/mdstat Personalities : [raid1] md0 : active raid1 xvdd1[2] xvdc1[1] 1044096 blocks [2 /1 ] [_U] [==================>..] recovery = 90.6% (947804 /1044096 ) finish=0.0min speed=26160K /sec unused devices: <none> |
ディスクの追加が完了した。
1 2 3 4 5 6 | [root@gestos01 ~] # cat /proc/mdstat Personalities : [raid1] md0 : active raid1 xvdd1[0] xvdc1[1] 1044096 blocks [2 /2 ] [UU] unused devices: <none> |
今回はここまでで次回は追加したディスクの状態を確認してみる