文書更新:2018年05月30日(水) 午後8時18分06秒

Home > 備忘録 > Raid に関すること > Raid の新規構築( 79 )

Raidの新規構築

稼働中のシステムに2台のHDD(2T)を追加して、データ用Raid1(ミラーリング)を構築する手順を記録する。追加したHDDは/homeにmountすることにする。
  1. /etc/fstabを確認しておく。
  2. [root@server]# vi /etc/fstab
    #
    # /etc/fstab
    # Created by anaconda on Thu Mar 11 18:43:10 2010
    #
    # Accessible filesystems, by reference, are maintained under '/dev/disk'
    # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
    #
    /dev/mapper/vg_leom-lv_root /                       ext4    defaults,acl        1 1
    /dev/mapper/vg_leom-lv_swap swap                    swap    defaults        0 0
    tmpfs                   /dev/shm                tmpfs   defaults        0 0
    sysfs                   /sys                    sysfs   defaults        0 0
    proc                    /proc                   proc    defaults        0 0
  3. fdiskで追加する2台のHDDのパーティションを切る。パーティションのタイプをfd(Linux raid 自動検出)に変更する。
  4. fdisk でのパーティションの切りかたは、別のサイトで確認してください。ここでは、省略します。
  5. mdadmコマンドでRaidの構成をする。/dev/sdb1と/dev/sdc1をRaid1アレイとして/dev/md0に割り当てる。
  6. [root@server]# mdadm --create /dev/md0 --level=raid1 --raid-devices=2 /dev/sdb1 /dev/sdc1
    mdadm: partition table exists on /dev/sdb1 but will be lost or
           meaningless after creating array
    mdadm: Note: this array has metadata at the start and
        may not be suitable as a boot device.  If you plan to
        store '/boot' on this device please ensure that
        your boot-loader understands md/v1.x metadata, or use
        --metadata=0.90
    mdadm: partition table exists on /dev/sdc1 but will be lost or
           meaningless after creating array
    Continue creating array? y
    mdadm: Defaulting to version 1.2 metadata
    mdadm: array /dev/md0 started.
  7. Raidアレイをフォーマットする。終了すると自動的にディスクの同期が始まる。
  8. [root@server]# mkfs.ext4 -j /dev/md0
    mke2fs 1.41.12 (17-May-2010)
    Filesystem label=
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    Stride=0 blocks, Stripe width=0 blocks
    122101760 inodes, 488378100 blocks
    24418905 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=0
    14905 block groups
    32768 blocks per group, 32768 fragments per group
    8192 inodes per group
    Superblock backups stored on blocks: 
    	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    	4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
    	102400000, 214990848
    
    Writing inode tables: done                            
    Creating journal (32768 blocks): done
    Writing superblocks and filesystem accounting information: done
    
    This filesystem will be automatically checked every 29 mounts or
    180 days, whichever comes first.  Use tune2fs -c or -i to override.
    次のコマンドで同期の進捗状況を確認できる。
    [root@server]# cat /proc/mdstat
    Personalities : [raid1] 
    md0 : active raid1 sdc1[1] sdb1[0]
          1953512400 blocks super 1.2 [2/2] [UU]
          [>....................]  resync =  1.2% (23460096/1953512400) finish=688.0min speed=46754K/sec
          
    unused devices: <none>
  9. /etc/mdadm.confを作成して、以下のようにデバイスの定義を行う。
  10. DEVICE /dev/sd1
    ARRAY /dev/md0 devices=/dev/sdb1,/dev/sdc1
  11. 現在の/homeをRAIDアレイにコピーする。
  12. [root@server]# mount /dev/md0 /mnt	←RAIDアレイを/mntに仮マウント
    
    [root@server]# rsync -av /home/ /mnt/
  13. 最後に、/etc/fstabに以下の設定を追加する。
  14. /dev/md0            /home          ext4      defaults,acl    0 0
  15. システムを再起動して、/dev/md0が/homeにマウントされていることを確認する。
  16. [root@server]# mount
    /dev/mapper/vg_leom-lv_root on / type ext4 (rw)
    proc on /proc type proc (rw)
    sysfs on /sys type sysfs (rw)
    devpts on /dev/pts type devpts (rw,gid=5,mode=620)
    tmpfs on /dev/shm type tmpfs (rw)
    /dev/sda1 on /boot type ext4 (rw)
    /dev/md0 on /home type ext4 (rw,acl)
    none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
    sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
    fusectl on /sys/fs/fuse/connections type fusectl (rw)
    
    
    [root@server ~]# df -h
    Filesystem            Size  Used Avail Use% マウント位置
    /dev/mapper/vg_leom-lv_root
                           99G   34G   60G  37% /
    tmpfs                 496M  260K  496M   1% /dev/shm
    /dev/sda1             194M   60M  125M  33% /boot
    /dev/md0              1.8T   33G  1.7T   2% /home