centos php7 无法加载mysqli_Linux-CentOS扩展根分区

f4669e722ec0fb4ef35b81bbb6da1e3c.png

一、前提说明

1、磁盘有空闲的分区或有空闲的磁盘

2、现有磁盘通过LVM分区,如果是直接分区则无法扩容(比如虚机完成加磁盘的操作)

二、确认前提条件:确认有空闲的分区及LVM分区

[root@perfvm01 ~]# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

vda 252:0 0 300G 0 disk

├─vda1 252:1 0 1G 0 part /boot

├─vda2 252:2 0 65G 0 part

├─centos-root 253:0 0 42.3G 0 lvm /

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

└─centos-home 253:2 0 254.7G 0 lvm /home

(vda 300G的空间,却只用了65G)

[root@perfvm01 ~]# fdisk -l

Disk /dev/vda: 322.1 GB, 322122547200 bytes, 629145600 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: 0x00017639

Device Boot Start End Blocks Id System

/dev/vda1 * 2048 2099199 1048576 83 Linux

/dev/vda2 2099200 138412031 68156416 8e Linux LVM

Disk /dev/mapper/centos-root: 45.4 GB, 45449478144 bytes, 88768512 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 /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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 /dev/mapper/centos-home: 22.2 GB, 22187868160 bytes, 43335680 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

三、使用空闲的分区新建分区

[root@perfvm01 ~]# fdisk /dev/vda

(注意:执行改命令是务必确认设备是不是vda,有的时候会是 /dev/sdb)

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.

Command (m for help): n #新建分区

Partition type:

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

e extended

Select (default p): p #主分区

Partition number (3,4, default 3): (直接敲回车)已经有两个,再生成就是第3个

First sector (138412032-629145599, default 138412032): (直接敲回车)

Using default value 138412032

Last sector, +sectors or +size{K,M,G} (138412032-629145599, default 629145599): (直接敲回车)

Using default value 629145599

Partition 3 of type Linux and of size 234 GiB is set

Command (m for help): w #保存退出

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.

The kernel still uses the old table. The new table will be used at

the next reboot or after you run partprobe(8) or kpartx(8)

Syncing disks.

[root@perfvm01 ~]# partprobe # 重新加载分区表、刷新

四、扩容vg

[root@perfvm01 ~]# vgdisplay #查看VG信息

--- Volume group ---

VG Name centos

……

VG Size <65.00 GiB

……

[root@perfvm01 ~]# pvcreate /dev/vda3 #vda3是新建的分区

Physical volume "/dev/vda3" successfully created.

[root@perfvm01 ~]# vgextend centos /dev/vda3 #centos 是上面的VG Name

Volume group "centos" successfully extended

[root@perfvm01 ~]# vgdisplay #再次查看VG信息

--- Volume group ---

VG Name centos

……

VG Size 298.99 GiB--此时已经变大了

……

五、扩容lv

[root@perfvm01 ~]# lvdisplay #查看lv信息

--- Logical volume ---

LV Path /dev/centos/swap

……

LV Size 2.00 GiB

……

--- Logical volume ---

LV Path /dev/centos/home

……

LV Size <20.67 GiB

……

--- Logical volume ---

LV Path /dev/centos/root

……

LV Size <42.33 GiB

……

[root@perfvm01 ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/centos-root 43G 3.9G 39G 10% /

devtmpfs 16G 0 16G 0% /dev

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

tmpfs 16G 8.3M 16G 1% /run

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

/dev/vda1 1014M 145M 870M 15% /boot

/dev/mapper/centos-home 21G 33M 21G 1% /home

[root@perfvm01 ~]# lvextend -l +100%FREE /dev/mapper/centos-home

#使用所有剩余空间

(注意,如果是打算挂载到根目录,那就是/dev/mapper/centos-root )

Size of logical volume centos/home changed from <20.67 GiB (5291 extents) to 254.66 GiB (65194 extents).

Logical volume centos/home successfully resized.

[root@perfvm01 ~]# lvdisplay #再次查看lv信息

--- Logical volume ---

LV Path /dev/centos/swap

……

LV Size 2.00 GiB

……

--- Logical volume ---

LV Path /dev/centos/home

……

LV Size 254.66 GiB

……

--- Logical volume ---

LV Path /dev/centos/root

……

LV Size <42.33 GiB

……

六、同步文件系统

[root@perfvm01 ~]# xfs_growfs /dev/mapper/centos-home #还是上面的文件路径

xfs_growfs /dev/mapper/centos-root

meta-data=/dev/mapper/centos-home isize=512 agcount=4, agsize=1354240 blks

= sectsz=512 attr=2, projid32bit=1

= crc=1 finobt=0 spinodes=0

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

= sunit=0 swidth=0 blks

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

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

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

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

data blocks changed from 5416960 to 66758656

[root@perfvm01 ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/centos-root 43G 3.9G 39G 10% /

devtmpfs 16G 0 16G 0% /dev

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

tmpfs 16G 8.3M 16G 1% /run

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

/dev/vda1 1014M 145M 870M 15% /boot

/dev/mapper/centos-home 255G 35M 255G 1% /home

[root@perfvm01 ~]# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

vda 252:0 0 300G 0 disk

├─vda1 252:1 0 1G 0 part /boot

├─vda2 252:2 0 65G 0 part

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

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

│ └─centos-home 253:2 0 254.7G 0 lvm /home

└─vda3 252:3 0 234G 0 part

└─centos-home 253:2 0 254.7G 0 lvm /home

再声明一点:每台服务器的分区设备号不一样,请务必确认设备号和你们想要扩容的目录(是home还是根目录),避免挂错目录,到时候还得卸载。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值