您现在的位置是:首页> 操作系统> Linux
LVM实战案例之LVM扩容
- 4600人已阅读
- 时间:2024-03-23 15:19:22
- 分类:Linux
接上所写
二、LVM扩容(本次扩容需要对pv,vg,lv等进行扩容)
需求分析:
/ora01需要扩容5G
(1)查看所需扩容的/ora01的空间情况
[root@db01 test]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 45G 4.4G 39G 11% / tmpfs 1004M 0 1004M 0% /dev/shm /dev/sda1 485M 39M 421M 9% /boot /dev/sdb2 79G 184M 75G 1% /oracle /dev/sdb1 20G 172M 19G 1% /soft /dev/sdd1 1007M 18M 939M 2% /alexpeng /dev/mapper/oraclevg-lvoracle 2.0G 68M 1.9G 4% /ora01
(2)查看当前vg大小,空闲空间小于5G
[root@db01 test]# vgs VG #PV #LV #SN Attr VSize VFree oraclevg 3 1 0 wz--n- 5.99g 3.99g [root@db01 /]# vgdisplay --- Volume group --- VG Name oraclevg System ID Format lvm2 Metadata Areas 3 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 3 Act PV 3 VG Size 5.99 GiB PE Size 4.00 MiB Total PE 1533 Alloc PE / Size 512 / 2.00 GiB Free PE / Size 1021 / 3.99 GiB VG UUID izNwjZ-XBiO-UVVl-y3H6-kvM4-gFUy-CXiaD1
(3)加载磁盘,并查看磁盘情况
[root@db01 /]# fdisk -l |grep "Disk /dev/sd" WARNING: GPT (GUID Partition Table) detected on '/dev/sdd'! The util fdisk doesn't support GPT. Use GNU Parted.' Disk /dev/sda: 53.7 GB, 53687091200 bytes Disk /dev/sdb: 107.4 GB, 107374182400 bytes Disk /dev/sdc: 107.4 GB, 107374182400 bytes Disk /dev/sdd: 1073 MB, 1073741824 bytes Disk /dev/sde: 2147 MB, 2147483648 bytes Disk /dev/sdf: 2147 MB, 2147483648 bytes Disk /dev/sdg: 2147 MB, 2147483648 bytes Disk /dev/sdh: 2147 MB, 2147483648 bytes
(4)将新添加的磁盘加入物理卷中
说明:添加整个磁盘到PV,可以不用分区不用格式化。如果添加分区到PV,需要用之前讲的fdisk或parted分区。
[root@db01 /]# pvcreate /dev/sdh Physical volume "/dev/sdh" successfully created [root@db01 /]# [root@db01 /]# pvs PV VG Fmt Attr PSize PFree /dev/sde oraclevg lvm2 a-- 2.00g 0 /dev/sdf oraclevg lvm2 a-- 2.00g 1.99g /dev/sdg oraclevg lvm2 a-- 2.00g 2.00g /dev/sdh lvm2 a-- 2.00g 2.00g
(5)将新建物理卷对卷组进行扩容
[root@db01 /]# vgextend oraclevg /dev/sdh Volume group "oraclevg" successfully extended [root@db01 /]# [root@db01 /]# vgs VG #PV #LV #SN Attr VSize VFree oraclevg 4 1 0 wz--n- 7.98g 5.98g
(6)在卷组上对逻辑卷进行扩容
[root@db01 /]# lvs LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert lvoracle oraclevg -wi-ao---- 2.00g [root@db01 /]# lvextend -L +5G /dev/oraclevg/lvoracle ###在lvoracle上扩容5G Extending logical volume lvoracle to 7.00 GiB Logical volume lvoracle successfully resized [root@db01 /]# [root@db01 /]# [root@db01 /]# lvs LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert lvoracle oraclevg -wi-ao---- 7.00g
(7)重新设置LV的文件系统大小
[root@db01 /]# resize2fs /dev/oraclevg/lvoracle resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/oraclevg/lvoracle is mounted on /ora01; on-line resizing required old desc_blocks = 1, new_desc_blocks = 1 Performing an on-line resize of /dev/oraclevg/lvoracle to 1835008 (4k) blocks. The filesystem on /dev/oraclevg/lvoracle is now 1835008 blocks long.
(8)检查逻辑卷扩容是否已经加载
[root@db01 /]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 45G 4.4G 39G 11% / tmpfs 1004M 0 1004M 0% /dev/shm /dev/sda1 485M 39M 421M 9% /boot /dev/sdb2 79G 184M 75G 1% /oracle /dev/sdb1 20G 172M 19G 1% /soft /dev/sdd1 1007M 18M 939M 2% /alexpeng /dev/mapper/oraclevg-lvoracle 6.9G 69M 6.5G 2% /ora01
(9)注意注意注意在一次Centos7上到最后一步报了如下错误:
resize2fs 1.42.9 (28-Dec-2013) resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root Couldn't find valid filesystem superblock.
经反复检查,才发现分区文件系统是XFS
[root@localhost ~]# fsck /dev/centos/root fsck from util-linux 2.23.2 If you wish to check the consistency of an XFS filesystem or repair a damaged filesystem, see xfs_repair(8).
所以到最后一步,调整文件大小的时候应该使用
xfs_growfs /dev/centos/root
相关文章
- linux的PV,VG,LV关系和操作详解
- linux磁盘分区与LVM详解
- LVM实战案例之pv,vg,lv创建到挂载
- LVM实战案例之LVM空间缩减(本次对PV,VG,LV等进行空间缩减)
- LVM实战案例之LVM删除
- LVM灾难修复坏一个硬盘怎么办
- MySql常用命令语法总结
- PHP获取操作系统函数
- apache的Rewrite详解
- linux修改用户密码命令
- linux查看与修改主机名
- linux修改SSH默认的端口号22
- 解决ssh登录后闲置时间过长而断开连接
- LINUX查看端口使用情况
- linux下查看CPU信息
- CMD常用命令总结
- LINUX系统如何区别是VPS还是独立的服务器
- linux设置IP地址
- vsftpd的配置文件详解
- linux中nmcli命令使用及网络配置包含无线
- sublime text3之Emmet插件快捷键助快速编程
- DVI-I和DVI-D区别与详解
- linux下fdisk命令实战案例之详解
- linux下parted命令实战分区
- apache配置SSL证书超详细教程
- CentOS7 systemctl配置文件详解