mdadm linux 做軟磁碟陣列 raid0

huzhichengforce發表於2015-02-14
第一步: 準備磁碟 
我虛擬機器已經新增好三塊盤
[root@oracle ~]# fdisk -l
Disk /dev/sde: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdf: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdg: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

2 第二步對磁碟分割槽和標記
[root@oracle ~]# fdisk /dev/sde
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x382d838f.
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)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').


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, +cylinders or +size{K,M,G} (1-130, default 130): 
Using default value 130


Command (m for help): t
Selected partition 1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)


Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

其它兩塊盤做同樣的分割槽和標記

3第三步建立raid組
mdadm --create --verbose /dev/md0 --level=0 --raid-devices=3 /dev/sde1 /dev/sdf1 /dev/sdg1

第四步 配置檔案

echo     DEVICE /dev/sd{e,f,g}1 >> /etc/mdadm.conf
mdadm  - -detail  - -scan >> /etc/mdadm.conf
第五步 穿件檔案系統
剛才建立的/dev/md0 現在可以做為一個磁碟裝置來使用
#mkfs.ext4 /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=128 blocks, Stripe width=384 blocks
195840 inodes, 782976 blocks
39148 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=805306368
24 block groups
32768 blocks per group, 32768 fragments per group
8160 inodes per group
Superblock backups stored on blocks: 
32768, 98304, 163840, 229376, 294912
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

第六步 掛載磁碟
mkdir /raid0test
mount /dev/md0 /raid0test
第七步  隨機啟動自掛載磁碟
將mount /dev/md0 /raid0test 命令寫入 /dev/rc.local 中
echo  mount /dev/md0 /raid0test >>/dev/rc.local 


第八步 檢視raid 資訊

[root@oracle ~]# cat /proc/mdstat
Personalities : [raid0] 
md0 : active raid0 sdg1[2] sdf1[1] sde1[0]
      3131904 blocks super 1.2 512k chunks
      
unused devices:
[root@oracle ~]# mdadm --detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Wed Feb 11 14:37:20 2015
     Raid Level : raid0
     Array Size : 3131904 (2.99 GiB 3.21 GB)
   Raid Devices : 3
  Total Devices : 3
    Persistence : Superblock is persistent


    Update Time : Wed Feb 11 14:37:20 2015
          State : clean 
 Active Devices : 3
Working Devices : 3
 Failed Devices : 0
  Spare Devices : 0


     Chunk Size : 512K


           Name : oracle:0  (local to host oracle)
           UUID : 2a4adf15:7f218c31:3f5fe32b:d27b7ca9
         Events : 0


    Number   Major   Minor   RaidDevice State
       0       8       65        0      active sync   /dev/sde1
       1       8       81        1      active sync   /dev/sdf1
       2       8       97        2      active sync   /dev/sdg1


這裡使用的是一個mdadm 做的軟raid

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26764973/viewspace-1435969/,如需轉載,請註明出處,否則將追究法律責任。

相關文章