Linux Cloud Automation system operations 19 (disk array RAID,LVM management)

Source: Internet
Author: User

What the software can do
RAID1. Double read speed, two disks read together
Raid0. Write two hard drives, one piece to write half
RAID5:RAID1+RAID0 Three pieces of disk


Mdadm-c/dev/md0-a yes-l 1-n 2-x 1/dev/vdb{1..3}
-C; Create-A: Add-L: Priority-N: Number of disks used x: Number of idle disks (standby)
mkfs.xfs/dev/md0 formatting

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/9D/CC/wKiom1mGlGKBCcbxAADYRAFcZN8655.png "title=" Screenshot from 2017-08-05 01_51_25.png "alt=" Wkiom1mglgkbccbxaadyrafczn8655.png "/>mount/dev/md0/mnt/mount to/m nt/
mdadm-d/dev/md0 View Device status

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/9D/CC/wKioL1mGlKiy-rpUAACkpC--zzM378.png "title=" Screenshot from 2017-08-05 01_51_54.png "alt=" wkiol1mglkiy-rpuaackpc--zzm378.png "/>mdadm/dev/md0-f/dev/vdb2 let/de V/VDB2 is broken, the spare disk will be replaced to continue to work
Mdadm/dev/md0-r/DEV/VDB2 Delete/dev/vdb2
Mdadm/dev/md0-a/dev/vdb2 Add/DEV/VDB2

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/9D/CC/wKiom1mGlUPxiJHrAAAxxpCAIqQ936.png "style=" float : none; "title=" screenshot from 2017-08-05 01_57_46.png "alt=" Wkiom1mglupxijhraaaxxpcaiqq936.png "/>

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/9D/CC/wKioL1mGlUPxMhcIAABuHTOnHOM516.png "style=" float : none; "title=" screenshot from 2017-08-05 01_59_26.png "alt=" Wkiol1mglupxmhciaabuhtonhom516.png "/>

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/9D/CC/wKioL1mGlUTTh2NrAACCmSwYmEI117.png "style=" float : none; "title=" screenshot from 2017-08-05 02_01_01.png "alt=" Wkiol1mglutth2nraaccmswymei117.png "/>

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/9D/CC/wKiom1mGlUWyakSHAACVCld8lus669.png "style=" float : none; "title=" screenshot from 2017-08-05 02_01_15.png "alt=" Wkiom1mgluwyakshaacvcld8lus669.png "/>


Delete procedure
UMOUNT/MNT Uninstalling the device
Mdadm-s/dev/md0 let/dev/md0 stop working
FDISK/DEV/VDB Delete the 3 disks created before

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/9D/CC/wKiom1mGlZKzVR9YAAAahL-nn7Y993.png "style=" float : none; "title=" screenshot from 2017-08-05 02_02_20.png "alt=" Wkiom1mglzkzvr9yaaaahl-nn7y993.png "/>

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/9D/CC/wKioL1mGlZKhLh4DAADq29ZnOg8611.png "style=" float : none; "title=" screenshot from 2017-08-05 13-51-10.png "alt=" Wkiol1mglzkhlh4daadq29znog8611.png "/>




Logical Volume: LVM
LVM developed by IBM

1.LVM noun
lvm     Logical volume, a device management software that allows devices to scale freely
pv     Physical volume
vg     Physical volume group
pe     Physical expansion, LVM smallest storage unit
lvm     Logical Volume, When we finally used the scalable device

2.LVM production
First partition the device used by LVM, the function ID of these devices must be Linux LVM

1) LVM build
PVCREATE/DEV/VDB1         # #把物理分区做成物理卷
pvs|pvdisplay             # #查看物理卷

vgcreate vg0/dev/vdb1        # #用制作好的/dev/ VDB1 this physical volume to make a physical volume group vg0
vgs|vgdisplay            # #查看物理卷组

Lvcreate-l 200m-n lv0 vg0    # #在vg0这个组中建立出lv0设备-L Specify device size-n Specify device name
lvs|lvdisplay    & nbsp;       # #对逻辑卷设备进行查看

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/9D/CC/wKioL1mGl8iBOhqkAACXK3p_-pY467.png "style=" float : none; "title=" screenshot from 2017-08-05 02_50_44.png "alt=" Wkiol1mgl8ibohqkaacxk3p_-py467.png "/>

Expansion of 3.LVM devices
############## #针对xfs文件系统 ######################
XFS file systems can only be expanded to not shrink
1) LVM expansion
Lvextend-l 500m/dev/vg0/lv0 # #扩大lvm设备到500M
Xfs_growfs/dev/vg0/lv0 # #扩大xfs文件系统到设备大小
2) VG Enlargement
PVCREATE/DEV/VDB2 # #在pv中增加一块设备/DEV/VDB2
Vgextend VG0/DEV/VDB2 # #把新建立的/DEV/VDB2 added to Vg0

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/9D/CC/wKioL1mGmD3iGCQVAAEja_s_x64179.png "title=" Screenshot from 2017-08-05 03_00_06.png "alt=" Wkiol1mgmd3igcqvaaeja_s_x64179.png "/>

############# #针对ext4文件系统 ####################

Mkfs.ext4/dev/vg0/lv0 convert file system to EXT4 type
EXT4 file system can be expanded or reduced

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/9D/CD/wKiom1mGmLOiP6D1AADDPrB9MC0399.png "title=" Screenshot from 2017-08-05 03_07_52.png "alt=" Wkiom1mgmloip6d1aaddprb9mc0399.png "/>1" LVM expansion
Lvextend-l 2g/dev/vg0/lv0 # #扩大lvm设备到2G
Resize2fs/dev/vg0/lv0 # #设定文件系统大小和设备同步

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/9D/CD/wKiom1mGmPiScQzrAACQHTcR27A587.png "title=" Screenshot from 2017-08-05 03_08_18.png "alt=" wkiom1mgmpiscqzraacqhtcr27a587.png "/>2" VG expansion
PVCREATE/DEV/VDB3 # #在pv中增加一块设备/DEV/VDB3
Vgextend VG0/DEV/VDB3 # #把新建立的/DEV/VDB2 added to Vg0
3) LVM Reduction
Umount/dev/vg0/lv0 # #卸载设备 because file system reduction does not support online operation
E2fsck-f/dev/vg0/lv0 # #检测文件系统 to determine the size of data already in the file system to prevent over-scaling
Resize2fs/dev/vg0/lv0 1G # #把文件系统缩减到1G
Lvreduce-l 1g/dev/vg0/lv0 # #设备缩减到1G

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/9D/CC/wKioL1mGmUqiQ1_MAADjXc27UAs213.png "title=" Screenshot from 2017-08-05 03_10_57.png "alt=" Wkiol1mgmuqiq1_maadjxc27uas213.png "/>

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/9D/CC/wKioL1mGmXzyjcDWAACU4Bq4-KI434.png "title=" Screenshot from 2017-08-05 03_12_21.png "alt=" Wkiol1mgmxzyjcdwaacu4bq4-ki434.png "/>


4) VG Reduction
#在vg缩减时只能缩减没有被占用的设备
Pvmove Equipment 1 Equipment 2 # #把设备1上的所有数据移动到设备2上
Vgreduce VG0/DEV/VDB1 # #把vg0中的/DEV/VDB1 Delete
PVREMOVE/DEV/VDB1 # LVM Management information removal on the #把/dev/vdb1
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/9D/CD/wKiom1mGmd3Slf2jAADD3QkUn2M588.png "title=" Screenshot from 2017-08-05 03_18_27.png "alt=" Wkiom1mgmd3slf2jaadd3qkun2m588.png "/>5" LVM lost device removal
[Email protected] ~]# PVs
PV G2OIGE-1AWL-HOFO-XWNG-EHUG-KP5E-GBQGRT not recognised. Is the device missing?
PV G2OIGE-1AWL-HOFO-XWNG-EHUG-KP5E-GBQGRT not recognised. Is the device missing?
PV G2OIGE-1AWL-HOFO-XWNG-EHUG-KP5E-GBQGRT not recognised. Is the device missing?
PV G2OIGE-1AWL-HOFO-XWNG-EHUG-KP5E-GBQGRT not recognised. Is the device missing?
PV VG Fmt Attr PSize pfree
/DEV/VDB1 vg0 lvm2 a--1020.00m 820.00m
/DEV/VDB2 vg0 lvm2 a--1020.00m 1020.00m
Unknown device vg0 lvm2 a-m 996.00m 996.00m # #设备丢失

[Email protected] ~]# vgreduce--removemissing vg0 # #删除vg0中丢失的设备
PV G2OIGE-1AWL-HOFO-XWNG-EHUG-KP5E-GBQGRT not recognised. Is the device missing?
PV G2OIGE-1AWL-HOFO-XWNG-EHUG-KP5E-GBQGRT not recognised. Is the device missing?
Wrote out consistent volume group vg0


[Email protected] ~]# PVs
PV VG Fmt Attr PSize pfree
/DEV/VDB1 vg0 lvm2 a--1020.00m 820.00m
/DEV/VDB2 vg0 lvm2 a--1020.00m 1020.00m


6.LVM Snapshots
Lvcreate-l 20m-n lv0-backup-s/dev/vg0/lv0 # #给/dev/vg0/lv0 Snapshot,-l specify snapshot size,-n Specify Snapshot name-s specify Snapshot template device
Mount/dev/vg0/lv0-backup/userdate
When the data in the snapshot device is changed, if you want to restore, delete the snapshot device, re-establish the snapshot

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/9D/CD/wKiom1mGmh7AZ8AFAAAnc2HFXkA505.png "style=" float : none; "title=" screenshot from 2017-08-05 03_26_58.png "alt=" Wkiom1mgmh7az8afaaanc2hfxka505.png "/>

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/9D/CC/wKioL1mGmh_BfoOlAABOx7lrzYs258.png "style=" float : none; "title=" screenshot from 2017-08-05 03_25_59.png "alt=" Wkiol1mgmh_bfoolaabox7lrzys258.png "/>



7.LVM Delete
Lvremove---->vgremove----->pvremove
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/9D/CC/wKioL1mGmjOj1-O6AAAxZHrIJqw766.png "title=" Screenshot from 2017-08-05 03_27_33.png "alt=" Wkiol1mgmjoj1-o6aaaxzhrijqw766.png "/>

This article is from the "13122425" blog, please be sure to keep this source http://13132425.blog.51cto.com/13122425/1953963

Linux Cloud Automation system operations 19 (disk array RAID,LVM management)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.