raid combination of advantages and disadvantages of introduction and create personal notes LVM experiment

A, RAID combinations introduction

A brief description of the advantages and disadvantages RAID mode

    1, raid 0 mode

  Advantages: In the state of RAID 0, stored data is divided into two parts respectively stored on two hard disks, removable hard disk storage speed theory at this time is twice the one-disk, the actual capacity is equal to the smaller one two disks 2 volumes of the hard disk.

    Disadvantages: one hard disk fails, the data on the entire RAID will not be restored.

    Note: HD movies are more suitable for storage.

    2, raid1 mode

  Advantages: In this mode, The two hard disks. When a hard disk damaged, put a new hard disk (hard disk capacity is greater than or equal to the original) to automatically replace the original hard disk data recovery and continued use, the actual capacity is equal to the smaller one mobile hard disk capacity, and the storage speed monolithic the same hard disk. RAID 1 advantage is that any one disk fails, the data stored will not be lost.

    Disadvantages: the actual capacity of the hard disk can be used in this mode is relatively small, only two of the hard disk capacity of the smallest disk.

    NOTE: Very important information, such as databases, personal information is foolproof storage solutions.

 3, raid 0 + 1 mode

 

 

    RAID 0 + 1 segment is a combination of disk and mirror using two groups of disk array RAID0 mirror each other, between them has become a RAID1 array. Hard disk usage is only 50%, but to provide the best speed and reliability.

    4, raid 3 mode

    RAID3 is divided into a plurality of data "block", in accordance with certain fault tolerance algorithm, stored in the hard disk of N + 1, the effective space occupied by the actual data is the sum of the N disk space, while the N + 1-th hard disk storage data parity information is fault-tolerant, that when the N + 1 hard disk in one of the disks fails, the original data can be restored from the hard disk data in the other N.

    5, raid 5 mode

    Data backup RAID5 not stored, but the data and corresponding parity information is stored on each disk consisting of RAID5, and parity information, and data corresponding to each stored on a different disk. When a RAID5 disk data is damaged, using the remaining data and parity information corresponding to recover corrupted data.

 

    6, raid10 mode

    RAID10最少需要4块硬盘才能完成。把2块硬盘组成一个RAID1,然后两组RAID1组成一个RAID0。虽然RAID10方案造成了50%的磁盘浪费,但是它提供了200%的速度和单磁盘损坏的数据安全性。

 

 7、raid6

 

 二、LVM实验笔记(centos7.6)

 实验准备:使用/dev/sdb1分区的10G空间和/dev/sdc一块10G硬盘作为逻辑卷的空间

步骤:创建lvm逻辑卷的步骤:

1、物理卷:首先把分区或硬盘制作成物理卷

使用分区时使用fdisk + /dev/device 创建分区并把分区标识改为8e,保存退出后使用partprobe 命令同步一下分区

 

 2、卷组:把一个或多个物理卷组合成一个卷组

 

 3、逻辑卷:在有了卷组vg1的基础上利用卷组的空间制作成逻辑卷

 

4、给逻辑卷创建文件系统

 

 5、写入配置文件/etc/fstab ,并进行挂载使用

 

 6、创建挂载目录,挂载使用

 

 二、逻辑卷的扩展(逻辑卷的其中的一个优点就是可以在线扩展,并不会影响其他用户的使用)

1、扩展的前提是卷组还有多余的空间下进行扩展,如果没有空间则需要先扩展卷组的空间再扩展逻辑卷的空间

 

2、提示容量从15G增加到18G但是查看时显示还是15G

 

原因是 因为刚刚添加的容量没有文件系统使用以下命令同步文件系统即可

xfs文件系统使用xfs_growfs  + 逻辑卷

ext4的使用 resize2fs  +  逻辑卷  

也可使用 lvextend -L +1G -r /dev/vg1/mysql 命令增加容量并同步文件系统

此命令不区分文件系统

 

三、总结:

一、

1、pvcreate 创建物理卷、vgcreate创建卷组、lvcreate创建逻辑卷
移除 {pv,vg,lv}remove + /dev/device
缩减容量 {vg,lv}reduce
2、{vg、lv}reduce + -L 大小 + 卷组或逻辑卷 缩减容量到 L 大小
3、新增加的逻辑卷容量同步文件格式命令:
xfs文件系统使用: xfs_growfs + LV_PATH
ext4文件系统使用: resize2fs + LV_PATH
使用以下命令不需要区分文件系统类型,
lvextend -r -L +0.5G(要扩充的容量大小) + /dev/vg1/mysql (LV_PATH)

二、硬盘迁移到其他系统步骤和命令

卷组改名: vgrename old_name new_name vg0表示卷组名称
① vgchange -an vg0 # -n 表示标记为非活动状态,即把逻辑卷禁用
② 把卷组标记位导出状态:vgexport + vg0
③ 把卷组导入: vgimport + vg0
④ 把卷组从禁用状态激活: vgchange -ay vg0
⑤ 挂载使用即可
小坑:如果卷组未移除硬盘,直接格式化硬盘造成unknown 使用此命令移除unknown设备   

报错如下图:虽然命令执行成功了但是总有warning告警

解决方法: vgreduce --removemissing /dev/vg9 (vg9卷组名) 移除丢失的卷组设备

三、LVM创建使用(相关命令与步骤):
步骤:1、首先把分区或硬盘制作成物理卷
2、卷组:把一个或多个物理卷组合成一个卷组
3、逻辑卷:在有卷组的基础上利用卷组的空间制作成逻辑卷
4、给逻辑卷创建文件系统
5、写入配置文件,并进行挂载使用
①创建物理卷: pvcreate + /dev/device ... 把多个硬盘或分区创建成物理卷
  查看命令: pvs、pvdisplay
②创建卷组: vgcreate +(-s 16m指定PE大小) + 卷组的名字 + 要加入的硬盘或分区
  示例: vgcreate -s 16m vg1 /dev/de2 /dev/sdc1
  查看: vgs、vgdisplay
③创建逻辑卷:lvcreate + -n(指定逻辑卷名称) + (-l 指定PE的个数或 -L 指定容量的大小或100%FREE 表示剩余容量全部使用) + 卷组名称(指定使用哪个卷组的空间)
  示例: lvcreate -n mysql -L 10G vg1
  查看:lvs、lvdisplay
④创建文件系统: mkfs.xfs /dev/vg1/mysql
⑤写入文件开机挂载使用:blkid 查看设备UUID并写入文件
挂载使用: mount /dev/vg1/mysql /mnt/mysql
3、逻辑卷扩容
  lvextend + ( -l 或 -L)+(+容量大小)+ 逻辑卷名称
  示例: lvextend  -L +1G   /dev/vg1/mysql
扩充完容量后使用 xfs_growfs + 逻辑卷的路径或挂载后的路径(如果不同步,则刚刚添加的容量不会增加到逻辑卷中,通过此命令可将新添加的容量创建文件系统并增加原有容量)
  示例: xfs_growfs /dev/vg1/mysql
4、逻辑卷容量缩减(逻辑卷的文件系统是ext4的可以缩减,xfs的不支持)
  ①取消挂载 umount /mnt/http
  ②缩减逻辑卷分为两个步骤:
第一步:先缩减文件系统
  resize2fs /dev/vg1/mysql 11G (11G表示缩减到11个G) 缩减前是12G
  会有提示“ Please run 'e2fsck -f /dev/vg2/http' first ”
  执行 e2fsck -f /dev/vg2/http' first 先检查文件系统
  再次执行resize2fs /dev/vg1/mysql 11G
第二步:再缩减逻辑卷的容量
  lvreduce -L 11G /dev/vg2/http
  再次挂载即可生效

 

 

 

如果觉得对你有所帮助的话可以关注一下哦,非常感谢! 

 

Guess you like

Origin www.cnblogs.com/fengdejiyixx/p/10962074.html