您好,登錄后才能下訂單哦!
一、高級文件系統(tǒng)管理
1) 設(shè)定文件系統(tǒng)配額
2) 設(shè)定和管理軟RAID設(shè)備
3) 配置邏輯卷
4) 設(shè)定LVM快照
5) btrfs文件系統(tǒng)
二、配置磁盤配額
演示步驟如下:
1、分區(qū)掛載將/home目錄下的所有文件拷貝至/dev/sdc1
fdsik /dev/sdc
mount /dec/sdc1 /mnt/test
mv /home/* /mnt/test
mount /dev/sdc1 /home
2、啟動(dòng)配額掛載選項(xiàng)
/dev/sdc1 /mnt/test ext4 defaults 0 0
/dev/sdc1 /home ext4 usrquota,grpquota 0 0
3、啟動(dòng)數(shù)據(jù)庫,如遇到報(bào)錯(cuò)則關(guān)閉防火墻及重新掛載(mount -0 remount usrquota,grpquota)
setenforce 0 #臨時(shí)關(guān)閉selinux
getenforce #查看selinux狀態(tài)
quotacheck -cug /home #創(chuàng)建磁盤配額數(shù)據(jù)庫
4、啟動(dòng)數(shù)據(jù)庫
quotaon -p /home #查看是否已啟動(dòng)數(shù)據(jù)庫
quotaon /home #啟動(dòng)數(shù)據(jù)庫
repquota /home #報(bào)告各個(gè)家目錄下用戶的默認(rèn)磁盤配額
5、配置配額項(xiàng)
edquota alren #給alren用戶配置配額
setquota alren 100000 150000 0 0 /home
6、測試
dd if=/dev/zero of=/home/alren/testfile bs=1M count=100
dd if=/dev/zero of=/home/alren/testfiel bs=1M count=160
代碼演示:
[root@centos6 ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Thu Aug 11 03:07:57 2016 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 /dev/sdb1 swap swap pri=10 0 0 /swapfile swap swap defaults,pri=100 0 0 /dev/sdc1 /mnt/test ext4 defaults 0 0 /dev/sdc1 /home ext4 usrquota,grpquota 0 0 UUID="39208cf4-4d84-430b-ab53-7a26ad9d786d" /mnt/lv0 ext4 defaults 0 0 UUID=240533cf-b37f-4460-974f-702bab867da5 / ext4 defaults1 1 UUID=4e245c68-a392-4ce9-9a99-5d32d8d43872 /boot ext4 defaults1 2 UUID=86aa7b74-24df-4043-ba83-f3b41a99ce0e /testdir ext4 defaults1 2 [root@centos6 home]# mount -o remount,usrquota,grpquota /home [root@centos6 home]# quotacheck -cug /home [root@centos6 home]# ls alren aquota.group aquota.user chen cheng chenggg lost+found [root@centos6 home]# quotaon -p /home group quota on /home (/dev/sdc1) is off user quota on /home (/dev/sdc1) is off [root@centos6 home]# quotaon /home [root@centos6 home]# quotaon -p /home group quota on /home (/dev/sdc1) is on user quota on /home (/dev/sdc1) is on [root@centos6 home]# setquota alren 100000 150000 0 0 /home [root@centos6 ~]# repquota /home *** Report for user quotas on device /dev/sdc1 Block grace time: 7days; Inode grace time: 7days Block limits File limits User used soft hard grace used soft hard grace ---------------------------------------------------------------------- root -- 37952 0 0 967 0 0 chen -- 43644 0 0 3198 0 0 chenggg -- 32 0 0 8 0 0 cheng -- 32 0 0 8 0 0 alren -- 32 100000 150000 9 0 0 [root@centos6 ~]# [root@centos6 home]# edquota alren [root@centos6 home]# su - alren [alren@centos6 ~]$ quota alren Disk quotas for user alren (uid 524): Filesystem blocks quota limit grace files quota limit grace /dev/sdc1 32 100000 150000 8 0 0 [alren@centos6 ~]$ repquota /home repquota: Cannot open quotafile /home/aquota.user: 權(quán)限不夠 repquota: Quota file not found or has wrong format. repquota: Not all specified mountpoints are using quota. [alren@centos6 ~]$ dd if=/dev/zero of=/home/alren bs=1M count=100 dd: 正在打開"/home/alren": 是一個(gè)目錄 [alren@centos6 ~]$ dd if=/dev/zero of=/home/alren/testfile bs=1M count=100 sdc1: warning, user block quota exceeded. 記錄了100+0 的讀入 記錄了100+0 的寫出 104857600字節(jié)(105 MB)已復(fù)制,0.613277 秒,171 MB/秒 [alren@centos6 ~]$ dd if=/dev/zero of=/home/alren/testfile bs=1M count=160 sdc1: warning, user block quota exceeded. sdc1: write failed, user block limit reached. dd: 正在寫入"/home/alren/testfile": 超出磁盤限額 記錄了147+0 的讀入 記錄了146+0 的寫出 153567232字節(jié)(154 MB)已復(fù)制,0.876813 秒,175 MB/秒 [alren@centos6 ~]$
三、獨(dú)立冗余磁盤整列(RAID,本文所述為軟RAID)
1、簡介
RAID:Redundant Arrays of Inexpensive(Independent)Disks,1988年由加利福尼亞大學(xué)伯克利分校(University of California-Berkeley) “A Case for Redundant Arrays of Inexpensive Disks”提出。多個(gè)磁盤合成一個(gè)“陣列”來提供更好的性能、冗余,或者兩者都提供,就叫做獨(dú)立磁盤冗余整列。
2、特點(diǎn)
1)提高IO性能,提升磁盤讀寫
2)提高耐用性,磁盤冗余來實(shí)現(xiàn)
3)多塊磁盤組織在一起的工作方式有所不同
3、raid級別
RAID-0:將數(shù)據(jù)切割成等分,然后按次序存儲在磁盤中
RAID-1:將數(shù)據(jù)切割成等分,然后分別存入各個(gè)磁盤中
RAID-5:將數(shù)據(jù)切割成等分,然后按次序存儲在磁盤中,并且每個(gè)磁盤輪流存儲校驗(yàn)信息
......
RAID-6: 將數(shù)據(jù)切割成等分,然后按次序存儲在磁盤中,并且每個(gè)磁盤輪流存儲校驗(yàn)信息,且存兩份校驗(yàn)信息
RAID-10: 先做raid1,然后做raid0即可
RAID-01: 先做raid0,然后做raid1即可
3、raid級別及其特性
RAID-0;讀寫性能提升
可用空間n*min(s1,s2...)
無容錯(cuò)能力
最少磁盤數(shù)量:2個(gè)
RAID-1:讀性能提升,寫性能有所下降
1*min(s1,s2,...)
有冗余能力
最少磁盤數(shù)量:2,2N
RAID-5: 讀寫性能提升
可用空間(N-1)*min(s1,s2)
有容錯(cuò)能力,只允許壞一塊磁盤
最少磁盤數(shù)量:3,3+
RAID-6:讀寫性能提升
可用空間(N-2)*min(s1,s2,...)
有容錯(cuò)能力允許壞兩塊磁盤
最少磁盤數(shù)量:4,4+
RAID-10:讀、寫性能提升
可用空間:N*min(S1,S2,...)/2
有容錯(cuò)能力:每組鏡像最多只能壞一塊
最少磁盤數(shù):4, 4+
RAID-01:讀、寫性能提升
可用空間:N*min(S1,S2,...)/2
有容錯(cuò)能力:每組鏡像最多只能壞一塊
最少磁盤數(shù):4, 4+
常用級別:RAID-0, RAID-1, RAID-5, RAID-10, RAID-50
軟RAID-5基本選項(xiàng):
mdadm:為軟raid提供管理界面,為空余磁盤添加冗余,RAID設(shè)備可為/dev/md0、/dev/md1、/dev/md2、 /dev/md3等等
mdadm命令:
語法格式:mdadm [mode] <raiddevice> [options] <component-devices>
模式:
創(chuàng)建:-C
裝配:-A
管理:-f,-r,-a
-C:創(chuàng)建模式
-n #:使用#個(gè)快設(shè)備來創(chuàng)建次RAID
-l #:指明RAID及級別
-a {yes|no}:自動(dòng)創(chuàng)建目標(biāo)raid設(shè)備的設(shè)備文件
-c chunck_size:指明塊設(shè)備的大小
-x #:指明空閑磁盤個(gè)數(shù)
-D: 顯示raid的詳細(xì)信息
mdadm -D /dev/md#
管理模式:
-f:標(biāo)記指定磁盤為損壞
-a:添加磁盤
-r:移除磁盤
觀察md的模式:
cat /proc/mdstat
停止md設(shè)備:
mdamd -S /dev/md#
軟RAID-5實(shí)現(xiàn)步驟:
1、創(chuàng)建磁盤分區(qū),本實(shí)驗(yàn)使用5塊磁盤做實(shí)驗(yàn),其中4塊為真實(shí)使用,1塊為冗余備份
fdisk /dev/sd{b,c,d,e,f}1 #磁盤分區(qū)10G并改其文件類型為fd
2、創(chuàng)建raid設(shè)備
mdadm -C /dev/md0 -a yes -l 5 -n 4 -x1 /dev/sd{b,c,d,e,f}1
mdamd -D /dev/md0
cat /proc/mdstat
3、格式化創(chuàng)建的md0設(shè)備
mkfs.ext4 /dev/md0
4、設(shè)置開機(jī)自動(dòng)掛載
vim /etc/fstab
UUID="b92ddd51-c555-4948-b1d5-8563b697a2f1" /mnt/raid ext4 defaults 0 0
5、生成配置文件/etc/mdadm.conf
mdadm -Ds /dev/md0 > /etc/mdadm.conf
mdadm -S /dev/md0 停止raid
mdadm -A /dev/md0 啟動(dòng)raid
6、測試
mdadm /dev/md0 -f /dev/sdf1 #模擬損壞
mdadm /dev/md0 -r /dev/sdf1 #刪除成員
mdadm /dev/md0 -a /dev/sdf1 #增加
mdadm -G /dev/md0 -n 6 -a /dev/sdd4 #增加成員
mkfs.ext4 /dev/md0 #重新格式化
7、刪除raid
umount /mnt/raid
mdadm -S /dev/md0 停止raid
rm -f /etc/mdadm.conf
vi /etc/fstab
fdisk /dev/sda
mdadm --zero-superblock /dev/sdd1
演示:
[root@centos7 ~]# mdadm -C /dev/md0 -a yes -l 5 -n 4 -x1 /dev/sd{b,c,d,e,f}1 mdadm: /dev/sdb1 appears to contain an ext2fs file system size=5242880K mtime=Thu Jan 1 08:00:00 1970 Continue creating array? y mdadm: Defaulting to version 1.2 metadata mdadm: array /dev/md0 started. [root@centos7 ~]# mdadm -D /dev/md0 /dev/md0: Version : 1.2 Creation Time : Tue Aug 30 11:28:31 2016 Raid Level : raid5 Array Size : 31432704 (29.98 GiB 32.19 GB) Used Dev Size : 10477568 (9.99 GiB 10.73 GB) Raid Devices : 4 Total Devices : 5 Persistence : Superblock is persistent Update Time : Tue Aug 30 11:28:42 2016 State : clean, degraded, recovering Active Devices : 3 Working Devices : 5 Failed Devices : 0 Spare Devices : 2 Layout : left-symmetric Chunk Size : 512K Rebuild Status : 18% complete Name : centos7.localdomain:0 (local to host centos7.localdomain) UUID : 40fbcb9e:3de8f63f:0ec52e1d:98020537 Events : 3 Number Major Minor RaidDevice State 0 8 17 0 active sync /dev/sdb1 1 8 33 1 active sync /dev/sdc1 2 8 49 2 active sync /dev/sdd1 5 8 65 3 spare rebuilding /dev/sde1 4 8 81 - spare /dev/sdf1 [root@centos7 ~]# mdadm -D /dev/md0 /dev/md0: Version : 1.2 Creation Time : Tue Aug 30 11:28:31 2016 Raid Level : raid5 Array Size : 31432704 (29.98 GiB 32.19 GB) Used Dev Size : 10477568 (9.99 GiB 10.73 GB) Raid Devices : 4 Total Devices : 5 Persistence : Superblock is persistent Update Time : Tue Aug 30 11:29:42 2016 State : clean, degraded, recovering Active Devices : 3 Working Devices : 5 Failed Devices : 0 Spare Devices : 2 Layout : left-symmetric Chunk Size : 512K Rebuild Status : 88% complete Name : centos7.localdomain:0 (local to host centos7.localdomain) UUID : 40fbcb9e:3de8f63f:0ec52e1d:98020537 Events : 15 Number Major Minor RaidDevice State 0 8 17 0 active sync /dev/sdb1 1 8 33 1 active sync /dev/sdc1 2 8 49 2 active sync /dev/sdd1 5 8 65 3 spare rebuilding /dev/sde1 4 8 81 - spare /dev/sdf1 [root@centos7 ~]# mdadm -D /dev/md0 /dev/md0: Version : 1.2 Creation Time : Tue Aug 30 11:28:31 2016 Raid Level : raid5 Array Size : 31432704 (29.98 GiB 32.19 GB) Used Dev Size : 10477568 (9.99 GiB 10.73 GB) Raid Devices : 4 Total Devices : 5 Persistence : Superblock is persistent Update Time : Tue Aug 30 11:29:52 2016 State : clean Active Devices : 4 Working Devices : 5 Failed Devices : 0 Spare Devices : 1 Layout : left-symmetric Chunk Size : 512K Name : centos7.localdomain:0 (local to host centos7.localdomain) UUID : 40fbcb9e:3de8f63f:0ec52e1d:98020537 Events : 18 Number Major Minor RaidDevice State 0 8 17 0 active sync /dev/sdb1 1 8 33 1 active sync /dev/sdc1 2 8 49 2 active sync /dev/sdd1 5 8 65 3 active sync /dev/sde1 4 8 81 - spare /dev/sdf1 [root@centos7 ~]# mkfs.ext4 /dev/md0 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=128 blocks, Stripe width=384 blocks 1966080 inodes, 7858176 blocks 392908 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2155872256 240 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done [root@centos7 ~]# mdadm -Ds /dev/md0 >/etc/mdadm.conf [root@centos7 ~]# mdadm -S /dev/md0 mdadm: stopped /dev/md0 [root@centos7 ~]# mdadm -A /dev/md0 mdadm: /dev/md0 has been started with 4 drives and 1 spare. [root@centos7 ~]# mdadm -D /dev/md0 /dev/md0: Version : 1.2 Creation Time : Tue Aug 30 11:28:31 2016 Raid Level : raid5 Array Size : 31432704 (29.98 GiB 32.19 GB) Used Dev Size : 10477568 (9.99 GiB 10.73 GB) Raid Devices : 4 Total Devices : 5 Persistence : Superblock is persistent Update Time : Tue Aug 30 11:30:29 2016 State : clean Active Devices : 4 Working Devices : 5 Failed Devices : 0 Spare Devices : 1 Layout : left-symmetric Chunk Size : 512K Name : centos7.localdomain:0 (local to host centos7.localdomain) UUID : 40fbcb9e:3de8f63f:0ec52e1d:98020537 Events : 18 Number Major Minor RaidDevice State 0 8 17 0 active sync /dev/sdb1 1 8 33 1 active sync /dev/sdc1 2 8 49 2 active sync /dev/sdd1 5 8 65 3 active sync /dev/sde1 4 8 81 - spare /dev/sdf1 [root@centos7 ~]# mdadm /dev/md0 -f /dev/sdb1 mdadm: set /dev/sdb1 faulty in /dev/md0 [root@centos7 ~]# mdadm -D /dev/md0 /dev/md0: Version : 1.2 Creation Time : Tue Aug 30 11:28:31 2016 Raid Level : raid5 Array Size : 31432704 (29.98 GiB 32.19 GB) Used Dev Size : 10477568 (9.99 GiB 10.73 GB) Raid Devices : 4 Total Devices : 5 Persistence : Superblock is persistent Update Time : Tue Aug 30 11:32:19 2016 State : clean, degraded, recovering Active Devices : 3 Working Devices : 4 Failed Devices : 1 Spare Devices : 1 Layout : left-symmetric Chunk Size : 512K Rebuild Status : 5% complete Name : centos7.localdomain:0 (local to host centos7.localdomain) UUID : 40fbcb9e:3de8f63f:0ec52e1d:98020537 Events : 20 Number Major Minor RaidDevice State 4 8 81 0 spare rebuilding /dev/sdf1 1 8 33 1 active sync /dev/sdc1 2 8 49 2 active sync /dev/sdd1 5 8 65 3 active sync /dev/sde1 0 8 17 - faulty /dev/sdb1 [root@centos7 ~]# cat /proc/mdstat Personalities : [raid6] [raid5] [raid4] md0 : active raid5 sdb1[0](F) sdf1[4] sde1[5] sdd1[2] sdc1[1] 31432704 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/3] [_UUU] [========>............] recovery = 43.8% (4592156/10477568) finish=0.7min speed=129724K/sec unused devices: <none> [root@centos7 ~]# mdadm -D /dev/md0 /dev/md0: Version : 1.2 Creation Time : Tue Aug 30 11:28:31 2016 Raid Level : raid5 Array Size : 31432704 (29.98 GiB 32.19 GB) Used Dev Size : 10477568 (9.99 GiB 10.73 GB) Raid Devices : 4 Total Devices : 5 Persistence : Superblock is persistent Update Time : Tue Aug 30 11:33:40 2016 State : clean Active Devices : 4 Working Devices : 4 Failed Devices : 1 Spare Devices : 0 Layout : left-symmetric Chunk Size : 512K Name : centos7.localdomain:0 (local to host centos7.localdomain) UUID : 40fbcb9e:3de8f63f:0ec52e1d:98020537 Events : 37 Number Major Minor RaidDevice State 4 8 81 0 active sync /dev/sdf1 1 8 33 1 active sync /dev/sdc1 2 8 49 2 active sync /dev/sdd1 5 8 65 3 active sync /dev/sde1 0 8 17 - faulty /dev/sdb1 [root@centos7 ~]# mdadm -G /dev/md0 -n 6 -a /dev/sdb2 mdadm: Need 2 spares to avoid degraded array, and only have 1. Use --force to over-ride this check. [root@centos7 ~]# mdadm -G /dev/md0 -n 6 -a /dev/sdb2 --force mdadm: added /dev/sdb2 mdadm: Failed to initiate reshape! unfreeze [root@centos7 ~]# mkfs.ext4 /dev/md0 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=128 blocks, Stripe width=384 blocks 1966080 inodes, 7858176 blocks 392908 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2155872256 240 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done [root@centos7 ~]# mdadm -D /dev/md0 /dev/md0: Version : 1.2 Creation Time : Tue Aug 30 11:28:31 2016 Raid Level : raid5 Array Size : 31432704 (29.98 GiB 32.19 GB) Used Dev Size : 10477568 (9.99 GiB 10.73 GB) Raid Devices : 4 Total Devices : 6 Persistence : Superblock is persistent Update Time : Tue Aug 30 11:34:55 2016 State : clean Active Devices : 4 Working Devices : 5 Failed Devices : 1 Spare Devices : 1 Layout : left-symmetric Chunk Size : 512K Name : centos7.localdomain:0 (local to host centos7.localdomain) UUID : 40fbcb9e:3de8f63f:0ec52e1d:98020537 Events : 41 Number Major Minor RaidDevice State 4 8 81 0 active sync /dev/sdf1 1 8 33 1 active sync /dev/sdc1 2 8 49 2 active sync /dev/sdd1 5 8 65 3 active sync /dev/sde1 0 8 17 - faulty /dev/sdb1 6 8 18 - spare /dev/sdb2 [root@centos7 ~]# mdadm /dev/md0 -r /dev/sdb1 mdadm: hot removed /dev/sdb1 from /dev/md0 [root@centos7 ~]# mdadm /dev/md0 -a /dev/sdb1 mdadm: added /dev/sdb1 [root@centos7 ~]# mdadm -D /dev/md0 /dev/md0: Version : 1.2 Creation Time : Tue Aug 30 11:28:31 2016 Raid Level : raid5 Array Size : 31432704 (29.98 GiB 32.19 GB) Used Dev Size : 10477568 (9.99 GiB 10.73 GB) Raid Devices : 4 Total Devices : 6 Persistence : Superblock is persistent Update Time : Tue Aug 30 11:35:46 2016 State : clean Active Devices : 4 Working Devices : 6 Failed Devices : 0 Spare Devices : 2 Layout : left-symmetric Chunk Size : 512K Name : centos7.localdomain:0 (local to host centos7.localdomain) UUID : 40fbcb9e:3de8f63f:0ec52e1d:98020537 Events : 43 Number Major Minor RaidDevice State 4 8 81 0 active sync /dev/sdf1 1 8 33 1 active sync /dev/sdc1 2 8 49 2 active sync /dev/sdd1 5 8 65 3 active sync /dev/sde1 6 8 18 - spare /dev/sdb2 7 8 17 - spare /dev/sdb1 [root@centos7 ~]#
三、LVM(邏輯卷管理)
1、簡介
LVM: Logical Volume Manager,允許對卷進(jìn)行方便操作的抽象層,包括重新設(shè)定文件系統(tǒng)的大小,允許在多個(gè)物理設(shè)備間重新組織文件系統(tǒng)。將設(shè)備指定為物理卷,用一個(gè)或多個(gè)物理卷來創(chuàng)建一個(gè)卷組,物理卷是用固定大小的物理區(qū)域(PE)來定義,在物理卷上創(chuàng)建邏輯卷,然后在邏輯卷上創(chuàng)建文件系統(tǒng)。
2、pv管理工具
1)顯示pv信息
pvs:簡要pv信息
pvdisplay:詳細(xì)pv信息
2)創(chuàng)建pv
pvcreate /dev/DEVICE
3、vg管理工具
1)顯示卷組
vgs:簡要vg信息
vgdisplay:詳細(xì)vg信息
2)創(chuàng)建邏輯卷
vgcreate [-s #[kKmMgGtTpPeE]] VolumeGroupName PhysicalDevicePath [PhysicalDevicePath...]
3)管理卷組
vgextend VolumeGroupName PhysicalDevicePath [PhysicalDevicePath...] vgreduce VolumeGroupName PhysicalDevicePath [PhysicalDevicePath...]
4)刪除卷組
先做vgremove,再做pvremove
4、lv工具
1)顯示邏輯卷
lvs:顯示邏輯卷簡單信息
lvdisplay:顯示詳細(xì)邏輯卷信息
2)刪除邏輯卷
lvremove /dev/VG_NAME/LV_NAME
3)重設(shè)文件系統(tǒng)大小
fsadm [options] resize device [new_size[BKMGTEP]] resize2fs [-f] [-F] [-M] [-P] [-p] device [new_size]
5)擴(kuò)展邏輯卷
lvextend -L [+]#[mMgGtT] /dev/VG_NAME/LV_NAME
resize2fs /dev/VG_NAME/LV_NAME
6)縮減邏輯卷
umount /dev/VG_NAME/LV_NAME
e2fsck -f /dev/VG_NAME/LV_NAME
resize2fs /dev/VG_NAME/LV_NAME
[mMgGtT]
lvreduce -L [-]#[mMgGtT] /dev/VG_NAME/LV_NAME
演示:
[root@centos6 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 3.7G 0 rom sda 8:0 0 120G 0 disk ├─sda1 8:1 0 200M 0 part /boot ├─sda2 8:2 0 80G 0 part / ├─sda3 8:3 0 20G 0 part /testdir ├─sda4 8:4 0 1K 0 part ├─sda5 8:5 0 4G 0 part [SWAP] └─sda6 8:6 0 2G 0 part sdb 8:16 0 120G 0 disk └─sdb1 8:17 0 2G 0 part [SWAP] sdc 8:32 0 20G 0 disk ├─sdc2 8:34 0 10G 0 part └─sdc1 8:33 0 2G 0 part /mnt/test sdd 8:48 0 20G 0 disk sde 8:64 0 20G 0 disk sdf 8:80 0 20G 0 disk [root@centos6 ~]# [root@centos6 ~]# pvcreate /dev/sd{c2,d} Physical volume "/dev/sdc2" successfully created Physical volume "/dev/sdd" successfully created [root@centos6 ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdc2 lvm2 ---- 10.00g 10.00g /dev/sdd lvm2 ---- 20.00g 20.00g [root@centos6 ~]# pvdisplay "/dev/sdc2" is a new physical volume of "10.00 GiB" --- NEW Physical volume --- PV Name /dev/sdc2 VG Name PV Size 10.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID PZRtfc-8dci-dW2V-ayy6-RVHQ-6oMh-q8LhwC "/dev/sdd" is a new physical volume of "20.00 GiB" --- NEW Physical volume --- PV Name /dev/sdd VG Name PV Size 20.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID X7gN2P-RysJ-Woci-IiIu-IphR-elkT-sAtSID ################創(chuàng)建邏輯卷組################## [root@centos6 ~]# vgcreate vg0 /dev/sd{c2,d} Volume group "vg0" successfully created [root@centos6 ~]# vgs VG #PV #LV #SN Attr VSize VFree vg0 2 0 0 wz--n- 30.00g 30.00g [root@centos6 ~]# vgdisplay --- Volume group --- VG Name vg0 System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 2 Act PV 2 VG Size 30.00 GiB PE Size 4.00 MiB Total PE 7679 Alloc PE / Size 0 / 0 Free PE / Size 7679 / 30.00 GiB VG UUID gbfTZO-aqo8-kdfg-cLkM-xXug-VWRK-hl1qSA ################創(chuàng)建邏輯卷################### [root@centos6 ~]# lvcreate -n lv0 -L 15G vg0 Logical volume "lv0" created. [root@centos6 ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert lv0 vg0 -wi-a----- 15.00g [root@centos6 ~]# lvdisplay --- Logical volume --- LV Path /dev/vg0/lv0 LV Name lv0 VG Name vg0 LV UUID XJ1Nco-ZP4s-h93D-YkIy-DcbN-6TEq-4XXJDI LV Write Access read/write LV Creation host, time centos6.localdomain, 2016-08-24 21:26:41 +0800 LV Status available # open 0 LV Size 15.00 GiB Current LE 3840 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 [root@centos6 ~]# mkfs.ext4 /dev/vg vg0/ vga_arbiter [root@centos6 ~]# mkfs.ext4 /dev/vg0/lv0 mke2fs 1.41.12 (17-May-2010) 文件系統(tǒng)標(biāo)簽= 操作系統(tǒng):Linux 塊大小=4096 (log=2) 分塊大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 983040 inodes, 3932160 blocks 196608 blocks (5.00%) reserved for the super user 第一個(gè)數(shù)據(jù)塊=0 Maximum filesystem blocks=4026531840 120 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208 正在寫入inode表: 完成 Creating journal (32768 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 This filesystem will be automatically checked every 36 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@centos6 ~]# vi /etc/fstab [root@centos6 ~]# blkid /dev/vg vg0/ vga_arbiter [root@centos6 ~]# blkid /dev/sda2: UUID="240533cf-b37f-4460-974f-702bab867da5" TYPE="ext4" /dev/sda1: UUID="4e245c68-a392-4ce9-9a99-5d32d8d43872" TYPE="ext4" /dev/sda3: UUID="86aa7b74-24df-4043-ba83-f3b41a99ce0e" TYPE="ext4" /dev/sda5: UUID="f8ef48ef-b141-48e5-9735-ff9089bd54ba" TYPE="swap" /dev/sda6: UUID="ca0c47c7-edb0-4685-8b29-44c6a5bf7a11" TYPE="ext4" LABEL="MYHOME" /dev/sdb1: UUID="443bb126-8dc0-45a3-acfe-9a37629bb511" TYPE="swap" /dev/sdc2: UUID="PZRtfc-8dci-dW2V-ayy6-RVHQ-6oMh-q8LhwC" TYPE="LVM2_member" /dev/sdd: UUID="X7gN2P-RysJ-Woci-IiIu-IphR-elkT-sAtSID" TYPE="LVM2_member" /dev/mapper/vg0-lv0: UUID="bac8210f-143d-4f89-a3fe-b75be6060274" TYPE="ext4" /dev/sdc1: UUID="7f140c30-7c34-4387-abac-b4687870463c" TYPE="ext4" [root@centos6 ~]# vi /etc/fstab [root@centos6 ~]# mount -a [root@centos6 ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda2 82438832 5772100 72472428 8% / tmpfs 502068 0 502068 0% /dev/shm /dev/sda1 194241 39067 144934 22% /boot /dev/sda3 20511356 45044 19417736 1% /testdir /dev/sdc1 2005848 84784 1815840 5% /mnt/test /dev/sdc1 2005848 84784 1815840 5% /home /dev/mapper/vg0-lv0 15350768 38384 14525952 1% /mnt/lv0 [root@centos6 ~]# cd /mnt/lv0/ [root@centos6 lv0]# ls lost+found [root@centos6 lv0]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 79G 5.6G 70G 8% / tmpfs 491M 0 491M 0% /dev/shm /dev/sda1 190M 39M 142M 22% /boot /dev/sda3 20G 44M 19G 1% /testdir /dev/sdc1 2.0G 83M 1.8G 5% /mnt/test /dev/sdc1 2.0G 83M 1.8G 5% /home /dev/mapper/vg0-lv0 15G 38M 14G 1% /mnt/lv0 ################擴(kuò)展邏輯卷################# [root@centos6 lv0]# lvextend -L +6G /dev/vg0/lv0 Size of logical volume vg0/lv0 changed from 15.00 GiB (3840 extents) to 21.00 GiB (5376extents). Logical volume lv0 successfully resized. [root@centos6 lv0]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 79G 5.6G 70G 8% / tmpfs 491M 0 491M 0% /dev/shm /dev/sda1 190M 39M 142M 22% /boot /dev/sda3 20G 44M 19G 1% /testdir /dev/sdc1 2.0G 83M 1.8G 5% /mnt/test /dev/sdc1 2.0G 83M 1.8G 5% /home /dev/mapper/vg0-lv0 15G 38M 14G 1% /mnt/lv0 [root@centos6 lv0]# resize2fs /dev/vg0/lv0 resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/vg0/lv0 is mounted on /mnt/lv0; on-line resizing required old desc_blocks = 1, new_desc_blocks = 2 Performing an on-line resize of /dev/vg0/lv0 to 5505024 (4k) blocks. The filesystem on /dev/vg0/lv0 is now 5505024 blocks long. [root@centos6 lv0]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 79G 5.6G 70G 8% / tmpfs 491M 0 491M 0% /dev/shm /dev/sda1 190M 39M 142M 22% /boot /dev/sda3 20G 44M 19G 1% /testdir /dev/sdc1 2.0G 83M 1.8G 5% /mnt/test /dev/sdc1 2.0G 83M 1.8G 5% /home /dev/mapper/vg0-lv0 21G 42M 20G 1% /mnt/lv0 ##############新增邏輯卷組及加入邏輯卷################ [root@centos6 ~]# pvcreate /dev/sde1 Physical volume "/dev/sde1" successfully created [root@centos6 ~]# vgextend /dev/vg0/ /dev/sde sde sde1 [root@centos6 ~]# vgextend /dev/vg0/ /dev/sde1 Volume group name "vg0/" has invalid characters. Cannot process volume group vg0/ [root@centos6 ~]# vgextend vg0 /dev/sde1 Volume group "vg0" successfully extended [root@centos6 ~]# vgs VG #PV #LV #SN Attr VSize VFree vg0 3 1 0 wz--n- 43.00g 22.00g [root@centos6 ~]# lvs \ > LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert lv0 vg0 -wi-ao---- 21.00g [root@centos6 ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdc2 vg0 lvm2 a--u 10.00g 9.00g /dev/sdd vg0 lvm2 a--u 20.00g 0 /dev/sde1 vg0 lvm2 a--u 13.00g 13.00g [root@centos6 ~]# lvcreate -L +13G /dev/vg0/lv0 Volume group name expected (no slash) Run `lvcreate --help' for more information. [root@centos6 ~]# lvextend -L +13G /dev/vg0/lv0 Size of logical volume vg0/lv0 changed from 21.00 GiB (5376 extents) to 34.00 GiB (8704extents). Logical volume lv0 successfully resized. [root@centos6 ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert lv0 vg0 -wi-ao---- 34.00g [root@centos6 ~]# resize2fs /dev/vg0/lv0 resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/vg0/lv0 is mounted on /mnt/lv0; on-line resizing required old desc_blocks = 2, new_desc_blocks = 3 Performing an on-line resize of /dev/vg0/lv0 to 8912896 (4k) blocks. The filesystem on /dev/vg0/lv0 is now 8912896 blocks long. [root@centos6 ~]# df -h |grep "vg0-lv0" /dev/mapper/vg0-lv0 34G 45M 32G 1% /mnt/lv0 ################刪除lv/vg/pv################## [root@centos6 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 3.7G 0 rom sda 8:0 0 120G 0 disk ├─sda1 8:1 0 200M 0 part /boot ├─sda2 8:2 0 80G 0 part / ├─sda3 8:3 0 20G 0 part /testdir ├─sda4 8:4 0 1K 0 part ├─sda5 8:5 0 4G 0 part [SWAP] └─sda6 8:6 0 2G 0 part sdb 8:16 0 120G 0 disk └─sdb1 8:17 0 2G 0 part [SWAP] sdc 8:32 0 20G 0 disk ├─sdc2 8:34 0 10G 0 part │ └─vg0-lv0 (dm-0) 253:0 0 34G 0 lvm /mnt/lv0 └─sdc1 8:33 0 2G 0 part /mnt/test sdd 8:48 0 20G 0 disk └─vg0-lv0 (dm-0) 253:0 0 34G 0 lvm /mnt/lv0 sde 8:64 0 20G 0 disk └─sde1 8:65 0 13G 0 part └─vg0-lv0 (dm-0) 253:0 0 34G 0 lvm /mnt/lv0 sdf 8:80 0 20G 0 disk [root@centos6 ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert lv0 vg0 -wi-ao---- 34.00g [root@centos6 ~]# lvremove /dev/vg0/lv0 Logical volume vg0/lv0 contains a filesystem in use. [root@centos6 ~]# umount /mnt/lv0/ [root@centos6 ~]# lvremove /dev/vg0/lv0 Do you really want to remove active logical volume lv0? [y/n]: y Logical volume "lv0" successfully removed [root@centos6 ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdc2 vg0 lvm2 a--u 10.00g 10.00g /dev/sdd vg0 lvm2 a--u 20.00g 20.00g /dev/sde1 vg0 lvm2 a--u 13.00g 13.00g [root@centos6 ~]# pvremove /dev/sdc2 --force WARNING: PV /dev/sdc2 belongs to Volume Group vg0 (consider using vgreduce). /dev/sdc2: physical volume label not removed. (If you are certain you need pvremove, then confirm by using --force twice.) [root@centos6 ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdc2 vg0 lvm2 a--u 10.00g 10.00g /dev/sdd vg0 lvm2 a--u 20.00g 20.00g /dev/sde1 vg0 lvm2 a--u 13.00g 13.00g [root@centos6 ~]# pvremove /dev/sdc2 --force WARNING: PV /dev/sdc2 belongs to Volume Group vg0 (consider using vgreduce). /dev/sdc2: physical volume label not removed. (If you are certain you need pvremove, then confirm by using --force twice.) [root@centos6 ~]# lvs [root@centos6 ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdc2 vg0 lvm2 a--u 10.00g 10.00g /dev/sdd vg0 lvm2 a--u 20.00g 20.00g /dev/sde1 vg0 lvm2 a--u 13.00g 13.00g [root@centos6 ~]# vgremove vg0 Volume group "vg0" successfully removed [root@centos6 ~]# vgs [root@centos6 ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdc2 lvm2 ---- 10.00g 10.00g /dev/sdd lvm2 ---- 20.00g 20.00g /dev/sde1 lvm2 ---- 13.01g 13.01g [root@centos6 ~]# pvremove /dev/sdc2 Labels on physical volume "/dev/sdc2" successfully wiped [root@centos6 ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdd lvm2 ---- 20.00g 20.00g /dev/sde1 lvm2 ---- 13.01g 13.01g [root@centos6 ~]# pvremove /dev/sdd Labels on physical volume "/dev/sdd" successfully wiped [root@centos6 ~]# pvremove /dev/sde1 Labels on physical volume "/dev/sde1" successfully wiped [root@centos6 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 3.7G 0 rom sda 8:0 0 120G 0 disk ├─sda1 8:1 0 200M 0 part /boot ├─sda2 8:2 0 80G 0 part / ├─sda3 8:3 0 20G 0 part /testdir ├─sda4 8:4 0 1K 0 part ├─sda5 8:5 0 4G 0 part [SWAP] └─sda6 8:6 0 2G 0 part sdb 8:16 0 120G 0 disk └─sdb1 8:17 0 2G 0 part [SWAP] sdc 8:32 0 20G 0 disk ├─sdc2 8:34 0 10G 0 part └─sdc1 8:33 0 2G 0 part /mnt/test sdd 8:48 0 20G 0 disk sde 8:64 0 20G 0 disk └─sde1 8:65 0 13G 0 part sdf 8:80 0 20G 0 disk [root@centos6 ~]# ################演示成功#################
本文為小耳朵原創(chuàng)作品,如有瑕疵可留言管理員哦:)
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。