当前位置 主页 > 服务器问题 > Linux/apache问题 >
1 什么是RAID
RAID全称是独立磁盘冗余阵列(Redundant Array of Independent Disks),基本思想是把多个磁盘组合起来,组合一个磁盘阵列组,使得性能大幅提高。
RAID分为几个不同的等级,各个不同的等级均在数据可靠性及读写性能做了不同的权衡。实际工作中根据自己的业务需求选择不同的RAID方案。
2 RAID的实现方式
外接式磁盘阵列:通过扩展卡提供适配能力内接式RAID:主板集成RAID控制器安装OS前在BIOS里配置软件RAID:通过OS实现
3 标准的RAID
3.1 RAID0
RAID0称为条带化存储,将数据分段存储在各个磁盘中,读写均可以并行处理,因此读写速率为单个磁盘的N倍,没有冗余功能,任何一个磁盘的损坏就会导致的数据不可用。
3.2 RAID1
RADI1是镜像存储,没有数据校验,数据被同等的写入到2个或者多个磁盘中,写入速度相对慢, 但是读取速度比较快。
3.3 RAID 4
RADI4在RAID1的基础上,N个盘用于数据存储,另外加入了1个磁盘作为校验盘。一共N+1个盘,任何一个盘坏掉也不影响数据的访问
3.4 RAID 5
RAID5在RAID4的基础上,由原来的一个盘来存储校验数据,改为每个盘都有数据和校验信息的。
4 混合RAID
4.1 RAID01
先组成RAID0,然后组成RAID1.
4.2 RAID10
先组成RAID1,然后组成RAID0
5 软RAID的实现
5.1 RAID5的实现
创建由三块硬盘组成的可用空间为2G的RAID5设备,要求其chunk大小为256k,文件系统为ext4,开机可自动挂载至/mydata目录
5.1.1 先看看我们的磁盘情况
[root@centos7 Bash]$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 200G 0 disk ├─sda1 8:1 0 1G 0 part /boot ├─sda2 8:2 0 128G 0 part ├─sda3 8:3 0 48.8G 0 part / ├─sda4 8:4 0 512B 0 part └─sda5 8:5 0 19.5G 0 part /app sdb 8:16 0 100G 0 disk sdc 8:32 0 20G 0 disk sdd 8:48 0 20G 0 disk sde 8:64 0 20G 0 disk sdf 8:80 0 20G 0 disk sr0 11:0 1 8.1G 0 rom /run/media/root/CentOS 7 x86_64
这里我们使用sdb,sdc,sdd,每个盘创建一个主分区1G,构建RADI5.
5.1.2 根据实际情况分区
[root@centos7 Bash]$ fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x93d380cf. Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): First sector (2048-209715199, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): +1G Partition 1 of type Linux and of size 1 GiB is set Command (m for help): t Selected partition 1 Hex code (type L to list all codes): fd Changed type of partition 'Linux' to 'Linux raid autodetect' Command (m for help): p Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x93d380cf Device Boot Start End Blocks Id System /dev/sdb1 2048 2099199 1048576 fd Linux raid autodetect Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@centos7 Bash]$ fdisk /dev/sdc Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0xc56b90d8. Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): First sector (2048-41943039, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +1G Partition 1 of type Linux and of size 1 GiB is set Command (m for help): t Selected partition 1 Hex code (type L to list all codes): fd Changed type of partition 'Linux' to 'Linux raid autodetect' Command (m for help): p Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xc56b90d8 Device Boot Start End Blocks Id System /dev/sdc1 2048 2099199 1048576 fd Linux raid autodetect Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@centos7 Bash]$ fdisk /dev/sdd Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x7e0900d8. Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): First sector (2048-41943039, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +1G Partition 1 of type Linux and of size 1 GiB is set Command (m for help): p Disk /dev/sdd: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x7e0900d8 Device Boot Start End Blocks Id System /dev/sdd1 2048 2099199 1048576 83 Linux Command (m for help): t Selected partition 1 Hex code (type L to list all codes): fd Changed type of partition 'Linux' to 'Linux raid autodetect' Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.