存储Raid 10配置
环境CentOs 5.4:
Raid10原理:
创建Raid10,至少需要4块磁盘,以4块磁盘为例子(2D(mirroring)+2D(stripping))
对数据存入先做镜像(备份),而后做条带操作(数据分割),并行的写入磁盘中,即保证数据安全性,又提高数据存取速度.
其缺点:存储容量利用率低,单位成本非常高.
Raid10创建:
假设有如下4块磁盘:
/dev/sdb
/dev/sdc
/dev/sdd
/dev/sde
1.对每块磁盘分区,每块磁盘只一个主分区
fdisk -l #显示磁盘信息
Disk /dev/sdb: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 512 524272 83 Linux #标记已作分区
Disk /dev/sdf: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Disk /dev/sdf doesn't contain a valid partition table #新插入磁盘,没有做任何动作
2.fdisk /dev/sdf #对磁盘进行分区
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): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-512, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-512, default 512): 512
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
#到这里表示/dev/sdf已被分区;
3.格式化/dev/sdf1
mkfs.ext3 /dev/sdf1 #也可以使用ext4格式
#经过上述磁盘分区和格式化后,看到4个分区:/dev/sdb1,/dev/sdc1,/dev/sdd1,/dev/sde1
4.建立Raid10
mdadm --create --auto=yes /dev/md10 --level=10 --raid-devices=4 /dev/sd{b,c,d,e}1
5.查看
cat /proc/mdstat
Personalities : [raid10]
md10 : active raid10 sdb1[0] sde1[3] sdd1[2] sdc1[1]
1048320 blocks 64K chunks 2 near-copies [4/4] [UUUU]
unused devices: <none>
6.格式化raid10
mkfs.ext3 /dev/md10
5.挂载
mkdir /mnt/raid10
mount /dev/md10 /mnt/raid10
6.查看是否挂载上
df -lh
7.测试
hdparm -tT /dev/md10
/dev/md10:
Timing cached reads: 5968 MB in 2.00 seconds = 2988.82 MB/sec
Timing buffered disk reads: 70 MB in 3.03 seconds = 23.11 MB/sec
8.设置开机自动启动Raid,且自动挂载
8.1查看UUID号
mdadm --detail /dev/md10
UUID : 028d36d3:fa15f8d5:2ef600e1:e532ee1d
8.2 UUID添加到vi /etc/mdadm.conf
/dev/md10 /media/raid10 ext3 defaults 1 2
综上,Raid10创建完成,自启动Raid,开机自动挂载
备注:如果因重启服务器,导致之前创建的Raid消失,必须要记住所创建Raid名称,
执行如下命令,启动Raid;
mdadm --assemble /dev/md10 /dev/sd{b,c,e,f}1
环境CentOs 5.4:
Raid10原理:
创建Raid10,至少需要4块磁盘,以4块磁盘为例子(2D(mirroring)+2D(stripping))
对数据存入先做镜像(备份),而后做条带操作(数据分割),并行的写入磁盘中,即保证数据安全性,又提高数据存取速度.
其缺点:存储容量利用率低,单位成本非常高.
Raid10创建:
假设有如下4块磁盘:
/dev/sdb
/dev/sdc
/dev/sdd
/dev/sde
1.对每块磁盘分区,每块磁盘只一个主分区
fdisk -l #显示磁盘信息
Disk /dev/sdb: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 512 524272 83 Linux #标记已作分区
Disk /dev/sdf: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Disk /dev/sdf doesn't contain a valid partition table #新插入磁盘,没有做任何动作
2.fdisk /dev/sdf #对磁盘进行分区
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): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-512, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-512, default 512): 512
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
#到这里表示/dev/sdf已被分区;
3.格式化/dev/sdf1
mkfs.ext3 /dev/sdf1 #也可以使用ext4格式
#经过上述磁盘分区和格式化后,看到4个分区:/dev/sdb1,/dev/sdc1,/dev/sdd1,/dev/sde1
4.建立Raid10
mdadm --create --auto=yes /dev/md10 --level=10 --raid-devices=4 /dev/sd{b,c,d,e}1
5.查看
cat /proc/mdstat
Personalities : [raid10]
md10 : active raid10 sdb1[0] sde1[3] sdd1[2] sdc1[1]
1048320 blocks 64K chunks 2 near-copies [4/4] [UUUU]
unused devices: <none>
6.格式化raid10
mkfs.ext3 /dev/md10
5.挂载
mkdir /mnt/raid10
mount /dev/md10 /mnt/raid10
6.查看是否挂载上
df -lh
7.测试
hdparm -tT /dev/md10
/dev/md10:
Timing cached reads: 5968 MB in 2.00 seconds = 2988.82 MB/sec
Timing buffered disk reads: 70 MB in 3.03 seconds = 23.11 MB/sec
8.设置开机自动启动Raid,且自动挂载
8.1查看UUID号
mdadm --detail /dev/md10
UUID : 028d36d3:fa15f8d5:2ef600e1:e532ee1d
8.2 UUID添加到vi /etc/mdadm.conf
ARRAY /dev/md10 UUID=028d36d3:fa15f8d5:2ef600e1:e532ee1d
或mdadm -Ds > /etc/mdadm.conf
9.设置开机自动挂载
vi /etc/fstab/dev/md10 /media/raid10 ext3 defaults 1 2
综上,Raid10创建完成,自启动Raid,开机自动挂载
备注:如果因重启服务器,导致之前创建的Raid消失,必须要记住所创建Raid名称,
执行如下命令,启动Raid;
mdadm --assemble /dev/md10 /dev/sd{b,c,e,f}1