修改卷组参数
在创建卷组时,会设置卷组的某些特性。使用 vgmodify 命令可以调整某些卷组参数,而不必
删除并重新创建卷组,也不必移动数据。vgmodify 命令允许您修改 1.0 版卷组和 2.x 版卷组的
不同参数。
对于 1.0 版卷组,可以使用 vgmodify 执行下列操作:
• 检测和处理物理卷大小更改。
• 修改每个物理卷可分配的最大物理盘区数。
• 修改每个卷组可包含的最大物理卷数。
• 修改卷组可包含的最大逻辑卷数。
• 将磁盘类型从可引导磁盘更改为非引导磁盘(反之亦然)。
• 处理物理卷 LUN 扩展。
• 准备物理卷以进行 LUN 缩减。
对于 2.x 版卷组,可以使用 vgmodify 执行下列操作:
• 检测和处理物理卷大小更改。
• 修改卷组的最大大小。
• 处理物理卷 LUN 扩展。
• 准备物理卷以进行 LUN 缩减。
从 2009 年 3 月更新版开始,对于 1.0 版和 2.x 版卷组,可联机运行 vgmodify 命令(卷组处
于激活状态且应用程序处于运行状态)。此外,对于 1.0 版卷组,vgmodify 可在卷组脱机(非
激活状态)的情况下运行。
用于 1.0 版卷组的 vgmodify
对于 1.0 版卷组,可执行下列步骤来调整每个 PV 的最大 PE 数、VG 中的最大 PV 数以及 VG 中
的最大 LV 数:
1. 运行 vgmodify 收集有关卷组的信息。
保存以下三个命令的输出:
# vgmodify -o -r vgnn
# vgmodify -v -t vgnn
# vgmodify -v -n -t vgnn
-o 选项会尝试通过充分利用现有的 LVM 元数据空间对这些值进行优化。-t 选项可报告设
置的优化范围而不重新计算物理盘区数目;通过 -n 选项可重新计算物理盘区的数目。
2. 根据上一步中收集的信息,选择新的卷组参数值。
3. 这些新值可能会增加每个物理卷上卷组保留区域 (VGRA) 的大小。VGRA 驻留在 LVM 标头
中,因此增加其大小可能需要移动物理卷上第一个物理盘区的任何用户数据。使用 pvmove
命令可将第一个物理盘区移动到其他位置。
4. 按照新的设置运行带 -r 选项的 vgmodify 检查这些值。
5. 如果需要,请停用卷组。
提示: 从 2009 年 3 月的 HP-UX 更新版开始,可在卷组处于活动状态时运行 vgmodify。
6. 运行不带 -r 选项的 vgmodify 提交新值。
7. 如果需要,请激活卷组。运行 vgdisplay 命令验证设置是否已应用。
示例:用于 1.0 版卷组的 vgmodify
例如,希望向卷组 vg32 中添加更大的磁盘。希望增加每个物理卷的最大物理盘区数 (max_pe)
和最大物理卷数 (max_pv)。以下是相关步骤:
1. 运行 vgmodify 收集有关卷组的信息。
保存以下三个命令的输出:
# vgmodify -o -r vg32
Current Volume Group settings:
Max LV 255
Max PV 16
Max PE per PV 1016
PE Size (Mbytes) 32
VGRA Size (Kbytes) 176
New configuration requires “max_pes” are increased from 1016 to 6652
The current and new Volume Group parameters differ.
An update to the Volume Group IS required
New Volume Group settings:
Max LV 255
Max PV 16
Max PE per PV 6652
PE Size (Mbytes) 32
VGRA Size (Kbytes) 896
Review complete. Volume group not modified
# vgmodify -v -t vg32
Current Volume Group settings:
Max LV 255
Max PV 16
Max PE per PV 1016
PE Size (Mbytes) 32
VGRA Size (Kbytes) 176
VGRA space (Kbytes) on Physical Volumes with extents in use:
PV current -n
/dev/rdisk/disk6 896 32768
/dev/rdisk/disk5 896 32768
Summary 896 32768
Volume Group optimized settings (no PEs renumbered):
max_pv(-p) max_pe(-e) Disk size (Mb)
2 53756 1720193
3 35836 1146753
…
213 296 9473
255 252 8065
# vgmodify -v -n -t vg32
Volume Group configuration for /dev/vg32 has been saved in
/etc/lvmconf/vg32.conf
Current Volume Group settings:
Max LV 255
Max PV 16
Max PE per PV 1016
PE Size (Mbytes) 32
VGRA Size (Kbytes) 176
VGRA space (Kbytes) on Physical Volumes with extents in use:
PV current -n
/dev/rdisk/disk6 896 32768
/dev/rdisk/disk5 896 32768
Summary 896 32768
Physical Extent zero is not free on all PVs. You will not achieve these
values until the first extent is made free (see pvmove(1M)) on all the
following disks:
/dev/rdisk/disk6
/dev/rdisk/disk5
Volume Group optimized settings (PEs renumbered lower):
max_pv(-p) max_pe(-e) Disk size (Mb)
61 65535 2097152
62 65532 2097056
…
252 16048 513568
255 15868 507808
2. 根据 vgmodify -n -t 的输出,为 max_pv 和 max_pe 分别选择 255 和 15868。
3. 由于新值要求物理盘区 0 可用,请使用 pvmove 将其移动到其他位置:
# pvmove /dev/disk/disk5:0 /dev/disk/disk5
Transferring logical extents of logical volume “/dev/vg32/lvol2″…
Physical volume “/dev/disk/disk5″ has been successfully moved.
Volume Group configuration for /dev/vg32 has been saved in
/etc/lvmconf/vg32.conf
# pvmove /dev/disk/disk6:0 /dev/disk/disk6
Transferring logical extents of logical volume “/dev/vg32/lvol1″…
Physical volume “/dev/disk/disk6″ has been successfully moved.
Volume Group configuration for /dev/vg32 has been saved in
/etc/lvmconf/vg32.conf
4. 使用带 -r 选项的 vgmodify 预览更改:
# vgmodify -p 255 -e 15868 -r -n vg32
Current Volume Group settings:
Max LV 255
Max PV 16
Max PE per PV 1016
PE Size (Mbytes) 32
VGRA Size (Kbytes) 176
The current and new Volume Group parameters differ.
An update to the Volume Group IS required
New Volume Group settings:
Max LV 255
Max PV 255
Max PE per PV 15868
PE Size (Mbytes) 32
VGRA Size (Kbytes) 32640
Review complete. Volume group not modified
5. 停用卷组:
# vgchange -a n vg32
Volume group “vg32″ has been successfully changed.
6. 提交新值:
# vgmodify -p 255 -e 15868 -n vg32
Current Volume Group settings:
Max LV 255
Max PV 16
Max PE per PV 1016
PE Size (Mbytes) 32
VGRA Size (Kbytes) 176
The current and new Volume Group parameters differ.
An update to the Volume Group IS required
New Volume Group settings:
Max LV 255
Max PV 255
Max PE per PV 15868
PE Size (Mbytes) 32
VGRA Size (Kbytes) 32640
New Volume Group configuration for “vg32″ has been saved in
“/etc/lvmconf/vg32.conf”
Old Volume Group configuration for “vg32″ has been saved in
“/etc/lvmconf/vg32.conf.old”
Starting the modification by writing to all Physical Volumes
Applying the configuration to all Physical Volumes from
“/etc/lvmconf/vg32.conf”
Completed the modification process.
New Volume Group configuration for “vg32″ has been saved in
“/etc/lvmconf/vg32.conf.old”
Volume group “vg32″ has been successfully changed.
7. 激活卷组并验证更改:
# vgchange -a y vg32
Activated volume group
Volume group “vg32″ has been successfully changed.
# vgdisplay vg32
— Volume groups —
VG Name /dev/vg32
VG Write Access read/write
VG Status available
Max LV 255
Cur LV 0
Open LV 0
Max PV 255
Cur PV 2
Act PV 2
Max PE per PV 15868
VGDA 4
PE Size (Mbytes) 32
Total PE 1084
Alloc PE 0
Free PE 1084
Total PVG 0
Total Spare PVs 0
Total Spare PVs in use 0
VG Version 1.0
用于 2.x 版卷组的 vgmodify
如果需要增大卷组的最大大小(在通过 vgcreate 命令创建 2.x 版卷组时选择该大小),可使
用 vgmodify -S 选项来增大卷组的最大大小。
例如,需要增大最大卷组的大小,以便能够通过 vgextend 命令或 LUN 扩展向卷组中添加更多
盘区(请参阅 vgmodify -E 选项)。
也可通过 vgmodify -S 选项减小卷组的最大大小,以便物理卷能提供更多的盘区。
增大卷组的最大大小可能需要将更多空间通过 LUN 扩展添加到每个物理卷。这种情况下,可以
同时调用 -E 和 -S 选项,以便只需一步即可处理 LUN 扩展和增大 VG 最大大小。
LVM 也可能会使用物理卷末尾的可用盘区来增大卷组的最大大小。如果某些物理卷的末尾没有足
够的可用盘区且这些物理卷不能通过 LUN 扩展来作进一步的扩展,则可能需要通过使用 pvmove
命令来释放这些物理卷末尾的盘区,以便重新定位正在使用这些盘区的逻辑卷。
使用 vgmodify -S 选项增大卷组的最大大小时,请注意只有在重新配置卷组中的所有物理卷
后,才会增大卷组的最大大小。
使用 vgmodify -S 选项减小卷组的最大大小时,请注意会在重新配置物理卷前减小卷组的最大
大小。
要增大 2.x 版卷组的最大大小,请执行下列步骤:
1. 使用 vgmodify 审阅模式验证所有物理卷是否有足够的可用空间,以将它们重新配置为所
需的更大 VG 最大大小。vgmodify 命令将检查可利用的 PV 末尾的可用盘区,并检查之前
LUN 扩展所产生的可用空间。您必须为审阅模式提供 -E 选项和 -S 选项,以便检查 LUN 扩
展。可能需要使用 pvmove 命令来重新定位位于 PV 末尾的逻辑卷。
# vgmodify -r -a -E -S 64t vg1
2. 如果审阅模式指明可以增大 VG 的最大大小,则执行实际的重新设置配置。该操作会将 VG
中的每个 PV 重新配置为新的(更大的)VG 最大大小。该操作还会自动将新盘区添加到 PV
中(其中新的盘区先前由于卷组已达到其最大盘区数而未被添加)。
# vgmodify -a -E -S 64t vg1
3. 通过运行 vgdisplay -v 命令验证重新设置配置的结果,以检查新的 VG 最大大小,新的
VG 最大盘区数以及可能已添加到某些 PV 中的其他盘区。
4. 如果任何 vgextend 先前无法将 PV 添加到卷组中,则现在重新运行这些命令。vgextend
命令必须能将更多的 PV 成功添加到 VG 中。运行 vgdisplay -v 验证现在是否有更多空
闲盘区可用。
5. 根据需要使用 lvextend -l 扩展逻辑卷,以允许它们容纳更多用户数据。也可通过使用
lvcreate 来创建更多逻辑卷。还可以通过使用 lvextend -m 添加更多镜像。
要减小 2.x 版卷组的最大卷组大小,请执行下列步骤:
1. 使用 vgmodify 的审阅模式验证是否可以将卷组的最大大小减小为所需的较小值。
# vgmodify -r -a -S 32t vg1
2. 如果审阅模式指明可以减小 VG 的最大大小,则执行实际的重新设置配置。vgmodify 命令
将重新配置 VG 中的每个 PV,以减小用于 LVM 配置数据的空间大小。未使用的空间将变为
新盘区,用于保存用户数据。
# vgmodify -a -S 32t vg1
3. 通过运行 vgdisplay -v 命令验证重新设置配置的结果,以便检查新的 VG 最大大小,新
的 VG 最大盘区数、新的 VG 盘区总数以及新的 VG 可用盘区数。
示例:用于 2.x 版卷组的 vgmodify
下面是一个当卷组达到其最大卷组大小限制时的联机重新设置示例。在该示例中,vgmodify
-S 选项用于增加已达到其最大 VG 大小限制的 2.x 卷组的最大 VG 大小。下面是方案:
卷组 /dev/vg1 有两个物理卷:/dev/disk/disk46 和 /dev/disk/disk47。
物理卷 /dev/disk/disk46 当前有 38398 个盘区,且该物理卷末尾的一些盘区是可用盘区。
物理卷 /dev/disk/disk47 当前有 25602 个盘区。卷组当前有 64000 个盘区 (38398 +
25602 = 64000)。
vgdisplay 所示的 VG 最大大小是 500 GB。卷组中的最大盘区数为 64000。
diskinfo 命令显示这两个物理卷的大小均为约 300 GB。然而,由于最大 VG 大小仅为 500
GB,因此 /dev/disk/disk47 上大约有 100 GB 当前不可用。此外,通过 vgextend 命令尝
试添加更多物理卷的操作将失败,因为卷组已经达到其最大 VG 大小限制。
要使 /dev/disk/disk47 上的全部 300 GB 可用,且允许通过 vgextend 命令将更多物理卷
添加到卷组,可使用 vgmodify -S 选项增大 VG 最大大小。在该示例中,最大大小从 500 GB
增加到 8 TB,以便有足够的增长空间。以下是相关步骤:
1. 运行 vgdisplay,该命令显示的 VG 最大大小为 500 GB 且卷组的最大盘区数(由 VG 的
最大大小确定)是 64000。
# vgdisplay -v vg1
— Volume groups —
VG Name /dev/vg1
…
VG Version 2.1
VG Max Size 500 GB
VG Max Entents 64000
…
2. 对物理卷运行 diskinfo 以显示它们的大小。
# diskinfo /dev/rdisk/disk46
# diskinfo /dev/rdisk/disk47
3. 在审阅模式下联机运行 vgmodify 来验证是否所有物理卷都可重新配置为新的(更大的)
VG 最大大小 (8 TB)。
# vgmodify -r -a -E -S 8t vg1
Physical volume “/dev/disk/disk46″ requires reconfiguration to be
provisioned to the requested maximum volume group size 8388608 MB.
Current number of extents: 38398
Number of extents after reconfiguration: 38396
…
Physical volume “/dev/disk/disk46″ was not changed.
Physical volume “/dev/disk/disk4″ requires reconfiguration to be
provisioned to the requested maximum volume group size 8388608 MB.
Current number of extents: 25602
Number of extents after reconfiguration: 25602
…
Physical volume “/dev/disk/disk47″ was not changed.
在该示例中,卷组中的所有物理卷都可重新配置,所以 /dev/vg1 的最大卷组大小可以从
500 GB 增大到 8 TB。
请注意,这两个空闲盘区将用于对 /dev/disk/disk46 进行重新配置,从而将物理卷上的
盘区数从 38398 减小至 38396。
4. 请注意,当在更改模式下运行 vgmodify -S 选项时,将向 /dev/disk/disk47 添加其
他盘区,如下所示。
# vgmodify -a -E -S 8t vg1
Reconfiguration of physical volume “/dev/disk/disk46″ for the
requested maximum volume group size 8388608 MB succeeded.
Previous number of extents: 38398
Number of extents after reconfiguration: 38396
Physical volume “/dev/disk/disk46″ was changed.
Volume Group configuration for /dev/vg1 has been saved in
/etc/lvmconf/vg1.conf
Reconfiguration of physical volume “/dev/disk/disk47″ for the
requested maximum volume group size 8388608 MB succeeded.
Previous number of extents: 25604
Number of extents after reconfiguration: 25604
Physical volume “/dev/disk/disk47″ was changed.
The maximum volume group size for “/dev/vg1″ has been
increased from 512000 MB to 8388608 MB.
Volume Group configuration for /dev/vg1 has been saved in
/etc/lvmconf/vg1.conf
正如审阅模式所示,已从 /dev/disk/disk46 中取走两个盘区以进行重新配置(从 38398
减小至 38396)。该操作允许在增加最大卷组大小前将两个盘区添加到 /dev/disk/disk47
中(从 25602 增加至 25604)
5. 请注意,增加 VG 最大大小后,/dev/disk/disk47 的盘区数从 25604 增加至 38396,
如 vgdisplay -v 所示。该命令确认 VG 最大大小已从 500 GB 增加至 8 TB,且 /dev/
disk/disk47 的盘区数已从 25602 增加至 38396,如下面的 vgdisplay 命令所示。
# vgdisplay –v vg1
— Volume groups —
VG Name /dev/vg1
…
PE Size (Mbytes) 8
Total PE 76792
Alloc PE 51196
Free PE 25596
…
VG Version 2.1
VG Max Size 8t
VG Max Extents 1048576
— Logical volumes —
LV Name /dev/vg1/lvol1
LV Status available/syncd
LV Size (Mbytes) 204784
Current LE 25598
Allocated PE 51196
Used PV 2
— Physical volumes —
PV Name /dev/disk/disk46
PV Status available
Total PE 38396
Free PE 12798
…
PV Name /dev/disk/disk47
PV Status available
Total PE 38396
Free PE 12798
本文为【爱上梁坤,爱上你】版权所有,欢迎转载。本站所有文章,未经说明,均为原创文章,转载敬请保留出处非常感谢。 本文链接:”http://www.liangkun.net/archives/755.html“
如果你觉得这篇文章对你有用,而且你又有自己的网站或者博客,请不要吝啬把本站加到你的友情链接,已经加入友情链接的朋友,请在本站留言说明,我也会在我的网站加入你的友情链接。
随机推荐文章
- « 上一篇:Linux 下批量建立目录

发表于 2011年12月15日 1:25 下午
怎么不更新文章了呢》?
[回复]
发表于 2011年11月27日 9:36 上午
跟博主学到了很多东西啊
[回复]