问题:测试服务器突然zk挂了,重新启动后根本起不了,发现报错:
查询后发现根分区爆满:
解决问题:
一、在虚拟机上增加新盘
1、增加盘后将盘分区
[root@dbmysql ~]# fdisk /dev/sda
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): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): p
Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 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: 0x000c1368
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 125829119 61864960 8e Linux LVM
Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): 3
Invalid partition type `3'
Command (m for help): n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p):
Using default response p
Partition number (3,4, default 3): 3
First sector (125829120-419430399, default 125829120):
Using default value 125829120
Last sector, +sectors or +size{K,M,G} (125829120-419430399, default 419430399):
Using default value 419430399
Partition 3 of type Linux and of size 140 GiB is set
Command (m for help): p
Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 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: 0x000c1368
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 125829119 61864960 8e Linux LVM
/dev/sda3 125829120 419430399 146800640 83 Linux
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.
问题:此时我们在/dev下查不到sd3文件
解决办法:执行[root@dbmysql ~]# partprobe
格式化盘:
[root@dbmysql ~]# mkfs.xfs /dev/sda3
meta-data=/dev/sda3 isize=512 agcount=4, agsize=9175040 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=36700160, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=17920, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
查询到了我们的盘uuid
[root@dbmysql ~]# blkid
/dev/sda1: UUID="553e6333-e548-4aa9-942d-61f1e56afc9f" TYPE="xfs"
/dev/sda2: UUID="Z7YLpG-G8XF-lFay-Cc3i-0Z39-qPtN-vAp1lu" TYPE="LVM2_member"
/dev/mapper/cl-root: UUID="5aca02a1-813b-4b22-b004-905273bcabf7" TYPE="xfs"
/dev/mapper/cl-swap: UUID="bec18aee-7929-4bef-8f6e-419060bfad80" TYPE="swap"
/dev/mapper/cl-home: UUID="a1eaa957-ed36-4eb0-9013-4af168b3a438" TYPE="xfs"
/dev/sda3: UUID="95859c12-86cf-4c44-8408-d04847d595a2" TYPE="xfs"
二、扩盘
1、创建物理卷
[root@dbmysql ~]# pvcreate /dev/sda3
WARNING: xfs signature detected on /dev/sda3 at offset 0. Wipe it? [y/n]: y
Wiping xfs signature on /dev/sda3.
Physical volume "/dev/sda3" successfully created.
2、创建卷组
查询我们要扩充盘的卷组,然后将新的分区加入到卷组
[root@dbmysql ~]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home cl -wi-ao---- 18.70g
root cl -wi-ao---- 38.30g
swap cl -wi-ao---- 2.00g
以上看到卷组名称是cl
[root@dbmysql ~]# vgextend cl /dev/sda3
Couldn't create temporary archive name.
以上问题是盘空间不足导致,我在/tmp目录清理下,盘空间降下来了
[root@dbmysql tmp]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 39G 37G 1.7G 96% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 8.6M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 1014M 139M 876M 14% /boot
/dev/mapper/cl-home 19G 141M 19G 1% /home
tmpfs 378M 0 378M 0% /run/user/0
[root@dbmysql tmp]# vgextend cl /dev/sda3
Volume group "cl" successfully extended
3、扩充到我们的逻辑卷
查询当前的Free PE / Size的值
[root@dbmysql tmp]# vgdisplay
--- Volume group ---
VG Name cl
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 198.99 GiB
PE Size 4.00 MiB
Total PE 50942
Alloc PE / Size 15102 / 58.99 GiB
Free PE / Size 35840 / 140.00 GiB
VG UUID 9pLc6R-J6Lw-iqcv-DL8v-iZa7-m9ni-rbskmb
扩盘:
[root@dbmysql ~]# lvextend -L 100G /dev/mapper/cl-root
Size of logical volume cl/root changed from 38.30 GiB (9804 extents) to 100.00 GiB (25600 extents).
Logical volume cl/root successfully resized.
此时我们df查询盘情况:
[root@dbmysql ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 39G 37G 1.7G 96% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 8.6M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 1014M 139M 876M 14% /boot
/dev/mapper/cl-home 19G 141M 19G 1% /home
tmpfs 378M 0 378M 0% /run/user/0
发现盘还没有显示:
刷新显示,常用的命令刷新报错:因我们的系统既不是ext3也不是ext4,
[root@dbmysql ~]# resize2fs /dev/mapper/cl-root
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/cl-root
Couldn't find valid filesystem superblock.
解决办法:
[root@dbmysql ~]# xfs_growfs /dev/mapper/cl-root
meta-data=/dev/mapper/cl-root isize=512 agcount=4, agsize=2509824 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=10039296, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=4902, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 10039296 to 26214400
再一次查询发现盘已更新了
[root@dbmysql ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 100G 38G 63G 38% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 8.6M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 1014M 139M 876M 14% /boot
/dev/mapper/cl-home 19G 141M 19G 1% /home
tmpfs 378M 0 378M 0% /run/user/0