华为 虚拟机 fusion服务器,华为FusionCompute虚拟机挂载点磁盘空间在线扩容

当CentOS7平台的数据库服务器/usr挂载点磁盘空间不足时,通过在线扩容解决了问题。首先在FusionCompute虚拟化环境中添加磁盘,然后在虚拟机内部创建LVM物理分区,扩展卷组和逻辑卷,最后使用xfs_growfs命令扩容文件系统,成功将/usr挂载点从200G扩容至300G,实现了不关机的弹性扩容操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

需求描述:

由于数据中心某平台测试环境数据库服务器(192.168.104.7)挂载点/usr磁盘空间不足,导致Oracle数据库无法正常运行,因此需要对/usr挂载点进行在线扩容,由原来的200G扩容至300G。

处理过程如下:

1.登陆虚拟机查看磁盘挂载使用情况,看到/usr挂载点空间使用已经100%

[[email protected] ~]# df -h

Filesystem Size Used Avail Use% Mounted on

devtmpfs 16G 0 16G 0% /dev

tmpfs 16G 0 16G 0% /dev/shm

tmpfs 16G 194M 16G 2% /run

tmpfs 16G 0 16G 0% /sys/fs/cgroup

/dev/mapper/centos-root 50G 123M 50G 1% /

/dev/mapper/centos-usr 200G 200G 17M 100% /usr

/dev/xvda1 1014M 157M 858M 16% /boot

/dev/mapper/centos-var 100G 773M 100G 1% /var

/dev/mapper/centos-home 10G 10G 20K 100% /home

nfs1.ccic.com:/nfs/temp 450G 358G 93G 80% /software/temp

tmpfs 3.2G 0 3.2G 0% /run/user/0

tmpfs 3.2G 0 3.2G 0% /run/user/1001

查看当前虚拟机有几块磁盘

[[email protected] ~]# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sr0 11:0 1 1024M 0 rom

xvda 202:0 0 500G 0 disk

├─xvda1 202:1 0 1G 0 part /boot

├─xvda2 202:2 0 267.9G 0 part

│ ├─centos-root 253:0 0 50G 0 lvm /

│ ├─centos-swap 253:1 0 7.9G 0 lvm [SWAP]

│ ├─centos-usr 253:2 0 200G 0 lvm /usr

│ ├─centos-home 253:3 0 10G 0 lvm /home

│ └─centos-var 253:4 0 100G 0 lvm /var

└─xvda3 202:3 0 231.1G 0 part

└─centos-usr 253:2 0 200G 0 lvm /usr

1.登陆FusionCompute虚拟化web界面,找到需要绑定磁盘的虚拟机

fa239d435a7e8edac7a59eb03b42711c.png

2.选择更多功能-->绑定磁盘

61873e86c71d63a06c1ec04efc5d2b56.png

3.创建磁盘,然后绑定给虚拟机

07297400467ad09310f8052d5880a5a3.png

4.输入需要绑定磁盘的大小和磁盘名称,然后点击确定。

39a4e650744d551175c475929893acc7.png

5.虚拟机绑定磁盘后,登陆虚拟机可看到新增的磁盘

[[email protected] ~]# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sr0 11:0 1 1024M 0 rom

xvda 202:0 0 500G 0 disk

├─xvda1 202:1 0 1G 0 part /boot

├─xvda2 202:2 0 267.9G 0 part

│ ├─centos-root 253:0 0 50G 0 lvm /

│ ├─centos-swap 253:1 0 7.9G 0 lvm [SWAP]

│ ├─centos-usr 253:2 0 200G 0 lvm /usr

│ ├─centos-home 253:3 0 10G 0 lvm /home

│ └─centos-var 253:4 0 100G 0 lvm /var

└─xvda3 202:3 0 231.1G 0 part

└─centos-usr 253:2 0 200G 0 lvm /usr

xvde 202:64 0 100G 0 disk

6.查看虚拟机上的lvm和vg信息

[[email protected] ~]# vgs

VG #PV #LV #SN Attr VSize VFree

centos 2 5 0 wz--n- 498.99g <131.12g

[[email protected] ~]# lvs

LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert

home centos -wi-ao---- 10.00g

root centos -wi-ao---- 50.00g

swap centos -wi-ao---- <7.88g

usr centos -wi-ao---- 200.00g

var centos -wi-ao---- 100.00g

7.创建物理分区

[[email protected] ~]# fdisk /dev/xvde

Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0x251e7667.

Command (m for help): n

Partition type:

p primary (0 primary, 0 extended, 4 free)

e extended

Select (default p): p

Partition number (1-4, default 1):

First sector (2048-209715199, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): t

Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):

Using default value 209715199

Partition 1 of type Linux and of size 100 GiB is set

Command (m for help): t

Selected partition 1

Hex code (type L to list all codes): 8e

Changed type of partition ‘Linux‘ to ‘Linux LVM‘

Command (m for help): p

Disk /dev/xvde: 107.4 GB, 107374182400 bytes, 209715200 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier: 0x251e7667

Device Boot Start End Blocks Id System

/dev/xvde1 2048 209715199 104856576 8e Linux LVM

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

8.创建物理逻辑卷

[[email protected] ~]# pvcreate /dev/xvde1

Physical volume "/dev/xvde1" successfully created.

[[email protected] ~]# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sr0 11:0 1 1024M 0 rom

xvda 202:0 0 500G 0 disk

├─xvda1 202:1 0 1G 0 part /boot

├─xvda2 202:2 0 267.9G 0 part

│ ├─centos-root 253:0 0 50G 0 lvm /

│ ├─centos-swap 253:1 0 7.9G 0 lvm [SWAP]

│ ├─centos-usr 253:2 0 200G 0 lvm /usr

│ ├─centos-home 253:3 0 10G 0 lvm /home

│ └─centos-var 253:4 0 100G 0 lvm /var

└─xvda3 202:3 0 231.1G 0 part

└─centos-usr 253:2 0 200G 0 lvm /usr

xvde 202:64 0 100G 0 disk

└─xvde1 202:65 0 100G 0 part

9.先扩容lvm所在的vg卷组

[[email protected] ~]# vgs

VG #PV #LV #SN Attr VSize VFree

centos 2 5 0 wz--n- 498.99g <131.12g

[[email protected] ~]# vgextend centos /dev/xvde1 ##扩容卷组centos的大小

Volume group "centos" successfully extended

[[email protected] ~]# vgs

VG #PV #LV #SN Attr VSize VFree

centos 3 5 0 wz--n- <598.99g 231.11g

10.接下来扩容/usr挂载点空间大小,并对文件系统进行xfs_growfs 格式化。

[[email protected] ~]# lvextend /dev/centos/usr /dev/xvde1

Size of logical volume centos/usr changed from 200.00 GiB (51200 extents) to <300.00 GiB (76799 extents).

Logical volume centos/usr successfully resized.

[[email protected] ~]# xfs_growfs /dev/centos/usr

meta-data=/dev/mapper/centos-usr isize=512 agcount=8, agsize=6553600 blks

= sectsz=512 attr=2, projid32bit=1

= crc=1 finobt=0 spinodes=0

data = bsize=4096 blocks=52428800, imaxpct=25

= sunit=0 swidth=0 blks

naming =version 2 bsize=4096 ascii-ci=0 ftype=1

log =internal bsize=4096 blocks=12800, version=2

= sectsz=512 sunit=0 blks, lazy-count=1

realtime =none extsz=4096 blocks=0, rtextents=0

data blocks changed from 52428800 to 78642176

[[email protected] ~]# df -h

Filesystem Size Used Avail Use% Mounted on

devtmpfs 16G 0 16G 0% /dev

tmpfs 16G 0 16G 0% /dev/shm

tmpfs 16G 194M 16G 2% /run

tmpfs 16G 0 16G 0% /sys/fs/cgroup

/dev/mapper/centos-root 50G 123M 50G 1% /

/dev/mapper/centos-usr 300G 200G 101G 67% /usr

/dev/xvda1 1014M 157M 858M 16% /boot

/dev/mapper/centos-var 100G 773M 100G 1% /var

/dev/mapper/centos-home 10G 10G 20K 100% /home

nfs1.ccic.com:/nfs/temp 450G 358G 93G 80% /software/temp

tmpfs 3.2G 0 3.2G 0% /run/user/0

tmpfs 3.2G 0 3.2G 0% /run/user/1001

nfs1.ccic.com:/nfs/ccic 450G 358G 93G 80% /software/ccic

[[email protected] ~]# lvscan

ACTIVE ‘/dev/centos/root‘ [50.00 GiB] inherit

ACTIVE ‘/dev/centos/home‘ [10.00 GiB] inherit

ACTIVE ‘/dev/centos/swap‘ [<7.88 GiB] inherit

ACTIVE ‘/dev/centos/usr‘ [<300.00 GiB] inherit

ACTIVE ‘/dev/centos/var‘ [100.00 GiB] inherit

经验总结

在centos7.x上,可对挂载点lvm空间大小进行在线、不关机弹性缩减和扩容操作,因此在很多系统环境规划时,建议使用lvm技术,可以根据应用数据的大小对空间进行弹性扩容操作。

原文:https://blog.51cto.com/liuleis/2486453

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值