正文前先吐槽,虽然我们不在一组了,但小广告还是要打到,除非你邮箱拉黑我。。。
不过觉得这个问题还是经验遇到的,给大家提供参考。
其他组一个RAC环境的/目录满了。仔细找了下大的文件,还真没,不过他就个400多M,满了正常,但我们是不能再用其他的分区mount上去的,否则所有的文件全部被覆盖丢失。
[root@zhuol5spotl133 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-rootlv
496M 496M 0 100% /
/dev/mapper/rootvg-tmplv
1.5G 35M 1.4G 3% /tmp
/dev/mapper/rootvg-varlv
372M 106M 248M 30% /var
/dev/mapper/rootvg-homelv
496M 34M 437M 8% /home
/dev/mapper/rootvg-usrlv
3.0G 2.3G 553M 81% /usr
/dev/mapper/rootvg-optlv
186M 9.0M 168M 6% /opt
/dev/sda1 99M 16M 79M 17% /boot
tmpfs 800M 0 800M 0% /dev/shm
/dev/mapper/rootvg-u01lv
17G 15G 1.4G 91% /u01
[root@zhuol5spotl133 ~]# fdisk -l
Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 3263 26105625 8e Linux LVM
Disk /dev/sdb: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1958 15727603+ 83 Linux
我们可以看到,这个作为/ mount的是/dev/sda2,不过明显的是这个已经没空间了,3263=3263,否则直接使用命令即可:
lvextend -L +1G /dev/mapper/rootvg-rootlv
直接用extend命令扩展分区是不行的,会提示没有剩余空间。只是因为当初划分磁盘空间的时候逻辑卷组rootvg的大小已经固定了。卷组的大小确定后是不能更改的。只有通过往卷组中添加物理卷来扩大卷组的空间。而物理卷要由新的分区/磁盘来创建。
[root@zhuol5spotl133 dev]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name rootvg
PV Size 24.90 GB / not usable 21.77 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 796
Free PE 0
Allocated PE 796
PV UUID gDmYGb-Pvfp-Qt7h-sij9-lWPV-gvP2-UMkCQA
不过作为我们强大的VM,直接加大硬盘容量即可,关掉linux,扩容,再启动:
[root@zhuol5spotl133 ~]# fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 3263 26105625 8e Linux LVM
Disk /dev/sdb: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1958 15727603+ 83 Linux
这时发现硬盘有空间了,OK,我们直接新加物理分区:
[root@zhuol5spotl133 ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 5221.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (3264-5221, default 3264):
Using default value 3264
Last cylinder or +size or +sizeM or +sizeK (3264-5221, default 5221): +5120m 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.
Syncing disks.
[root@zhuol5spotl133 ~]# partprobe
[root@zhuol5spotl133 ~]# reboot
记得要重启才能生效。
[root@zhuol5spotl133 ~]# fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 3263 26105625 8e Linux LVM
/dev/sda3 3264 3886 5004247+ 83 Linux
Disk /dev/sdb: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1958 15727603+ 83 Linux
现在我们新加物理卷:
[root@zhuol5spotl133 ~]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
[root@zhuol5spotl133 ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name rootvg
PV Size 24.90 GB / not usable 21.77 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 796
Free PE 0
Allocated PE 796
PV UUID gDmYGb-Pvfp-Qt7h-sij9-lWPV-gvP2-UMkCQA
"/dev/sda3" is a new physical volume of "4.77 GB"
--- NEW Physical volume ---
PV Name /dev/sda3
VG Name
PV Size 4.77 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID YYoCFw-3hTL-CkKv-WXL5-oo2i-zJJb-DL6m5L
为卷组VolGroup00添加新的物理卷sda3来增大卷组的容量:
[root@zhuol5spotl133 dev]# vgextendrootvg /dev/sda3
Volume group "rootvg" successfully extended
扩展逻辑卷大小:
[root@zhuol5spotl133 dev]# lvextend -L +5G /dev/mapper/rootvg-rootlv
Extending logical volume rootlv to 5.50 GB
Insufficient free space: 160 extents needed, but only 152 available
[root@zhuol5spotl133 dev]# lvextend -L +4G /dev/mapper/rootvg-rootlv
Extending logical volume rootlv to 4.50 GB
Logical volume rootlv successfully resized
因为说是有5G,其实是不够的,我们还是老实地来个4G吧,成功了。看下效果:[root@zhuol5spotl133 dev]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-rootlv
496M 496M 0 100% /
/dev/mapper/rootvg-tmplv
1.5G 35M 1.4G 3% /tmp
/dev/mapper/rootvg-varlv
372M 105M 249M 30% /var
/dev/mapper/rootvg-homelv
496M 34M 437M 8% /home
/dev/mapper/rootvg-usrlv
3.0G 2.3G 553M 81% /usr
/dev/mapper/rootvg-optlv
186M 9.0M 168M 6% /opt
/dev/sda1 99M 16M 79M 17% /boot
tmpfs 800M 0 800M 0% /dev/shm
不过我们发现悲剧的容易还是只有496M,其实这时就算你重启,还是这个大小的。因为没用resize2fs命令:
[root@zhuol5spotl133 dev]# resize2fs /dev/mapper/rootvg-rootlv
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/rootvg-rootlv is mounted on /; on-line resizing required
Performing an on-line resize of /dev/mapper/rootvg-rootlv to 4718592 (1k) blocks.
The filesystem on /dev/mapper/rootvg-rootlv is now 4718592 blocks long.
[root@zhuol5spotl133 dev]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-rootlv
4.4G 497M 3.7G 12% /
/dev/mapper/rootvg-tmplv
1.5G 35M 1.4G 3% /tmp
/dev/mapper/rootvg-varlv
372M 105M 249M 30% /var
/dev/mapper/rootvg-homelv
496M 34M 437M 8% /home
/dev/mapper/rootvg-usrlv
3.0G 2.3G 553M 81% /usr
/dev/mapper/rootvg-optlv
186M 9.0M 168M 6% /opt
/dev/sda1 99M 16M 79M 17% /boot
tmpfs 800M 0 800M 0% /dev/shm
/dev/mapper/rootvg-u01lv
17G 15G 1.4G 92% /u01
这时我们发现,现在/的总容易=496m+4G=4.4G了,可用空间也有了。因为这不是共享磁盘,另一个节点如此炮制即可。