Red Hat ENTERPRISE LINUX 4 - LVM ADMINISTRATOR Manual

Cluster logical volume manager
Table of Contents

Advertisement

Quick Links

Red Hat Enterprise Linux 4
Cluster Logical
Volume Manager
LVM Administrator's Guide

Advertisement

Table of Contents
loading

Summary of Contents for Red Hat ENTERPRISE LINUX 4 - LVM ADMINISTRATOR

  • Page 1 Red Hat Enterprise Linux 4 Cluster Logical Volume Manager LVM Administrator's Guide...
  • Page 2 Cluster Logical Volume Manager Red Hat Enterprise Linux 4 Cluster Logical Volume Manager LVM Administrator's Guide Edition 1.0 Copyright © 2009 Red Hat Inc.. This material may only be distributed subject to the terms and conditions set forth in the Open Publication License, V1.0 or later (the latest version of the OPL is presently available at http://www.opencontent.org/openpub/).
  • Page 3: Table Of Contents

    Introduction 1. Audience ........................vii 2. Software Versions ......................vii 3. Related Documentation ....................vii 4. Document Conventions ....................viii 4.1. Typographic Conventions ................... viii 4.2. Pull-quote Conventions ..................x 4.3. Notes and Warnings ..................... x 5. Feedback ........................xi 1.
  • Page 4 Cluster Logical Volume Manager 4.3.11. Backing Up Volume Group Metadata .............. 26 4.3.12. Renaming a Volume Group ................27 4.3.13. Moving a Volume Group to Another System ............ 27 4.3.14. Recreating a Volume Group Directory ............. 28 4.4. Logical Volume Administration ..................28 4.4.1.
  • Page 5 6.4. Recovering Physical Volume Metadata ................ 70 6.5. Replacing a Missing Physical Volume ................71 6.6. Removing Lost Physical Volumes from a Volume Group ..........72 6.7. Insufficient Free Extents for a Logical Volume .............. 72 7. LVM Administration with the LVM GUI A.
  • Page 7: Introduction

    Introduction This book describes the Logical Volume Manager (LVM), including information on running LVM in a clustered environment. The content of this document is specific to the LVM2 release. 1. Audience This book is intended to be used by system administrators managing systems running the Linux operating system.
  • Page 8: Document Conventions

    Red Hat Cluster Suite documentation and other Red Hat documents are available in HTML and PDF versions online at the following location: http://www.redhat.com/docs 4. Document Conventions This manual uses several conventions to highlight certain words and phrases and draw attention to specific pieces of information.
  • Page 9 Typographic Conventions File-related classes include filesystem for file systems, file for files, and dir for directories. Each class has its own associated set of permissions. Proportional Bold This denotes words or phrases encountered on a system, including application names; dialogue box text;...
  • Page 10: Pull-Quote Conventions

    Introduction a server-pool. Under Apache HTTP Server 2.0, the responsibility for creating and maintaining these server-pools has been abstracted to a group of modules called Multi-Processing Modules (MPMs). Unlike other modules, only one module from the MPM group can be loaded by the Apache HTTP Server. 4.2.
  • Page 11: Feedback

    5. Feedback If you spot a typo, or if you have thought of a way to make this manual better, we would love to hear from you. Please submit a report in Bugzilla (http://bugzilla.redhat.com/bugzilla/) against the component rh-cs. Be sure to mention the manual's identifier: rh-clvm(EN)-4.8 (2009-05-14T12:46)
  • Page 13: The Lvm Logical Volume Manager

    Chapter 1. The LVM Logical Volume Manager This chapter provides a high-level overview of the components of the Logical Volume Manager (LVM). 1.1. Logical Volumes Volume management creates a layer of abstraction over physical storage, allowing you to create logical storage volumes. This provides much greater flexibility in a number of ways than using physical storage directly.
  • Page 14: Lvm Architecture Overview

    Chapter 1. The LVM Logical Volume Manager 1.2. LVM Architecture Overview For the RHEL 4 release of the Linux operating system, the original LVM1 logical volume manager was replaced by LVM2, which has a more generic kernel framework than LVM1. LVM2 provides the following improvements over LVM1: •...
  • Page 15: Running Lvm In A Cluster

    Running LVM in a Cluster 1.3. Running LVM in a Cluster The Clustered Logical Volume Manager (CLVM) is a set of clustering extensions to LVM. These extensions allow a cluster of computers to manage shared storage (for example, on a SAN) using LVM.
  • Page 16: Document Overview

    Chapter 1. The LVM Logical Volume Manager must not use single-instance LVM on the shared disk as this may result in data corruption. If you have any concerns please contact your Red Hat service representative. Note CLVM requires changes to the lvm.conf file for cluster-wide locking. For information on Section 3.1, “Creating LVM Volumes configuring the lvm.conf file to support CLVM, see in a...
  • Page 17: Lvm Components

    Chapter 2. LVM Components This chapter describes the components of an LVM Logical volume. 2.1. Physical Volumes The underlying physical storage unit of an LVM logical volume is a block device such as a partition or whole disk. To use the device for an LVM logical volume the device must be initialized as a physical volume (PV).
  • Page 18: Multiple Partitions On A Disk

    Chapter 2. LVM Components Figure 2.1. Physical Volume layout 2.1.2. Multiple Partitions on a Disk LVM allows you to create physical volumes out of disk partitions. It is generally recommended that you create a single partition that covers the whole disk to label as an LVM physical volume for the following reasons: •...
  • Page 19: Lvm Logical Volumes

    LVM Logical Volumes A logical volume is allocated into logical extents of the same size as the physical extents. The extent size is thus the same for all logical volumes in the volume group. The volume group maps the logical extents to physical extents.
  • Page 20: Striped Logical Volumes

    Chapter 2. LVM Components of 4MB. This volume group includes 2 physical volumes named PV1 and PV2. The physical volumes are divided into 4MB units, since that is the extent size. In this example, PV1 is 100 extents in size (400MB) and PV2 is 200 extents in size (800MB).
  • Page 21: Mirrored Logical Volumes

    Mirrored Logical Volumes striped logical volume. For large sequential reads and writes, this can improve the efficiency of the data I/O. Striping enhances performance by writing data to a predetermined number of physical volumes in round-round fashion. With striping, I/O can be done in parallel. In some situations, this can result in near-linear performance gain for each additional physical volume in the stripe.
  • Page 22: Snapshot Volumes

    Chapter 2. LVM Components LVM supports mirrored volumes. When you create a mirrored logical volume, LVM ensures that data written to an underlying physical volume is mirrored onto a separate physical volume. With LVM, you can create mirrored logical volumes with multiple mirrors. An LVM mirror divides the device being copied into regions that are typically 512KB in size.
  • Page 23 Snapshot Volumes Note Snapshot copies of a file system are virtual copies, not actual media backup for a file system. Snapshots do not provide a substitute for a backup procedure. The size of the snapshot governs the amount of space set aside for storing the changes to the origin volume.
  • Page 25: Lvm Administration Overview

    Chapter 3. LVM Administration Overview This chapter provides an overview of the administrative procedures you use to configure LVM logical volumes. This chapter is intended to provide a general understanding of the steps involved. For Chapter 5, LVM specific step-by-step examples of common LVM configuration procedures, see Configuration Examples.
  • Page 26: Growing A File System On A Logical Volume

    Chapter 3. LVM Administration Overview After creating the logical volume you can create and mount the file system. The examples in this document use GFS file systems. 1. Create a GFS file system on the logical volume with the gfs_mkfs command. 2.
  • Page 27 Logging • syslog • log file • external log function Appendix B, The The logging levels are set in the /etc/lvm/lvm.conf file, which is described in LVM Configuration Files.
  • Page 29: Lvm Administration With Cli Commands

    Chapter 4. LVM Administration with CLI Commands This chapter summarizes the individual administrative tasks you can perform with the LVM Command Line Interface (CLI) commands to create and maintain logical volumes. Note If you are creating or modifying an LVM volume for a clustered environment, you must Section 3.1, ensure that you are running the clvmd daemon.
  • Page 30: Physical Volume Administration

    Chapter 4. LVM Administration with CLI Commands Found volume group "new_vg" Creating new_vg-lvol0 Loading new_vg-lvol0 table Resuming new_vg-lvol0 (253:2) Clearing start of logical volume "lvol0" Creating volume group backup "/etc/lvm/backup/new_vg" (seqno 5). Logical volume "lvol0" created You could also have used the -vv, -vvv or the -vvvv argument to display increasingly more details about the command execution.
  • Page 31: Creating Physical Volumes

    Creating Physical Volumes 4.2.1. Creating Physical Volumes The following subsections describe the commands used for creating physical volumes. 4.2.1.1. Setting the Partition Type If you are using a whole disk device for your physical volume, the disk must have no partition table. For DOS disk partitions, the partition id should be set to 0x8e using the fdisk or cfdisk command or an equivalent.
  • Page 32: Displaying Physical Volumes

    Chapter 4. LVM Administration with CLI Commands /dev/ram5 16.00 MB] /dev/ram6 16.00 MB] /dev/ram7 16.00 MB] /dev/ram8 16.00 MB] /dev/ram9 16.00 MB] /dev/ram10 16.00 MB] /dev/ram11 16.00 MB] /dev/ram12 16.00 MB] /dev/ram13 16.00 MB] /dev/ram14 16.00 MB] /dev/ram15 16.00 MB] /dev/sdb 17.15 GB] /dev/sdb1...
  • Page 33: Preventing Allocation On A Physical Volume

    Preventing Allocation on a Physical Volume The following command shows all physical devices found: # pvscan PV /dev/sdb2 VG vg0 lvm2 [964.00 MB / 0 free] PV /dev/sdc1 VG vg0 lvm2 [964.00 MB / 428.00 MB free] PV /dev/sdc2 lvm2 [964.84 MB] Total: 3 [2.83 GB] / in use: 2 [1.88 GB] / in no VG: 1 [964.84 MB] You can define a filter in the lvm.conf so that this command will avoid scanning specific physical Section 4.6,...
  • Page 34: Creating Volume Groups

    Chapter 4. LVM Administration with CLI Commands 4.3.1. Creating Volume Groups To create a volume group from one or more physical volumes, use the vgcreate command. The vgcreate command creates a new volume group by name and adds at least one physical volume to The following command creates a volume group named vg1 that contains physical volumes /dev/ sdd1 and /dev/sde1.
  • Page 35: Adding Physical Volumes To A Volume Group

    Adding Physical Volumes to a Volume Group /dev/myvg2/lv03 The maximum device size with LVM is 8 Exabytes on 64-bit CPUs. 4.3.2. Adding Physical Volumes to a Volume Group To add additional physical volumes to an existing volume group, use the vgextend command. The vgextend command increases a volume group's capacity by adding one or more free physical volumes.
  • Page 36: Scanning Disks For Volume Groups To Build The Cache File

    Chapter 4. LVM Administration with CLI Commands PE Size 4.00 MB Total PE 13164 Alloc PE / Size 13 / 52.00 MB Free PE / Size 13151 / 51.37 GB VG UUID jxQJ0a-ZKk0-OpMO-0118-nlwO-wwqd-fD5D32 4.3.4. Scanning Disks for Volume Groups to Build the Cache File The vgscan command scans all supported disk devices in the system looking for LVM physical volumes and volume groups.
  • Page 37: Changing The Parameters Of A Volume Group

    Changing the Parameters of a Volume Group Cur LV PE Size (KByte) 4096 Total PE Free PE Allocated PE PV UUID Sd44tK-9IRw-SrMC-MOkn-76iP-iftz-OVSen7 If the physical volume is still being used you will have to migrate the data to another physical volume using the pvmove command.
  • Page 38: Removing Volume Groups

    Chapter 4. LVM Administration with CLI Commands Section 4.8, “Activating Logical Volumes on logical volumes on individual nodes in a cluster, see Individual Nodes in a Cluster”. 4.3.8. Removing Volume Groups To remove a volume group that contains no logical volumes, use the vgremove command. # vgremove officevg Volume group "officevg"...
  • Page 39: Renaming A Volume Group

    Renaming a Volume Group For an example of using the vgcfgrestore command to recover physical volume metadata, see Section 6.4, “Recovering Physical Volume Metadata”. 4.3.12. Renaming a Volume Group Use the vgrename command to rename an existing volume group. Either of the following commands renames the existing volume group vg02 to my_volume_group vgrename /dev/vg02 /dev/my_volume_group vgrename vg02 my_volume_group 4.3.13.
  • Page 40: Recreating A Volume Group Directory

    Chapter 4. LVM Administration with CLI Commands 6. Mount the file system to make it available for use. 4.3.14. Recreating a Volume Group Directory To recreate a volume group directory and logical volume special files, use the vgmknodes command. This command checks the LVM2 special files in the /dev directory that are needed for active logical volumes.
  • Page 41 Creating Logical Volumes You can use the -l argument of the lvcreate command to specify the size of the logical volume in extents. You can also use this argument to specify the percentage of the volume group to use for the logical volume.
  • Page 42 Chapter 4. LVM Administration with CLI Commands lvcreate -l 100 -n testlv testvg /dev/sda1:0-25:100- The default policy for how the extents of a logical volume are allocated is inherit, which applies the same policy as for the volume group. These policies can be changed using the lvchange command. Section 4.3.1, “Creating Volume Groups”.
  • Page 43 Creating Logical Volumes The following command creates a mirrored logical volume with a single mirror. The volume is 50 gigabytes in size, is named mirrorlv, and is carved out of volume group vg0: lvcreate -L 50G -m1 -n mirrorlv vg0 An LVM mirror divides the device being copied into regions that, by default, are 512KB in size.
  • Page 44: Persistent Device Numbers

    Chapter 4. LVM Administration with CLI Commands Note Creating a mirrored LVM logical volume in a cluster requires the same commands and procedures as creating a mirrored LVM logical volume on a single node. However, in order to create a mirrored LVM volume in a cluster the cluster and cluster mirror infrastructure must be running, the cluster must be quorate, and the locking type in the lvm.conf file must be set correctly to enable cluster locking.
  • Page 45: Resizing Logical Volumes

    Resizing Logical Volumes 4.4.3. Resizing Logical Volumes To reduce the size of a logical volume, use the lvreduce command. If the logical volume contains a file system, be sure to reduce the file system first (or use the LVM GUI) so that the logical volume is always at least as large as the file system expects it to be.
  • Page 46: Displaying Logical Volumes

    Chapter 4. LVM Administration with CLI Commands [root@tng3-1 lvm]# lvremove /dev/testvg/testlv Do you really want to remove active logical volume "testlv"? [y/n]: y Logical volume "testlv" successfully removed You could explicitly deactivate the logical volume before removing it with the lvchange -an command, in which case you would not see the prompt verifying whether you want to remove an active logical volume.
  • Page 47: Extending A Striped Volume

    Extending a Striped Volume lvextend -- doing automatic backup of volume group "myvg" lvextend -- logical volume "/dev/myvg/homevol" successfully extended The following command adds another gigabyte to the logical volume /dev/myvg/homevol. # lvextend -L+1G /dev/myvg/homevol lvextend -- extending logical volume "/dev/myvg/homevol" to 13 GB lvextend -- doing automatic backup of volume group "myvg"...
  • Page 48 Chapter 4. LVM Administration with CLI Commands # lvs -a -o +devices Attr LSize Origin Snap% Move Log Copy% Devices stripe1 vg -wi-a- 271.31G /dev/sda1(0),/ dev/sdb1(0) Note that the volume group now has no more free space. # vgs #PV #LV #SN Attr VSize VFree 0 wz--n- 271.31G...
  • Page 49: Shrinking Logical Volumes

    Shrinking Logical Volumes may result in uneven performance. When adding space to the logical volume, the default operation is to use the same striping parameters of the last segment of the existing logical volume, but you can override those parameters. The following example extends the existing striped logical volume to use the remaining free space after the initial lvextend command fails.
  • Page 50: Controlling Lvm Device Scans With Filters

    Chapter 4. LVM Administration with CLI Commands After you create a snapshot logical volume, specifying the origin volume on the lvdisplay command yields output that includes a a list of all snapshot logical volumes and their status (active or inactive). The following example shows the status of the logical volume /dev/new_vg/lvol0, for which a snapshot volume /dev/new_vg/newvgsnap has been created.
  • Page 51: Online Data Relocation

    Online Data Relocation You can control which devices LVM scans by setting up filters in the lvm.conf configuration file. The filters in the lvm.conf file consist of a series of simple regular expressions that get applied to the device names in the /dev directory to decide whether to accept or reject each block device found. The following examples show the use of filters to control which devices LVM scans.
  • Page 52: Activating Logical Volumes On Individual Nodes In A Cluster

    Chapter 4. LVM Administration with CLI Commands pvmove /dev/sdc1 The following command moves just the extents of the logical volume MyLV. pvmove -n MyLV /dev/sdc1 Since the pvmove command can take a long time to execute, you may want to run the command in the background to avoid display of progress updates in the foreground.
  • Page 53: Format Control

    Format Control • Instructions for specifying the units of the report output. 4.9.1. Format Control Whether you use the pvs, lvs, or vgs command determines the default set of fields displayed and the sort order. You can control the output of these commands with the following arguments: •...
  • Page 54 Chapter 4. LVM Administration with CLI Commands /dev/sdc1 new_vg lvm2 a- 17.14G 17.09G 17.14G Joqlch-yWSj-kuEn- IdwM-01S9-XO8M-mcpsVe /dev/sdd1 new_vg lvm2 a- 17.14G 17.14G 17.14G yvfvZK-Cf31-j75k- dECm-0RZ3-0dGW-tUqkCS • The --noheadings argument suppresses the headings line. This can be useful for writing scripts. The following example uses the --noheadings argument in combination with the pv_name argument, which will generate a list of all physical volumes.
  • Page 55: Object Selection

    Object Selection #PV #LV #SN Attr VSize VFree new_vg 0 wz--n- 51.42G 51.37G /dev/sdc1 new_vg 0 wz--n- 51.42G 51.37G /dev/sdd1 new_vg 0 wz--n- 51.42G 51.37G /dev/sdb1 4.9.2. Object Selection This section provides a series of tables that list the information you can display about the LVM objects with the pvs, vgs, and lvs commands.
  • Page 56 Chapter 4. LVM Administration with CLI Commands Argument Header Description PV UUID The UUID of the physical volume pv_uuid Table 4.1. pvs Display Fields The pvs command displays the following fields by default: pv_name, vg_name, pv_fmt, pv_attr, pv_size, pv_free. The display is sorted by pv_name. # pvs Attr PSize PFree...
  • Page 57 Object Selection /dev/sdc1 lvm2 a- 17.14G 17.14G 4389 /dev/sdd1 lvm2 a- 17.14G 17.14G 4389 /dev/sde1 lvm2 a- 17.14G 17.14G 4389 /dev/sdf1 lvm2 a- 17.14G 17.14G 4389 /dev/sdg1 lvm2 a- 17.14G 17.14G 4389 You can use the pvs -a command to see devices detected by LVM that have not been initialized as LVM physical volumes.
  • Page 58 Chapter 4. LVM Administration with CLI Commands Argument Header Description The size of the physical extents in the volume group vg_extent_size The metadata format of the volume group (lvm2 or vg_fmt lvm1) VFree Size of the free space remaining in the volume group vg_free Free Number of free physical extents in the volume group...
  • Page 59 Object Selection Argument Header Description Devices The underlying devices that make up the logical volume: devices the physical volumes, logical volumes, and start physical extents and logical extents Attr The status of the logical volume. The logical volume lv_attr attribute bits are as follows: Bit 1: Volume type: (m)irrored, (M)irrored without initial sync, (o)rigin, (p)vmove, (s)napshot, invalid (S)napshot, (v)irtual...
  • Page 60 Chapter 4. LVM Administration with CLI Commands Argument Header Description Type The segment type of a logical volume (for example: segtype mirror, striped, linear) Snap% Current percentage of a snapshot volume that is in use snap_percent #Str Number of stripes or mirrors in a logical volume stripes Stripe Unit size of the stripe in a striped logical volume...
  • Page 61: Sorting Lvm Reports

    Sorting LVM Reports Using the -v argument with the lvs --segments command adds the following fields to the default display: seg_start, stripesize, chunksize. # lvs -v --segments Finding all logical volumes Attr Start SSize #Str Type Stripe Chunk lvol0 new_vg owi-a- 52.00M 1 linear newvgsnap1 new_vg swi-a-...
  • Page 62: Specifying Units

    Chapter 4. LVM Administration with CLI Commands The following example shows that you do not need to display the field on which you are sorting. # pvs -o pv_name,pv_size -O pv_free PSize /dev/sdc1 17.14G /dev/sdd1 17.14G /dev/sdb1 17.14G To display a reverse sort, precede a field you specify after the -O argument with the - character. # pvs -o pv_name,pv_size,pv_free -O -pv_free PSize PFree...
  • Page 63 Specifying Units pvs --units G Attr PSize PFree /dev/sdb1 new_vg lvm2 a- 18.40G 18.40G /dev/sdc1 new_vg lvm2 a- 18.40G 18.35G /dev/sdd1 new_vg lvm2 a- 18.40G 18.40G You can also specify (s)ectors (defined as 512 bytes) or custom units. The following example displays the output of the pvs command as a number of sectors. # pvs --units s Attr PSize PFree...
  • Page 65: Lvm Configuration Examples

    Chapter 5. LVM Configuration Examples This chapter provides some basic LVM configuration examples. 5.1. Creating an LVM Logical Volume on Three Disks This example creates an LVM logical volume called new_logical_volume that consists of the disks at /dev/sda1, /dev/sdb1, and /dev/sdc1. 5.1.1.
  • Page 66: Creating The File System

    Chapter 5. LVM Configuration Examples 5.1.4. Creating the File System The following command creates a GFS file system on the logical volume. [root@tng3-1 ~]# gfs_mkfs -plock_nolock -j 1 /dev/new_vol_group/ new_logical_volume This will destroy any data on /dev/new_vol_group/new_logical_volume. Are you sure you want to proceed? [y/n] y Device: /dev/new_vol_group/new_logical_volume Blocksize:...
  • Page 67: Creating The Volume Group

    Creating the Volume Group Physical volume "/dev/sdc1" successfully created 5.2.2. Creating the Volume Group The following command creates the volume group striped_vol_group. [root@tng3-1 ~]# vgcreate striped_vol_group /dev/sda1 /dev/sdb1 /dev/sdc1 Volume group "striped_vol_group" successfully created You can use the vgs command to display the attributes of the new volume group. [root@tng3-1 ~]# vgs #PV #LV #SN Attr VSize...
  • Page 68: Splitting A Volume Group

    Chapter 5. LVM Configuration Examples Syncing... All Done The following commands mount the logical volume and report the file system disk space usage. [root@tng3-1 ~]# mount /dev/striped_vol_group/striped_logical_volume /mnt [root@tng3-1 ~]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 13902624 1656776 11528232 13% /...
  • Page 69: Splitting The Volume Group

    Splitting the Volume Group /dev/sdc1: Moved: 76.6% /dev/sdc1: Moved: 92.2% /dev/sdc1: Moved: 100.0% After moving the data, you can see that all of the space on /dev/sdc1 is free. [root@tng3-1 ~]# pvscan PV /dev/sda1 VG myvg lvm2 [17.15 GB / 0 free] PV /dev/sdb1 VG myvg...
  • Page 70: Activating And Mounting The Original Logical Volume

    Chapter 5. LVM Configuration Examples [root@tng3-1 ~]# gfs_mkfs -plock_nolock -j 1 /dev/yourvg/yourlv This will destroy any data on /dev/yourvg/yourlv. Are you sure you want to proceed? [y/n] y Device: /dev/yourvg/yourlv Blocksize: 4096 Filesystem Size: 1277816 Journals: Resource Groups: Locking Protocol: lock_nolock Lock Table: Syncing...
  • Page 71: Moving Extents To A New Disk

    Moving Extents to a New Disk /dev/sdc1 myvg lvm2 a- 17.15G 12.15G 5.00G /dev/sdd1 myvg lvm2 a- 17.15G 2.15G 15.00G We want to move the extents off of /dev/sdb1 so that we can remove it from the volume group. If there are enough free extents on the other physical volumes in the volume group, you can execute the pvmove command on the device you want to remove with no other options and the extents will be distributed to the other devices.
  • Page 72 Chapter 5. LVM Configuration Examples /dev/sdc1 myvg lvm2 a- 17.15G 15.15G 2.00G We want to move the extents of /dev/sdb1 to a new device, /dev/sdd1. 5.4.2.1. Creating the New Physical Volume Create a new physical volume from /dev/sdd1. [root@tng3-1 ~]# pvcreate /dev/sdd1 Physical volume "/dev/sdd1"...
  • Page 73: Creating A Mirrored Lvm Logical Volume In A Cluster

    Creating a Mirrored LVM Logical Volume in a Cluster [root@tng3-1 ~]# vgreduce myvg /dev/sdb1 Removed "/dev/sdb1" from volume group "myvg" You can now reallocate the disk to another volume group or remove the disk from the system. 5.5. Creating a Mirrored LVM Logical Volume in a Cluster Creating a mirrored LVM logical volume in a cluster requires the same commands and procedures as creating a mirrored LVM logical volume on a single node.
  • Page 74 Chapter 5. LVM Configuration Examples 4. Start the cmirror service. [root@doc-07 ~]# service cmirror start Loading clustered mirror log: 5. Create the mirror. The first step is creating the physical volumes. The following commands create three physical volumes. Two of the physical volumes will be used for the legs of the mirror, and the third physical volume will contain the mirror log.
  • Page 75 Creating a Mirrored LVM Logical Volume in a Cluster [root@doc-07 log]# lvs mirrorvg/mirrorlv Attr LSize Origin Snap% Move Log Copy% Convert mirrorlv mirrorvg mwi-a- 3.91G mirrorlv_mlog 47.00 [root@doc-07 log]# lvs mirrorvg/mirrorlv Attr LSize Origin Snap% Move Log Copy% Convert mirrorlv mirrorvg mwi-a- 3.91G mirrorlv_mlog 91.00 [root@doc-07 ~]#...
  • Page 76 Chapter 5. LVM Configuration Examples /dev/xvdc1:0-0 When you create the mirrored volume, you create the clustered_log dlm space, which will contain the dlm logs for all mirrors. [root@doc-07 log]# cman_tool services Service Name GID LID State Code Fence Domain: "default" 2 run [1 2 3] DLM Lock Space:...
  • Page 77: Lvm Troubleshooting

    Chapter 6. LVM Troubleshooting This chapter provide instructions for troubleshooting a variety of LVM issues. 6.1. Troubleshooting Diagnostics If a command is not working as expected, you can gather diagnostics in the following ways: • Use the -v, -vv, -vvv, or -vvvv argument of any command for increasingly verbose levels of output.
  • Page 78: Recovering From Lvm Mirror Failure

    Chapter 6. LVM Troubleshooting [root@link-07 tmp]# lvs -a -o +devices Volume group "vg" not found Using the -P argument shows the logical volumes that have failed. [root@link-07 tmp]# lvs -P -a -o +devices Partial mode. Incomplete volume groups will be activated read-only. Attr LSize Origin Snap%...
  • Page 79 Recovering from LVM Mirror Failure The following command creates the physical volumes which will be used for the mirror. [root@link-08 ~]# pvcreate /dev/sd[abcdefgh][12] Physical volume "/dev/sda1" successfully created Physical volume "/dev/sda2" successfully created Physical volume "/dev/sdb1" successfully created Physical volume "/dev/sdb2" successfully created Physical volume "/dev/sdc1"...
  • Page 80 Chapter 6. LVM Troubleshooting groupfs mwi-a- 752.00M groupfs_mlog 100.00 groupfs_mimage_0(0),groupfs_mimage_1(0) [groupfs_mimage_0] vg iwi-ao 752.00M /dev/sda1(0) [groupfs_mimage_1] vg iwi-ao 752.00M /dev/sdb1(0) [groupfs_mlog] lwi-ao 4.00M /dev/sdc1(0) In this example, the primary leg of the mirror /dev/sda1 fails. Any write activity to the mirrored volume causes LVM to detect the failed mirror.
  • Page 81 Recovering from LVM Mirror Failure PV /dev/sdg1 VG vg lvm2 [67.83 GB / 67.83 GB free] PV /dev/sdg2 VG vg lvm2 [67.83 GB / 67.83 GB free] PV /dev/sdh1 VG vg lvm2 [67.83 GB / 67.83 GB free] PV /dev/sdh2 VG vg lvm2 [67.83 GB / 67.83 GB free] PV /dev/sda1...
  • Page 82: Recovering Physical Volume Metadata

    Chapter 6. LVM Troubleshooting [groupfs_mimage_1] vg iwi-ao 752.00M /dev/sda1(0) [groupfs_mlog] lwi-ao 4.00M /dev/sdc1(0) 6.4. Recovering Physical Volume Metadata If the volume group metadata area of a physical volume is accidentally overwritten or otherwise destroyed, you will get an error message indicating that the metadata area is incorrect, or that the system was unable to find a physical volume with a particular UUID.
  • Page 83: Replacing A Missing Physical Volume

    Replacing a Missing Physical Volume (which could happen, for example, if the original pvcreate command had used the command line arguments that control metadata placement, or it the physical volume was originally created using a different version of the software that used different defaults). The pvcreate command overwrites only the LVM metadata areas and does not affect the existing data areas.
  • Page 84: Removing Lost Physical Volumes From A Volume Group

    Chapter 6. LVM Troubleshooting wish to substitute another physical volume of the same size, you can use the pvcreate command with the --restorefile and --uuid arguments to initialize a new device with the same UUID as the missing physical volume. You can then use the vgcfgrestore command to restore the volume group's metadata.
  • Page 85 Insufficient Free Extents for a Logical Volume # lvcreate -l8780 -n testlv testvg This uses all the free extents in the volume group. # vgs -o +vg_free_count,vg_extent_count #PV #LV #SN Attr VSize VFree Free #Ext testvg 0 wz--n- 34.30G 0 8780 Alternately, you can extend the logical volume to use a percentage of the remaining free space in the volume group by using the -l argument of the lvcreate command.
  • Page 87: Lvm Administration With The Lvm Gui

    Chapter 7. LVM Administration with the LVM GUI In addition to the Command Line Interface (CLI), LVM provides a Graphical User Interface (GUI) which you can use to configure LVM logical volumes. You can bring up this utility by typing system- config-lvm.
  • Page 89: The Device Mapper

    Appendix A. The Device Mapper The Device Mapper is a kernel driver that provides a generic framework for volume management. It provides a generic way of creating mapped devices, which may be used as logical volumes. It does not specifically know about volume groups or metadata formats. The Device Mapper provides the foundation for a number of higher-level technologies.
  • Page 91: The Lvm Configuration Files

    Appendix B. The LVM Configuration Files LVM supports multiple configuration files. At system startup, the lvm.conf configuration file is loaded from the directory specified by the environment variable LVM_SYSTEM_DIR, which is set to /etc/lvm by default. The lvm.conf file can specify additional configuration files to load. Settings in later files override settings from earlier ones.
  • Page 92 Appendix B. The LVM Configuration Files # /etc/lvm/lvm.conf file. # Refer to 'man lvm.conf' for further information including the file layout. # To put this file in a different directory and override /etc/lvm set # the environment variable LVM_SYSTEM_DIR before running the tools. # This section allows you to configure which block devices should # be used by the LVM system.
  • Page 93 Sample lvm.conf File # filter = [ "a/loop/", "r/.*/" ] # Or maybe all loops and ide drives except hdc: # filter =[ "a|loop|", "r|/dev/hdc|", "a|/dev/ide|", "r|.*|" ] # Use anchors if you want to be really specific # filter = [ "a|^/dev/hda8$|", "r/.*/" ] # The results of the filtering are cached on disk to avoid # rescanning dud devices (which can take a very long time).
  • Page 94 Appendix B. The LVM Configuration Files # This section that allows you to configure the nature of the # information that LVM2 reports. log { # Controls the messages sent to stdout or stderr. # There are three levels of verbosity, 3 being the most verbose. verbose = 0 # Should we send log messages through syslog? # 1 is yes;...
  • Page 95 Sample lvm.conf File # Configuration of metadata backups and archiving. In LVM2 when we # talk about a 'backup' we mean making a copy of the metadata for the # *current* system. The 'archive' contains old metadata configurations. # Backups are stored in a human readable text format. backup { # Should we maintain a backup of the current metadata configuration ? # Use 1 for Yes;...
  • Page 96 Appendix B. The LVM Configuration Files # Enabling test mode means that no changes to the on disk metadata # will be made. Equivalent to having the -t option on every # command. Defaults to off. test = 0 # Default value for --units argument units = "h"...
  • Page 97 Sample lvm.conf File # because cluster components such as clvmd are not running, with this # to 1 an attempt will be made to use local file-based locking (type # If this succeeds, only commands against local volume groups will proceed.
  • Page 98 Appendix B. The LVM Configuration Files # volume_list = [ "vg1", "vg2/lvol1", "@tag1", "@*" ] # Size (in KB) of each copy operation when mirroring mirror_region_size = 512 # Setting to use when there is no readahead value stored in the metadata.
  • Page 99 Sample lvm.conf File because it would break the redundant nature of the mirror. This policy acts like "remove" if no suitable device and space can be allocated for the replacement. mirror_log_fault_policy = "allocate" mirror_device_fault_policy = "remove" #################### # Advanced section # #################### # Metadata settings # metadata {...
  • Page 100 Appendix B. The LVM Configuration Files # reconfigures a mirror as necessary. If no mirror library is # provided, mirrors are not monitored through dmeventd. # mirror_library = "libdevmapper-event-lvm2mirror.so" # snapshot_library is the library used when monitoring a snapshot device. # "libdevmapper-event-lvm2snapshot.so"...
  • Page 101: Lvm Object Tags

    Appendix C. LVM Object Tags An LVM tag is a word that can be used to group LVM2 objects of the same type together. Tags can be attached to objects such as physical volumes, volume groups, and logical volumes. Tags can be attached to hosts in a cluster configuration.
  • Page 102: Controlling Activation With Tags

    Appendix C. LVM Object Tags C.3. Controlling Activation with Tags You can specify in the configuration file that only certain logical volumes should be activated on that host. For example, the following entry acts as a filter for activation requests (such as vgchange -ay) and only activates vg1/lvol0 and any logical volumes or volume groups with the database tag in the metadata on that host.
  • Page 103: Lvm Volume Group Metadata

    Appendix D. LVM Volume Group Metadata The configuration details of a volume group are referred to as the metadata. By default, an identical copy of the metadata is maintained in every metadata area in every physical volume within the volume group.
  • Page 104: Sample Metadata

    Appendix D. LVM Volume Group Metadata • Name and unique id • A version number which is incremented whenever the metadata gets updated • Any properties: Read/Write? Resizeable? • Any administrative limit on the number of physical volumes and logical volumes it may contain •...
  • Page 105 Sample Metadata device = "/dev/sda" # Hint only status = ["ALLOCATABLE"] dev_size = 35964301 # 17.1491 Gigabytes pe_start = 384 pe_count = 4390 # 17.1484 Gigabytes pv1 { id = "ZHEZJW-MR64-D3QM-Rv7V-Hxsa-zU24-wztY19" device = "/dev/sdb" # Hint only status = ["ALLOCATABLE"] dev_size = 35964301 # 17.1491 Gigabytes pe_start = 384...
  • Page 106 Appendix D. LVM Volume Group Metadata stripes = [ "pv0", 0 segment2 { start_extent = 1280 extent_count = 1280 # 5 Gigabytes type = "striped" stripe_count = 1 # linear stripes = [ "pv1", 0...
  • Page 107: Revision History

    Appendix E. Revision History Revision 1.0 Wed Apr 01 2009...
  • Page 109: Index

    Index persistent, 32 device path names, 17 device scan filters, 38 device size, maximum, 23 device special file directory, 22 activating logical volumes display individual nodes, 40 sorting output, 49 activating volume groups, 25 displaying individual nodes, 25 logical volumes, 34, 46 local node only, 25 physical volumes, 20, 43 administrative procedures, 13...
  • Page 110 Index displaying, 34, 40, 46 mirrored logical volume exclusive access, 40 clustered, 32, 61 extending, 34 converting to linear, 32 growing, 34 creation, 30 linear, 28 definition, 9 local access, 40 failure recovery, 66 lvs display arguments, 46 reconfiguration, 32 mirrored, 30 reducing, 37 removing, 33...
  • Page 111 report format, LVM devices, 40 definition, 6 resizing displaying, 23, 40, 45 logical volume, 33 extending, 23 physical volume, 21 growing, 23 merging, 26 moving between systems, 27 reducing, 24 scanning removing, 26 block devices, 19 renaming, 27 scanning devices, filters, 38 shrinking, 24 snapshot logical volume splitting, 26...

This manual is also suitable for:

Enterprise linux 4

Table of Contents