Showing posts with label IBM AIX - LVM. Show all posts
Showing posts with label IBM AIX - LVM. Show all posts

Thursday, September 6, 2012

IBM AIX - How to remove ODM information of a LV

IBM AIX - How to remove ODM information of a LV

Sometimes situations occur where a logical volume is deleted, but the ODM is not up to date. E.g. when "lsvg -l" doesn't show you the logical volume, but the lslv command can still show information about the logical volume. Not good.

To resolve this issue, first try:
# synclvodm -v [volume group name]
If that doesn't work, try this: (in the example below logical volume hd7 is used). Save the ODM information of the logical volume:
# odmget -q name=hd7 CuDv | tee -a /tmp/CuDv.hd7.out
# odmget -q name=hd7 CuAt | tee -a /tmp/CuAt.hd7.out
If you mess things up, you can allways use the following command to restore the ODM information:
# odmadd /tmp/[filename]
Delete the ODM information of the logical volume:
# odmdelete -o CuDv -q name=hd7
# odmdelete -o CuAt -q name=hd7
Then, remove the device entry of the logical volume in the /dev directory (if present at all).

IBM AIX - LVM Usage


IBM AIX - LVM Usage

One of the best tools to look at LVM usage is with lvmstat. It can report the bytes read and written to logical volumes. Using that information, you can determine which logical volumes are used the most.

Gathering LVM statistics is not enabled by default:
# lvmstat -v data2vg 0516-1309 lvmstat: Statistics collection is not enabled for this logical device. Use -e option to enable.
As you can see by the output here, it is not enabled, so you need to actually enable it for each volume group prior to running the tool using:
# lvmstat -v data2vg -e
The following command takes a snapshot of LVM information every second for 10 intervals:
# lvmstat -v data2vg 1 10
This view shows the most utilized logical volumes on your system since you started the data collection. This is very helpful when drilling down to the logical volume layer when tuning your systems.
# lvmstat -v data2vg Logical Volume iocnt Kb_read Kb_wrtn Kbps appdatalv 306653 47493022 383822 103.2 loglv00 34 0 3340 2.8 data2lv 453 234543 234343 89.3
What are you looking at here?
  • iocnt: Reports back the number of read and write requests.
  • Kb_read: Reports back the total data (kilobytes) from your measured interval that is read.
  • Kb_wrtn: Reports back the amount of data (kilobytes) from your measured interval that is written.
  • Kbps: Reports back the amount of data transferred in kilobytes per second.
You can use the -d option for lvmstat to disable the collection of LVM statistics.

Monday, September 3, 2012

IBM AIX - Logical Volume Manager (LVM) - Procedures

IBM AIX - Logical Volume Manager (LVM) - Procedures



Procedure to create a filesystem using JFS:

  • See below the procedure for creating a logical volume and a filesystem using JFS:

Procedure to extend the size of filesystem using JFS:


  1. "df" to see the filesystem, it's current size, % utilization and the name of it's logical volume
  2. "lslv <logical_volume>" to show information about the logical volume including it's volume group name.
  3. "lsvg <volume_group>" to show information about the volume group, including number of free pp's and the pp size
  4. If there are not enough free pp's then see below for procedure to add a disk to a volume group.
  5. "chfs -a size= +4194304 <MOUNT_POINT>" to grow the filesystem by 2 GB (4194304=2*1024*1024*1024/512)
    • NOTE:  Growing the file system will automatically grow the logical volume
  6. df" shows the file system's current size is 2 GB more than before.
Troubleshooting extending the size of a filesystem using JFS:
  • Error Message:  0516-787 extendlv: Maximum allocation for logical volume <LV_Name> is 512.
    • Maximum number of LPs for the logical volume has been exceeded - must increase the allocation
    • Calculate the number of LPs needed = LV Size in MB / LP size in MB
    • chlv -x <new_max_lps> <logical_volume>
Procedure to remove a file system
  1. Unmount the filesystem
  2. Remove the logical volume "rmlv <lv_name>"
  3. Remove the filesystem information from /etc/filesystems
Procedure to reduce the size of a file system - shareold is 8mb and needs to be reduced to 4mb
  1. Create the file system
    1. crfs -v jfs -m /usr/sharenew -g rootvg -a size=8192
    2. this makes a logical volume in the root volume group of 4MB that uses jfs
  2. Mount the volume
    1. mount /usr/sharenew
  3. Move the files from the old file system (/usr/shareold)
    1. cd /usr/shareold
    2. tar cf - | (cd /usr/sharenew; tar xvf -)
    3. cd
  4. Unmount the file systems
    1. umount /usr/sharenew
    2. umount /usr/shareold
  5. Remove the old file system and it's logical volume
    1. rmfs /usr/shareold
  6.   
    1. chfs -m /usr/shareold /usr/sharenew
  7. Mount the new filesystem
    1. mount /usr/shareold
  8. Delete the temporary mount point
    1. rmdir /usr/share


Logical Volume Procedures

Procedure to create a logical volume and filesystem in a volume group using JFS:
  1. lsvg to determine the size of the PP
  2. lslv in similar logical volumes to determine if mirroring is in effect
  3. Calculate the number of PPs needed for the logical volume
    1. bc
    2. scale=2
    3. <size of lv in MB>/<size of PP in MB>
    4. quit
  4. mklv -y  "<LV_NAME>" <VG_NAME> <# of LPS>  --> creates the logical volume
  5. crfs -v jfs -d <LV_NAME> -m /<MOUNTPOINT> -A yes   --> makes the filesystem, creates the mountpoint and puts it in /etc/filesystems
  6. mount /<MOUNTPOINT>  --> mounts the new fileystem
  7. df /<MOUNTPOINT>  --> verifies the mount and the size of the new filesystem
  8. Check the ownership and permissions of the new mount point
    • ls -ld <mountpoint>
    • chown owner:group <mountpoint>
    • chmod XXX <mountpoint>
  9. If mirroring is in effect, then mirror this logical volume to another disk (original and 1 mirror):
    • mklvcopy -s y <LV_NAME> 2

Check to see if  all of the logical volumes in a volume group are mirrored


  • lsvg -l

Mirror a logical volume after the fact


  •  mklvcopy -s y <LV_NAME> 2


Volume Group Procedures

Procedure to create a volume group:
  1. lsdev -C -c disk  -> lists available disks (and the hdisk#) on the server
  2. mkvg -y "<VG_NAME>" hdisk#  --> creates the volume group on the named hard disk
  3. varyonvg <VG_NAME>  --> activates the volume group
Procedure to add a disk to a volume group (extend the volume group)
  • extendvg <vg> <disk#>
    • Verify the disk has been successfully added to the vg
  • lsvg -p <vg>

Procedure to mirror the rootvg:


  1. lspv  --> determine the hdisk#
  2. extendvg rootvg hdisk<number>  --> add the hdisk to the volume group
  3. lspv  -->  verify that the hdisk has been successfully added to the volume group
  4. chvg -Q 'n' rootvg  -->  change the quorum so that the vg will stay active if one of the mirrors fail
  5. mirrorvg -S -c 2 rootvg  --> mirror all of the logical volumes in the volume group
  6. lsvg -l rootvg  --> verify successful mirroring (pps will appear "stale" until synchronization is complete).
  7. bosboot -a  -->  update the boot image information
  8. bootlist -m normal -o hdisk0 hdisk1  --> create a new bootlist
  9. bootlist -m normal -o  --> verify the bootlist is correct
Procedure to increase the number of LP's available
Assume we receive an error that the maximum number of LP's had been exceeded, and the maximum number of LP's defined was 1100:

  1. "lsvg <volume_group>" to show the total PP's available in the volume group =1250
  2. "lsvg -l <volume_group>" to show the total PP's used in all logical volumes in that volume group (showed sys1log, the jfs log was using 2 PP's)
  3. "chlv -x 1248 <logical_volume>" to change the maximum number of LP's from 1100 to 1248 (1250 PP's in the volume group - 2 PP's used by the jfs log  = 1248 available)


Physical Disk Procedures

Procedure to find disks/vpaths that are unallocated
  • lsvpcfg
    • This will show disks/vpaths and the volume group they are allocated to
  • lspv|grep None
    • This will show pvs and whether they are asssociated with a volume group
    • Note:  For vpaths, the hdisks will show as none, but they may be allocated to a vpath - you must grep each hdisk with the lsvpcfg

Procedure to make a new lun available to AIX


  • Allocate the new lun on the SAN
  • Run "cfgmgr"
  • Verify the new vpatch/hdisk by running "lsvpcfg"
    • There should be a new vpath and it should be available with no volume group - if not, rerun cfgmgr

Procedure to list the PVs in a volume group:


  • lsvg -p <volume group>

IBM AIX - Logical Volume Manager (LVM) Concepts & Commands

IBM AIX - Logical Volume Manager (LVM)

Concepts:

 • LVM (Logical Volume Manager) is the ever-present disk and volume management framework for AIX. The level of integration is visible not only in fileystem commands that understand the underlying LVM, but in other, higher level, commands like the install and backup utilities that can optionally grow filesytems when necessary.
• Physical disks (hdisks) are placed under LVM control by adding them to a VG (volume group). Within LVM, these disks are referred to as PVs (Physical Volumes).
• Each PV in a VG contains a unique ID called a PVID. The PVID of a disk is used to track all disks in a VG, but also provides a device name independence that makes importing, exporting, and disk management much simpler. Because the unique characteristics of the disk become the identifier, the device name remains consistent but does not need to as (properly) renaming / reordering disks under LVM control is of little consequence.
• Once a hdisk is placed into a VG it is divided into PP (Physical Partitions). PPs are then used to create LVs (Logical Volumes). An additional layer of abstraction is placed between an LV and a PP called a LP (Logical Partition) that allows for more than one PP to be used (i.e. mirrored) to back each portion of a LV.
 Several on-disk structures are responsible for holding all LVM information. The VGDA resides on each disk and holds structural information such as the member PVs. The VGSA also resides on each disk and contains status information on all member devices. The LVCB varies by VG type but traditionally has resided in the first part of an LV (when it exists as a separate structure). In addition to the basic LVM commands that manage these structures, there are a number of lower level LVM commands that accesses this metadata more directly.
• The first disk in a VG will have two copies of the VGDA, and a two disk VG will have one disk with a single VGDA and the other with two copies. For three disk and larger VGs, each disk has a single copy of the VGDA.
• The concept of quorum is achieved when > 50% of the copies of the VGSA/VGDAs are online. If quorum is lost then the VG can be taken offline.
• Quorum is problematic for two disk VGs because the loss of the two VGDA disk means a loss of the entire VG. In a mirrored configuration (a typical case for two-disk VGs) it is inappropriate to offline the VG for a single disk failure. For this reason, quorum rules can be turned off in the case of a two disk mirrored VG.
The ODM is central to managing off-disk LVM structures and physical device to hdisk mappings. When a VG is created or imported this information is added to the ODM as well as other system files such as /etc/filesystems.
• AIX LVM supports several versions of VGs that have been introduced over the lifetime of the product. The VG types are normal, big, and scalable. Normal VGs were the original creation and are more limited than the big or scalable types. The easiest way to tell the type of an existing VG is to look at the Max PV value for the VG (see example in the next section).
VG Type mkvg
option
Max
PV
Max
LV
Max
PP
Notes
Legacy
32 256 3512 Can be converted to Big VG
Big -B 128 512 130048 LVCB data is stored in the head of the data area in the LV
Scalable -S 1024 4096 2097152 Default LV and PP values are lower and can be increased to shown maximums 

The default filesystem on AIX is JFS2. JFS2, and it predecessor JFS, are both journaling filesystems that utilize the fundamental Unix filesystem structures such as i-nodes, directory structures, and block allocations. (Technically, JFS2 allocates blocks in groups called "extents".)
• JFS2 is not an implementation of UFS and expands considerably over basic filesystem features with such capabilities as snapshots, dynamic i-node allocation, online growth, extended attributes, and encryption. AIX provides a layer of abstraction over all supported filesystems that map filesystem specific structures to standard Unix filesystem tools so that filesystems like JFS2 appear as an implementation of UFS.
• While most journaled Unix filesystem implementations use inline logs (within the filesystem structure), AIX tends to use a special type of LV that is created only to contain log data. The jfs(2)log LV can provide logging capability for more than one filesystem LV. The log type must match the filesystem type. JFS2 can log to an inline log, but these implementations tend to be the exception to the rule.
• The default filesystems that are installed with AIX:
hd1 /home
hd2 /usr
hd3 /tmp
hd4 / root
hd5
BLV (Boot Logical Volume)
hd6
Paging space
hd8
JFS2 log
hd9var /var
hd10opt /opt
hd11admin /admin New in 6.1
livedump /var/adm/ras/livedump New in 6.1 TL3

/proc procfs pseudo filesystem




For General Commands and other details. Click here


Pages