LVM学习逻辑卷管理创建逻辑卷遇到的问题
1 实验环境
系统 内核 发行版本
CentOS 2.6.32-754.2.1.el6.x86_64 CentOS release 6.10 (Final)
由于是最小化安装没有xfs,yum安装如下包支持此
[root@www ~]# yum install xfsprogs Loaded plugins: fastestmirror, security Setting up Install Process Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package xfsprogs.x86_64 0:3.1.1-20.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ====================================================================================================== Package Arch Version Repository Size ====================================================================================================== Installing: xfsprogs x86_64 3.1.1-20.el6 base 725 k Transaction Summary ====================================================================================================== Install 1 Package(s) Total download size: 725 k Installed size: 3.2 M Is this ok [y/N]: y Downloading Packages: xfsprogs-3.1.1-20.el6.x86_64.rpm | 725 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : xfsprogs-3.1.1-20.el6.x86_64 1/1 Verifying : xfsprogs-3.1.1-20.el6.x86_64 1/1 Installed: xfsprogs.x86_64 0:3.1.1-20.el6 Complete!
2 用gdisk分区对/dev/sdb分区然后再删除后遇到以下问题
[root@www ~]# pvcreate /dev/sdb Device /dev/sdb not found (or ignored by filtering)
3 解决方法
开始尝试使用partprobe /dev/sdb但是没有用处,后来用如下命令解决. [root@www ~]# dd if=/dev/urandom of=/dev/sdb bs=512 count=64 64+0 records in 64+0 records out 32768 bytes (33 kB) copied, 0.0513912 s, 638 kB/s [root@www ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 4.3G 0 rom sda 8:0 0 20G 0 disk ├─sda1 8:1 0 200M 0 part /boot ├─sda2 8:2 0 1G 0 part [SWAP] └─sda3 8:3 0 18.8G 0 part / sdb 8:16 0 1G 0 disk sdc 8:32 0 1G 0 disk sdd 8:48 0 1G 0 disk sde 8:64 0 1G 0 disk [root@www ~]# pvcreate /dev/sdb Physical volume "/dev/sdb" successfully created [root@www ~]# [root@www ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdb lvm2 ---- 1.00g 1.00g /dev/sdc lvm2 ---- 1.00g 1.00g /dev/sdd lvm2 ---- 1.00g 1.00g 为什么会报如上的错误呢,我现在还没有搞清楚. [root@www ~]# vgcreate storage /dev/sdb /dev/sdc /dev/sdd Volume group "storage" successfully created [root@www ~]# vgs VG #PV #LV #SN Attr VSize VFree storage 3 0 0 wz--n- 2.99g 2.99g [root@www ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdb storage lvm2 a--u 1020.00m 1020.00m /dev/sdc storage lvm2 a--u 1020.00m 1020.00m /dev/sdd storage lvm2 a--u 1020.00m 1020.00m
4 创建一个150M大小的逻辑卷
[root@www ~]# lvcreate -n vo -L 150M storage Rounding up size to full physical extent 152.00 MiB Logical volume "vo" created. [root@www ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert vo storage -wi-a----- 152.00m
5 把生成号的逻辑卷进行格式化,然后挂载使用.
[root@www ~]# mkfs.xfs /dev/storage/vo meta-data=/dev/storage/vo isize=256 agcount=4, agsize=9728 blks = sectsz=512 attr=2, projid32bit=0 data = bsize=4096 blocks=38912, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 log =internal log bsize=4096 blocks=1200, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 [root@www ~]# mount /dev/storage/vo /soft/ [root@www ~]# ls /soft/ [root@www ~]# 永久挂载,重启后生效,这里可以使用/dev/storage/vo也可以使用uuid推荐使用后者. UUID="645e5ca4-d564-425b-ad50-a9d43536951f" /soft xfs defaults 0 0 可以使用umount /soft卸载,再使用mount -a检查一下有没有挂载成功.使用df -h查看分区情况 [root@www ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 19G 1.7G 16G 10% / tmpfs 490M 0 490M 0% /dev/shm /dev/sda1 190M 59M 122M 33% /boot /dev/mapper/storage-vo 148M 7.8M 140M 6% /soft 扩容逻辑卷 这里使用lvextend -l 50指定200M大小的逻辑卷,计算方法为4M*50. [root@www ~]# lvextend -l 50 /dev/storage/vo Size of logical volume storage/vo changed from 152.00 MiB (38 extents) to 200.00 MiB (50 extents). Logical volume vo successfully resized. [root@www ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert vo storage -wi-a----- 200.00m 新硬盘加入vg卷组 [root@www ~]# pvcreate /dev/sde Physical volume "/dev/sde" successfully created [root@www ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdb storage lvm2 a--u 1020.00m 820.00m /dev/sdc storage lvm2 a--u 1020.00m 1020.00m /dev/sdd storage lvm2 a--u 1020.00m 1020.00m /dev/sde lvm2 ---- 1.00g 1.00g [root@www ~]# vgextend storage /dev/sde Volume group "storage" successfully extended [root@www ~]# vgs VG #PV #LV #SN Attr VSize VFree storage 4 1 0 wz--n- 3.98g 3.79g [root@www ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdb storage lvm2 a--u 1020.00m 820.00m /dev/sdc storage lvm2 a--u 1020.00m 1020.00m /dev/sdd storage lvm2 a--u 1020.00m 1020.00m /dev/sde storage lvm2 a--u 1020.00m 1020.00m 从vg卷组移除一块硬盘 [root@www ~]# vgreduce storage /dev/sde Removed "/dev/sde" from volume group "storage" [root@www ~]# vgs VG #PV #LV #SN Attr VSize VFree storage 3 1 0 wz--n- 2.99g 2.79g [root@www ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdb storage lvm2 a--u 1020.00m 820.00m /dev/sdc storage lvm2 a--u 1020.00m 1020.00m /dev/sdd storage lvm2 a--u 1020.00m 1020.00m /dev/sde lvm2 ---- 1.00g 1.00g 逻辑卷裁剪大小为120M [root@www ~]# lvreduce -L 120M /dev/storage/vo WARNING: Reducing active logical volume to 120.00 MiB. THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce storage/vo? [y/n]: y Size of logical volume storage/vo changed from 200.00 MiB (50 extents) to 120.00 MiB (30 extents). Logical volume vo successfully resized. [root@www ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert vo storage -wi-a----- 120.00m [root@www ~]# 删除逻辑卷,依次删除lv逻辑卷,gv卷组,pv物理卷 [root@www ~]# lvremove /dev/storage/vo Do you really want to remove active logical volume vo? [y/n]: y Logical volume "vo" successfully removed [root@www ~]# lvs [root@www ~]# vgremove storage Volume group "storage" successfully removed [root@www ~]# vgs [root@www ~]# pvremove /dev/sde Labels on physical volume "/dev/sde" successfully wiped [root@www ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdb lvm2 ---- 1.00g 1.00g /dev/sdc lvm2 ---- 1.00g 1.00g /dev/sdd lvm2 ---- 1.00g 1.00g [root@www ~]# pvremove /dev/sdd /dev/sdc /dev/sdb Labels on physical volume "/dev/sdd" successfully wiped Labels on physical volume "/dev/sdc" successfully wiped Labels on physical volume "/dev/sdb" successfully wiped [root@www ~]# pvs 数据迁移,首先创建一些文件touch /soft/{00..100}.txt,然后进行数据迁移. [root@www ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdb oradata lvm2 a--u 1020.00m 140.00m /dev/sdc oradata lvm2 a--u 1020.00m 1020.00m /dev/sdd oradata lvm2 a--u 1020.00m 1020.00m /dev/sde oradata lvm2 a--u 1020.00m 1020.00m [root@www ~]# pvmove /dev/sdb /dev/sdd /dev/sdb: Moved: 0.9% /dev/sdb: Moved: 36.4% /dev/sdb: Moved: 54.5% /dev/sdb: Moved: 100.0% [root@www ~]# pvs PV VG Fmt Attr PSize PFree /dev/sdb oradata lvm2 a--u 1020.00m 1020.00m /dev/sdc oradata lvm2 a--u 1020.00m 1020.00m /dev/sdd oradata lvm2 a--u 1020.00m 140.00m /dev/sde oradata lvm2 a--u 1020.00m 1020.00m [root@www ~]# 迁移后查看文件并没有丢失,最后删除这些文件. [root@www ~]# ls /soft/ 000.txt 010.txt 020.txt 030.txt 040.txt 050.txt 060.txt 070.txt 080.txt 090.txt 100.txt 001.txt 011.txt 021.txt 031.txt 041.txt 051.txt 061.txt 071.txt 081.txt 091.txt 002.txt 012.txt 022.txt 032.txt 042.txt 052.txt 062.txt 072.txt 082.txt 092.txt 003.txt 013.txt 023.txt 033.txt 043.txt 053.txt 063.txt 073.txt 083.txt 093.txt 004.txt 014.txt 024.txt 034.txt 044.txt 054.txt 064.txt 074.txt 084.txt 094.txt 005.txt 015.txt 025.txt 035.txt 045.txt 055.txt 065.txt 075.txt 085.txt 095.txt 006.txt 016.txt 026.txt 036.txt 046.txt 056.txt 066.txt 076.txt 086.txt 096.txt 007.txt 017.txt 027.txt 037.txt 047.txt 057.txt 067.txt 077.txt 087.txt 097.txt 008.txt 018.txt 028.txt 038.txt 048.txt 058.txt 068.txt 078.txt 088.txt 098.txt 009.txt 019.txt 029.txt 039.txt 049.txt 059.txt 069.txt 079.txt 089.txt 099.txt [root@www ~]# find /soft/ -type f -size 0 -delete
原文来自:
本文地址://lrxjmw.cn/lvmlogica-lvolume-management.html编辑:王健达,审核员:逄增宝
本文原创地址://lrxjmw.cn/lvmlogica-lvolume-management.html编辑:坑人小妖精,审核员:暂无