磁盘阵列  Raid

 

磁盘列阵:是把多个磁盘设备合并成一个磁盘空间

  硬件RAID: 优点,好管理、性能高。 缺点,价钱高。

  软件RAID: 优点,成本低。 缺点,会多消耗20%的系统资源

 

功能:  整合闲置的磁盘空间

                   提高磁盘读取效率

                   提供容错性

 

磁盘列阵差异表:

 

磁盘列阵  Raid_空间



 

进行Raid 5 配置

 

 

1.       进行磁盘分区

现有三磁盘sda 、sdb 、 sdc

[root@www ~]# fdisk /dev/sda                磁盘分区 sda2

[root@www ~]# fdisk /dev/sdb                                     磁盘分区 sdb2

[root@www ~]# fdisk /dev/sdc                                     磁盘分区 sdc2

 

The number of cylinders for this disk is set to 13054.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

   (e.g., DOS FDISK, OS/2 FDISK)

 

Command (m for help): n

Command action

    extended

    primary partition (1-4)

p

Partition number (1-4): 2

First cylinder (367-13054, default 367):

Using default value 367

Last cylinder or +size or +sizeM or +sizeK (367-13054, default 13054): +3000M

 

Command (m for help): t

Partition number (1-4): 2

Hex code (type L to list codes): fd      (linux raid)

Changed system type of partition 2 to fd (Linux raid autodetect)

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

 

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.

The kernel still uses the old table.

The new table will be used at the next reboot.

Syncing disks.

2.       [root@www ~]# vim /etc/mdadm.conf         设置mdadm的主配置文件

 

磁盘列阵  Raid_空间_02



 

[root@www ~]#madam -C /dev/md2 --level 1 --raid-devices 3 /dev/sda2 /dev/sdb2 /dev/sdc2

   初始化多重磁盘设备     (md2是新建的  level是级别   --raid-devices 3是组成数量)

[root@www ~]#mdadm -D /dev/md2        mdadm –detail /dev/md2

                                                      查看磁盘列阵的详细信息

[root@www ~]#mdadm /dev/md2 --set-faulty /dev/sdb2

                                                        模拟一块磁盘分区sdb2出现故障“有faulty字样”

[root@www ~]#mdadm /dev/md2 –remove /dev/sdb2

                                                        移除坏的磁盘分区sdb2

[root@www ~]#mdadm /dev/md2 --add /dev/sdb3

                                                        重新添加一块好的磁盘sdb3

 

 

 

 

 

停用磁盘列阵  raid

#mdadm --stop /dev/md2  

启用磁盘列阵 raid

         #mdadm --assemble --scan /dev/md2      #mdadm -A --scan /dev/md2

 

 

 

 附加:

   大于2T的磁盘,分区时最好用parted         parted /dev/sda rm 1    删除第一块分区

 

 

 

查看对应厂商和对应的raid类型           dmraid –l

 

读取磁盘列阵设备:       dmraid  –r

   

启动raid     dmraid  -a  y

停用raid          dmraid  -a  n