Linux服务器由于应用变更或需求的缘故,有可能出现分区空间不足的情况,此时往往需要进行扩容(要增加分区的空间),而采用LVM的好处就是可以在不需停机的情况下可以方便地调整各个分区大小。如下所示,分区/u05由于备份集保留的时间调整,RMAN备份时出现空间不足的情况,如下所示,

[root@getlnx01 ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

                       97G   37G   55G  41% /

/dev/mapper/VolGroup01-LogVol00

                       79G   33G   43G  44% /u01

/dev/mapper/VolGroup02-LogVol00

                      197G  168G   19G  90% /u02

/dev/mapper/VolGroup03-LogVol00

                      197G  127G   60G  68% /u03

/dev/mapper/VolGroup04-LogVol00

                      138G  126G  5.6G  96% /u04

/dev/mapper/VolGroup05-LogVol00

                      178G  104G   65G  62% /u05

/dev/sda1              99M   23M   71M  25% /boot

tmpfs                  12G     0   12G   0% /dev/shm

[root@getlnx01 ~]# vgscan

  Reading all physical volumes.  This may take a while...

  Found volume group "VolGroup05" using metadata type lvm2

  Found volume group "VolGroup04" using metadata type lvm2

  Found volume group "VolGroup03" using metadata type lvm2

  Found volume group "VolGroup02" using metadata type lvm2

  Found volume group "VolGroup01" using metadata type lvm2

  Found volume group "VolGroup00" using metadata type lvm2

[root@getlnx01 ~]# 

我在添加了一块虚拟磁盘后(虚拟机),此时使用fdisk -l查不到刚刚添加的新磁盘,此时需要运行命令echo "- - -" > /sys/class/scsi_host/host0/scan重新扫描该接口下的SCSI磁盘设备。

关于该命令它是通过/sys下的属性设置运行SCSI扫描。echo "- - -" > scan "- - -"代表channel,target和LUN编号。以上命令会导致hba4下所有channel,target以及可见LUN被扫描。

 

[root@getlnx01 ~]# echo "- - -" > /sys/class/scsi_host/host0/scan

[root@getlnx01 ~]# fdisk -l

 

Disk /dev/sda: 55.8 GB, 55834574848 bytes

255 heads, 63 sectors/track, 6788 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        6788    54420187+  8e  Linux LVM

 

Disk /dev/sdb: 85.8 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1       10443    83883366    5  Extended

/dev/sdb5               1       10443    83883334+  83  Linux

 

Disk /dev/sdd: 214.7 GB, 214748364800 bytes

255 heads, 63 sectors/track, 26108 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdd1               1       26108   209712478+   5  Extended

/dev/sdd5               1       26108   209712447   83  Linux

 

Disk /dev/sdc: 214.7 GB, 214748364800 bytes

255 heads, 63 sectors/track, 26108 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1               1       26108   209712478+   5  Extended

/dev/sdc5               1       26108   209712447   83  Linux

 

Disk /dev/sdf: 64.4 GB, 64424509440 bytes

255 heads, 63 sectors/track, 7832 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdf1               1        7832    62910508+   5  Extended

/dev/sdf5               1        7832    62910477   83  Linux

 

Disk /dev/sde: 150.3 GB, 150323855360 bytes

255 heads, 63 sectors/track, 18275 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sde1               1       18275   146793906    5  Extended

/dev/sde5               1       18275   146793874+  83  Linux

 

Disk /dev/sdg: 193.2 GB, 193273528320 bytes

255 heads, 63 sectors/track, 23497 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdg1               1       23497   188739621    5  Extended

/dev/sdg5               1       23497   188739589+  83  Linux

 

Disk /dev/dm-0: 107.2 GB, 107206410240 bytes

255 heads, 63 sectors/track, 13033 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Disk /dev/dm-0 doesn't contain a valid partition table

 

Disk /dev/dm-1: 12.8 GB, 12884901888 bytes

255 heads, 63 sectors/track, 1566 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Disk /dev/dm-1 doesn't contain a valid partition table

 

Disk /dev/sdh: 85.8 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

Disk /dev/sdh doesn't contain a valid partition table

 

1:格式化分区

格式化磁盘设备/dev/sdh, 下面是采用逻辑扩展分区。关于格式分区时是否一定要修改分区类型为8e(LVM格式),我查了一些资料,这个不是必须的。鸟哥的Linux私房菜里面的原话为:“那个8e的出现会导致system变成Linux LMV! 其实没有设定为8e也没有关系,不过某些LMV的侦测指令可能会侦测不到该partition就是了”

[root@getlnx01 ~]# fdisk /dev/sdh

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. Changes will remain in memory only,

until you decide to write them. After that, of course, the previous

content won't be recoverable.

 

 

The number of cylinders for this disk is set to 10443.

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)

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

 

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

e

Partition number (1-4): 1

First cylinder (1-10443, default 1): 

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-10443, default 10443): 

Using default value 10443

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

[root@getlnx01 ~]# fdisk /dev/sdh

 

The number of cylinders for this disk is set to 10443.

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): p

 

Disk /dev/sdh: 85.8 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdh1               1       10443    83883366    5  Extended

 

Command (m for help): n

Command action

   l   logical (5 or over)

   p   primary partition (1-4)

l

First cylinder (1-10443, default 1): 

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-10443, default 10443): 

Using default value 10443

 

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

[root@getlnx01 ~]# 

 

 

2:新建物理卷(PV)

[root@getlnx01 ~]# pvcreate /dev/sdh5

  Physical volume "/dev/sdh5" successfully created

[root@getlnx01 ~]# pvdisplay /dev/sdh5

  "/dev/sdh5" is a new physical volume of "80.00 GB"

  --- NEW Physical volume ---

  PV Name               /dev/sdh5

  VG Name               

  PV Size               80.00 GB

  Allocatable           NO

  PE Size (KByte)       0

  Total PE              0

  Free PE               0

  Allocated PE          0

  PV UUID               LgKUuj-UddY-AHHO-ewqX-1iF1-6HYN-N5EITM

3:扩展卷组(VG)

首先查看VG的详细信息,然后扩展VG

[root@getlnx01 ~]# vgdisplay VolGroup05

  --- Volume group ---

  VG Name               VolGroup05

  System ID             

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  2

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                1

  Open LV               1

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               179.97 GB

  PE Size               32.00 MB

  Total PE              5759

  Alloc PE / Size       5759 / 179.97 GB

  Free  PE / Size       0 / 0   

  VG UUID               UNFxZH-lAGM-vqF3-jtNK-yuKT-enUX-WwL7FQ

   

 

   

[root@getlnx01 ~]# vgextend VolGroup05 /dev/sdh5

  Volume group "VolGroup05" successfully extended

[root@getlnx01 ~]# vgdisplay VolGroup05

  --- Volume group ---

  VG Name               VolGroup05

  System ID             

  Format                lvm2

  Metadata Areas        2

  Metadata Sequence No  3

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                1

  Open LV               1

  Max PV                0

  Cur PV                2

  Act PV                2

  VG Size               259.94 GB

  PE Size               32.00 MB

  Total PE              8318

  Alloc PE / Size       5759 / 179.97 GB

  Free  PE / Size       2559 / 79.97 GB

  VG UUID               UNFxZH-lAGM-vqF3-jtNK-yuKT-enUX-WwL7FQ

   

[root@getlnx01 ~]# 

4:处理文件系统

VG扩展后,/u05分区还不能实时增加空间,还需要使用resize2fs –p命令激活新增加的空间

 

[root@getlnx01 ~]# resize2fs -p  /dev/VolGroup05/LogVol00 

resize2fs 1.39 (29-May-2006)

Filesystem at /dev/VolGroup05/LogVol00 is mounted on /u05; on-line resizing required

Performing an on-line resize of /dev/VolGroup05/LogVol00 to 68141056 (4k) blocks.

 

The filesystem on /dev/VolGroup05/LogVol00 is now 68141056 blocks long.

 

[root@getlnx01 ~]# 

[root@getlnx01 ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

                       97G   37G   55G  41% /

/dev/mapper/VolGroup01-LogVol00

                       79G   33G   43G  44% /u01

/dev/mapper/VolGroup02-LogVol00

                      197G  168G   19G  90% /u02

/dev/mapper/VolGroup03-LogVol00

                      197G  127G   60G  68% /u03

/dev/mapper/VolGroup04-LogVol00

                      138G  126G  5.6G  96% /u04

/dev/mapper/VolGroup05-LogVol00

                      256G  104G  140G  43% /u05

/dev/sda1              99M   23M   71M  25% /boot

tmpfs                  12G     0   12G   0% /dev/shm

[root@getlnx01 ~]# 

Linux LVM学习总结——创建卷组VG

Linux LVM学习总结——删除卷组VG

Linux LVM学习总结——扩展卷组VG

Linux LVM学习总结——扩展卷组VG的更多相关文章

  1. Linux LVM学习总结——创建卷组VG

    在Linux平台如何创建一个卷组(VG)呢?下面简单介绍一下卷组(VG)的创建步骤.本文实验平台为Red Hat Enterprise Linux Server release 6.6 (Santia ...

  2. Linux LVM学习总结——删除卷组VG

    在Linux系统中,如何删除一个卷组(VG)呢? 下面我总结了一下如何删除卷组(VG)的具体步骤,仅供参考,如有不足,敬请指出.谢谢!在下面的例子中,我想删除卷组VolGroup05. 步骤1: 查看 ...

  3. Linux LVM学习总结——放大LV容量

    本篇介绍LVM管理中的命令lvresize,我们先创建一个卷组VG VolGroup02,它建立在磁盘/dev/sdc (大小为8G)上.创建逻辑卷LV时,我们故意只使用了一小部分.具体情况如下所示 ...

  4. Linux LVM学习总结——删除物理卷

    本篇介绍LVM管理中的命令vgreduce, pvremove.其实前面几篇中以及有所涉及. vgreduce:通过删除LVM卷组中的物理卷来减少卷组容量.注意:不能删除LVM卷组中剩余的最后一个物理 ...

  5. Linux LVM学习总结——Insufficient Free Extents for a Logical Volume

    如下所示,在创建LV的时候,偶尔会遇到"Volume group "xxxx" has insufficient free space (xxxx extents): x ...

  6. linux lvm管理基础教程

    linux lvm管理基础教程 本人是在redhat7.x系统上亲测lvm管理功能,至于文中所受的CentOS 6 没有亲自试过. 本文来自:https://geekpeek.net/lvm-phys ...

  7. Linux LVM硬盘管理之二:创建逻辑卷步骤

    创建逻辑卷(LV)的顺序:Linux分区---物理卷(PV)---卷组(VG)---逻辑卷(LV)---挂载到文件系统 删除逻辑卷(LV)的顺序:卸载文件系统----逻辑卷(LV)---卷组(VG)- ...

  8. Linux LVM简明教程

    逻辑卷管理LVM是一个多才多艺的硬盘系统工具.无论在Linux或者其他类似的系统,都是非常的好用.传统分区使用固定大小分区,重新调整大小十分麻烦.但是,LVM可以创建和管理“逻辑”卷,而不是直接使用物 ...

  9. Linux lvm在线扩容

    1.查看磁盘空间 [root@bgd-mysql3 ~]# fdisk -l Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sector ...

随机推荐

  1. SQL 邮件配置篇

    在我们运维工作中,经常要对备份,ETL等作业进行监控,这时我们需要用到SQL SERVER自带的邮件服务器,其原理,我在这么里不多说,直接来实战,下面是我对服务器配置源码,分享给大家,希望对大家有帮助 ...

  2. ASP.NET Core中的依赖注入(3): 服务的注册与提供

    在采用了依赖注入的应用中,我们总是直接利用DI容器直接获取所需的服务实例,换句话说,DI容器起到了一个服务提供者的角色,它能够根据我们提供的服务描述信息提供一个可用的服务对象.ASP.NET Core ...

  3. 查看当前数据库正在运行的Session

    当数据库运行比较缓慢时,我们需要实时查看当前有什么Session在运行,获得信息越完整,对于分析低性能的原因越有帮助.根据之前调优的经历,简单几步分析如下: 1.通过SQL Server内置的Sp_w ...

  4. 一个难倒 3年 android开发经验 " 工程师 " 的 "bug"

    一个关于 imageView 设置 scaleType 的问题. 就在刚才 晚上9 点多的时候,我的一个外包伙伴发一个工程代码我,叫我去看下这样一个"bug",说折腾了很久,图片选 ...

  5. [JSP]自定义标签库taglib

    自定义标签的步骤 自定义标签的步骤大概有三步: 1.继承javax.servlet.jsp.tagext.*下提供的几个标签类,如Tag.TagSupport.BodyTagSupport.Simpl ...

  6. es6学习笔记一数组(上)

    最近公司没什么事情,我们老大让我看看es6,小颖就练习了下数组的各个方法,今天先给大家分享一部分.嘻嘻,希望对大家有所帮助. every方法: 概述:    every() 方法测试数组的所有元素是否 ...

  7. Less使用心得

    初识less就被其函数式编程css深深吸引了,而函数式编写css带来的好处不言而喻,复用,复用,还是复用.话不多说下面简单介绍下个人使用less的心得 首先网上有很多less的安装教程,这边不多做介绍 ...

  8. UEditor百度富文本编辑器--preview在线预览时头部被挡住的解决方案

    问题截图: 正常情况应该是如下显示: 解决方案: 1.打开ueditor/dialogs/preview/preview.html 2.找到body节点下面这一句 document.getElemen ...

  9. C#开发微信门户及应用(36)--微信卡劵管理的封装操作

    前面几篇介绍了微信支付方面的内容,本篇继续微信接口的一些其他方面的内容:卡劵管理.卡劵管理是微信接口里面非常复杂的一个部分,里面的接口非常多,我花了不少时间对它进行了封装处理,重构优化等等工作,卡劵在 ...

  10. Android的历史与花边

    作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 历史 现在的Android如日中天.每天150万部的Android设备被激活,全球 ...