Production environments often run out of disk space, so let’s look at how to scale LVM volumes. Operation and maintenance practice :Linux system to expand the partition where Oracle database is operating and maintenance practice :Linux system to expand the partition where Oracle database is experimental environment: System: Oracle database is deployed in /home/oracle partition. Later, we found that the disk space is not enough, so we added a new hard disk to enlarge the partition of /home/oracle.

[root@localhost ~]# LSBLK NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0020g 0 disk ├─sda1 8:10 200M 0 part / Boot sigma ─sda2 8:2019g 0 Part sigma ─ setos-root 253:0 010g 0 LVM/Bass Exercises ─ setos-swap 253:1 04g 0 LVM [swap] -setos-home 253:2 0 5G 0 LVM/Home SR0 11:0 1 4.2G 0 ROM is used to partition, if not LVM partition can not be used in this way capacity expansion, Oracle directory is 5G size. /dev/sdb is a new hard disk

Add a hard disk and change the partition to LVM format [root@localhost ~]# fdisk /dev/sdb Welcome fdisk (util-Linux 2.23.2).

Changes stay in memory until you decide to write them to disk. Think twice before using the write command.

Device does not contain a recognized partition table (0xD10B295E)

N Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): n Partition type: p primary (0 primary, 0 extended, 4 free) P Sector No. (1-4, Default 1) : Starting Sector (2048-20971519, Default 2048-2048Last Sector, + Sector OR + Size {K,M,G} (2048-20971519, Default 20971519) : +5G partition 1 is set to Linux type and size is set to 5 GIB

Command (enter m for help) : t has selected partition 1 Hex code (enter L to list all codes) : 8e has changed the type of partition “Linux” to “Linux LVM”

Command (type m for help) : p

/dev/sdb: 10.7GB, 10737418240 bytes, 20971520 Units = sector of 1 * 512 = 512 bytes 512 bytes / 512 bytes I/O size (min/best) : 512 bytes / 512 bytes Disk Label Type: DOS Disk Identifier: 0xD10B295E

Boot Start End Blocks Id System /dev/sdb1 2048 10487807 5242880 8e Linux LVM

Command (type m for help) : w The partition table has been altered!

Calling ioctl() to re-read partition table. Synchronizing disks. [root@localhost ~]# pvcreate /dev/sdb1 Physical volume “/dev/sdb1” successfully created. [root@localhost ~]# vgdisplay — — Volume group — VG Name centos System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 3 Open LV 3 Max PV 0 Cur PV 1 Act PV 1 VG Size 19.00 GiB PE Size 4.00 MiB Total PE 4864 Alloc PE/Size 4864/19.00 GiB Free PE/Size 0/0 VG UUID Snqtmh-yg2a-y2gb-rzh6-yvjg-gvqh-6n2bxz The volume group name is CENTOS, and the size is 19G

[root@localhost ~]# vgextend centos /dev/sdb1 Volume group “centos” successfully extended [[email protected] ~]# vgdisplay — Volume group — VG Name centos System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 5 VG Access read/write VG Status resizable MAX LV 0 Cur LV 3 Open LV 3 Max PV 0 Cur PV 2 Act PV 2 VG Size <24.00 GiB PE Size 4.00 MiB Total PE 6143 Alloc PE/Size 4864/19.00 GiB Free PE/Size 1279 / <5.00 GiB VG UUID Snqtmh-yg2a-y2gb-rzh6-yvjg-gvqh-6n2bxz volume group size changed to 24G

[root@localhost ~]# lvresize-l +4G /dev/centos/home Size of logical volume centos/home changed from 5.00 GiB (1280 extents) to 9.00 GiB (2304 extents). Logical volume centos/home successfully resized. [root@localhost ~]# LSBLK NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0020g 0 disk ├─sda1 8:10 200M 0 part / Boot sigma ─sda2 8:2019g 0 Part sigma ─ setos-root 253:0 010g 0 LVM/Bass Exercises ─ setos-swap 253:1 04g 0 LVM [swap] -setos-home 253-2 0 0 9 g LVM/home SDB he 0 0, 10 g disk └ ─ sdb1 0 and 0 5 g part └ ─ centos – home 253:2 0 0 9 g LVM/home sr0 11:0 1 4.2G 0 ROM now sees the centos-home changed to 9G

[root@localhost ~]# DF-H File System Capacity Used Used % mount point /dev/mapper-centos-root 10G 927M 9.1g 10% / devtmpfs 478M 0 478M 0% /dev TMPFS 489M 0 489M 0% /dev/ SHM TMPFS 489M 6.8M 482M 2% /run TMPFS 489M 0 489M 0% /sys/fs/cgroup /dev/mapper-centos-home 5.0g 33M 5.0g 1% /home/dev/sda1 197M 103M 95M 53% /boot TMPFS 98M 0 98M 0% /run/user/0 /dev/mapper/centos-home is still 5G

[root@localhost ~]# xfs_growfs /dev/centos/home meta-data= /dev/mapper-centos-home isize=512 agcount=4, agsize=327680 blks

     =                       sectsz=512   attr=2, projid32bit=1
     =                       crc=1        finobt=0 spinodes=0

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

     =                       sunit=0      swidth=0 blks

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

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

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

realtime =none extsz=4096 blocks=0, Rtextents =0 data blocks changed from 1310720 to 2359296 using xfs_growfs for XFS using resize2fs for ext4

[root@localhost ~]# df-h filesystem capacity used Used % mount point /dev/mapper/centos-root 10G 927M 9.1g 10% / devtmpfs 478M 0 478M 0% /dev TMPFS 489M 0 489M 0% /dev/ SHM TMPFS 489M 0 489M 0% /dev/ SHM TMPFS 489M 0 489M 0% /sys/fs/cgroup /dev/mapper-centos-home 9.0g 33M 9.0g 1% /home/dev/sda1 197M 103M 95M 53% /boot TMPFS 98M 0 98M 0% /run/user/0 Then the /home/home partition is really expanded.

Summarized so, completed the expansion of production environment space.