扩容前 df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 7.9G 0 7.9G 0% /dev tmpfs 7.9G 16M 7.9G 1% /dev/shm tmpfs 7.9G 840M 7.1G 11% /run tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup /dev/mapper/vg_root-lv_root 50G 4.3G 46G 9% / /dev/sda1 1014M 206M 809M 21% /boot /dev/mapper/vg_root-lv_var 10G 2.0G 8.1G 20% /var /dev/mapper/vg_data-lv_data 4.0T 3.6T 300G 90% /data 在vcenter或者vmware给虚拟机添加新的硬盘后,查看是否存在 1、fdisk -l 查找新加的硬盘 ,一般是最后一个 格式化硬盘 fdisk /dev/sdd 先按n创建,再选择 p 创建主分区,其他回车默认 2、给新加的硬盘创建分区 parted /dev/sdd GNU Parted 3.1 Using /dev/sdd Welcome to GNU Parted! Type 'help' to view a list of commands. 给创建的分区指定分区表 (parted) mklabel msdos (这里按照原系统有的的硬盘格式来做) Warning: The existing disk label on /dev/sdd will be destroyed and all data on this disk will be lost. Do you want to continue? Yes/No? yes (parted) quit Information: You may need to update /etc/fstab. 如果是给新的分区挂载,需要加到/etc/fstab自启 3、将物理硬盘分区初始化为物理卷,以便LVM使用 pvcreate /dev/sdd 查看卷组 [root@DB1 postgresql]# lvdisplay --- Logical volume --- LV Path /dev/vg_data/lv_data LV Name lv_data VG Name vg_data LV UUID FjYXcv-0F3W-uMny-OG71-fHll-gM7p-slrsvL LV Write Access read/write LV Creation host, time ZABBIX1, 2020-09-27 20:15:09 +0800 卷组拓展,把 /dev/sdd 加到 vg_data组 root@DB1 ~]# vgextend vg_data /dev/sdd Volume group "vg_data" successfully extended 分区拓展,把 /dev/sdd的空间拓展到 /dev/vg_data/lv_data 分区 [root@DB1 ~]# lvextend /dev/vg_data/lv_data /dev/sdd Size of logical volume vg_data/lv_data changed from <6.00 TiB (1572861 extents) to <8.00 TiB (2097148 extents). Logical volume vg_data/lv_data successfully resized. 4、执行扩容命令 [root@DB1 ~]# xfs_growfs /dev/vg_data/lv_data meta-data=/dev/mapper/vg_data-lv_data isize=512 agcount=9, agsize=134152192 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=1073739776, imaxpct=5 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=262016, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 1073739776 to 1610609664 5、查看扩容结果 df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 7.9G 0 7.9G 0% /dev tmpfs 7.9G 16M 7.9G 1% /dev/shm tmpfs 7.9G 840M 7.1G 11% /run tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup /dev/mapper/vg_root-lv_root 50G 4.3G 46G 9% / /dev/sda1 1014M 206M 809M 21% /boot /dev/mapper/vg_root-lv_var 10G 2.0G 8.1G 20% /var /dev/mapper/vg_data-lv_data 6.0T 3.6T 2.5T 60% /data |
错误信息