Linux-centos磁盘扩容

linux mysql扩容var目录下空间

背景环境:物理机--centos7系统,公司zabbix系统警告[Too many processes on Zabbix-server 10.0.0.0](javascript:void(0))

故障实例:使用df - h 查看磁盘空间如下,发现/var/已经使用了100%

解决方案:

1:原有目录已经满了,可用不到2G,申请40G硬盘后;进行扩容;

2:fdisk /dev/sdb (对sdb这块磁盘没有被使用的空间进行分区)

[root@zabbix-server ~]# fdisk /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.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x8305a435.

Command (m for help): p

Disk /dev/sdb: 42.9 GB, 42949672960 bytes, 83886080 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: 0x8305a435

   Device Boot      Start         End      Blocks   Id  System

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-83886079, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-83886079, default 83886079): 83886079M
Partition 1 of type Linux and of size 40 GiB is set

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

Calling ioctl() to re-read partition table.
Syncing disks.
[root@zabbix-server ~]# fdisk -l
......

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    83886079    41942016   83  Linux


#reboot 进行重启操作
[root@zabbix-server ~]# reboot

3:分区完后把新分区改成LVM 卷的文件系统

[root@zabbix-server ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
2621440 inodes, 10485504 blocks
524275 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2157969408
320 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   

[root@zabbix-server ~]# pvcreate /dev/sdb1
WARNING: ext4 signature detected on /dev/sdb1 at offset 1080. Wipe it? [y/n]: y
  Wiping ext4 signature on /dev/sdb1.
  Physical volume "/dev/sdb1" successfully created.
[root@zabbix-server ~]# vgextend centos /dev/sdb1
  Volume group "centos" successfully extended
[root@zabbix-server ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 1.9G     0  1.9G   0% /dev
tmpfs                    1.9G     0  1.9G   0% /dev/shm
tmpfs                    1.9G  9.0M  1.9G   1% /run
tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/centos-root   50G  723M   50G   2% /
/dev/mapper/centos-usr   5.0G  4.0G  1.1G  80% /usr
/dev/sda1                2.0G  191M  1.9G  10% /boot
/dev/mapper/centos-home   30G   33M   30G   1% /home
/dev/mapper/centos-var   2.0G  2.0G  232K 100% /var
/dev/mapper/centos-tmp  1014M   33M  982M   4% /tmp
tmpfs                    379M     0  379M   0% /run/user/0
[root@zabbix-server ~]# lvextend -L +40G /dev/mapper/centos-var
  Size of logical volume centos/var changed from 2.00 GiB (512 extents) to 42.00 GiB (10752 extents).
  Logical volume centos/var successfully resized.
[root@zabbix-server ~]#  xfs_growfs /dev/mapper/centos-var
meta-data=/dev/mapper/centos-var isize=512    agcount=4, agsize=131072 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=524288, 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 524288 to 11010048
[root@zabbix-server ~]# resize2fs -p /dev/mapper/centos-var
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-var
Couldn't find valid filesystem superblock.
[root@zabbix-server ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 1.9G     0  1.9G   0% /dev
tmpfs                    1.9G     0  1.9G   0% /dev/shm
tmpfs                    1.9G  9.0M  1.9G   1% /run
tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/centos-root   50G  723M   50G   2% /
/dev/mapper/centos-usr   5.0G  4.0G  1.1G  80% /usr
/dev/sda1                2.0G  191M  1.9G  10% /boot
/dev/mapper/centos-home   30G   33M   30G   1% /home
/dev/mapper/centos-var    42G  2.0G   40G   5% /var
/dev/mapper/centos-tmp  1014M   33M  982M   4% /tmp
tmpfs                    379M     0  379M   0% /run/user/0


###磁盘扩容结束,故障解决。
posted @ 2020-04-16 16:46  老王教你学Linux  阅读(1286)  评论(0编辑  收藏  举报