损失50%的数据容量,如:2块100G的盘,做RAID 1后,容量为200G,原理是写入一个硬盘的数据百分之百地自动复制到另一块硬盘上,实现存储双份的数据
性能
RAID 1不能提高存储性能,理论上写性能和单盘相差不大;有人说读取速率是单盘的2倍,有待验证
冗余
在所有RAID级别中,RAID 1提供最高的数据安全保障,冗余度50%
场景
适用于存放重要数据,如服务器系统分区和对性能要求不高的数据库存储等领域
特点
50%冗余,容量损失一半,具有利用备份数据重构RAID 1,即镜像mirror
注意
制作RAID 1至少是两块硬盘,整个RAID大小等于两个磁盘中最小硬盘的容量(最好使用同样大小的硬盘)
4.8 RAID 5级别
关注点
描述
容量
损失一块硬盘的数据容量
性能
RAID 5具有和RAID 0相近似的数据读取速度,只是多个一个奇偶校验信息,写入数据的速度比对单个硬盘进行写入操作稍慢
冗余
可损失一块盘,RAID 5数据安全保障程度比RAID 1低,而磁盘空间利用率要比RAID 1高
场景
适合对性能和冗余都有一定要求,又都不是非常高的情况,如:Mysql的主从库,存储等
特点
容量损失一块盘,写数据通过奇偶检验,RAID 0和RAID 1的折中方案
注意
制作RAID 5需要至少3块物理硬盘,提供热备盘实现故障恢复,采用奇偶校验,可靠性强,且只有同时损坏两块硬盘数据才会损坏,只损坏一块盘时,系统会根据剩下的数据和相应的奇偶校验信息去重建数据;奇偶校验信息和相应的数据分别存储在不同的磁盘上
虚拟文件系统模型图
5 fdisk与parted分区操作MBR分区方式:无法支持超过2TB的硬盘的分区(或单个分区超过2TB) GPT分区方式:很好的解决了传统MBR无法逾越2TB的限制,如果大于2TB就用GPT分区 Fdisk命令无法支持gpt分区格式,Parted命令操作是实时的
5.1 fdisk分区操作[root@cobbler-node1 ~]# fdisk -l /dev/sdb Disk /dev/sdb: 2147 MB, 2147483648 bytes 255 heads, 63 sectors/track, 261 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: 0x000a3ee6 Device Boot Start End Blocks Id System [root@cobbler-node1 ~]# fdisk -cu /dev/sdb Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First sector (2048-4194303, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-4194303, default 4194303): +100M Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First sector (206848-4194303, default 206848): Using default value 206848 Last sector, +sectors or +size{K,M,G} (206848-4194303, default 4194303): +100M Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 3 First sector (411648-4194303, default 411648): Using default value 411648 Last sector, +sectors or +size{K,M,G} (411648-4194303, default 4194303): +100M Command (m for help): n Command action e extended p primary partition (1-4) e Selected partition 4 First sector (616448-4194303, default 616448): Using default value 616448 Last sector, +sectors or +size{K,M,G} (616448-4194303, default 4194303): Using default value 4194303 Command (m for help): n First sector (618496-4194303, default 618496): Using default value 618496 Last sector, +sectors or +size{K,M,G} (618496-4194303, default 4194303): +100M Command (m for help): p Disk /dev/sdb: 2147 MB, 2147483648 bytes 255 heads, 63 sectors/track, 261 cylinders, total 4194304 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 identifier: 0x000a3ee6 Device Boot Start End Blocks Id System /dev/sdb1 2048 206847 102400 83 Linux /dev/sdb2 206848 411647 102400 83 Linux /dev/sdb3 411648 616447 102400 83 Linux /dev/sdb4 616448 4194303 1788928 5 Extended /dev/sdb5 618496 823295 102400 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. #格式化/dev/sdb5分区文件系统为ext4类型 [root@cobbler-node1 ~]# mkfs.ext4 /dev/sdb5 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 25688 inodes, 102400 blocks 5120 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=67371008 13 block groups 8192 blocks per group, 8192 fragments per group 1976 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 38 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. #打印块设备的属性信息 [root@cobbler-node1 ~]# blkid /dev/sdb5 /dev/sdb5: UUID="20cdc54d-f801-4399-9799-f92daac43155" TYPE="ext4" #创建挂载目录 [root@cobbler-node1 ~]# mkdir /applog #挂载/dev/sdb5到/applog目录 [root@cobbler-node1 ~]# mount /dev/sdb5 /applog #验证/dev/sdb5是否挂载成功 [root@cobbler-node1 ~]# df -h | grep "applog" /dev/sdb5 97M 5.6M 87M 7% /applog #加载开机启动自动挂载/dev/sdb5 [root@cobbler-node1 ~]# echo "UUID=20cdc54d-f801-4399-9799-f92daac43155 /applog ext4 defaults 0 0" >> /etc/fstab [root@cobbler-node1 ~]# tail -1 /etc/fstab UUID=20cdc54d-f801-4399-9799-f92daac43155 /applog ext4 defaults 0 0 #查看/dev/sdb磁盘的现有分区 [root@cobbler-node1 ~]# fdisk -l /dev/sdb Disk /dev/sdb: 2147 MB, 2147483648 bytes 255 heads, 63 sectors/track, 261 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: 0x000a3ee6 Device Boot Start End Blocks Id System /dev/sdb1 1 13 102400 83 Linux Partition 1 does not end on cylinder boundary. /dev/sdb2 13 26 102400 83 Linux Partition 2 does not end on cylinder boundary. /dev/sdb3 26 39 102400 83 Linux Partition 3 does not end on cylinder boundary. /dev/sdb4 39 262 1788928 5 Extended Partition 4 does not end on cylinder boundary. /dev/sdb5 39 52 102400 83 Linux 注意:其他分区如:/dev/sdb1、/dev/sdb2、/dev/sdb3格式化创建文件系统、创建挂载目录并挂载到相应的目录、加载开机自启动,请参照/dev/sdb5的操作即可
5.2 parted分区操作方法一:交互式创建磁盘分区