Showing posts with label lvsplit. Show all posts
Showing posts with label lvsplit. Show all posts

Monday, December 7, 2015

How to Perform HP-UX Patching with LVM rootvg split | Recovering or Rollback to older patch level using the Split LVs | Use of LVMPVG /etc/lvmpvg for PVG based Strict LVM mirroring of rootvg vg00 in HP-UX

This is a document to show how you can split the rootVG mirror on HP-UX for patching so that the Split mirrors can be used in order to roll-back to the older patch version.

Note : Depending on the basic setup of the server LVM root mirror this can need a bit of modification in your environment.

Also you can try using the DRD clone as an alternative for roll-back. Please look at the DRD Guide available for HP-UX at docs.hp.com

In the current scenario the setup has root VG has 2 disks which are mirrored in a strict manner using LVM mirroring.

This makes use of LVMPVG in order to have LVSPLIT and LVMERGE take care which PV are the source and destination of the original and the Split LV.

As a prerequisite you need to have understanding of HP-UX LVM Concepts.

1) create a file /etc/lvmpvg

VG vg00
PVG PVG1
/dev/dsk/c2t6d0
PVG PVG2
/dev/dsk/c0t6d0

2) vgdisplay -v vg00 | to confirm

3) lvlnboot -vR

4) make sure full mirror sync is there between the disks

for i in /dev/vg00/lv*
do
lvdisplay $i| grep -i copies
done


This should show 1 mirror copies for each LV

for i in /dev/vg00/lv*
do
lvdisplay -v $i | grep -i stale
done


this should show 0 stale PEs for the LVs

5)get the current setboot

Primary bootpath : 0/0/0/3/0.6.0 -- /dev/dsk/c2t6d0
HA Alternate bootpath : 0/0/0/2/0.6.0 -- /dev/dsk/c0t6d0
Alternate bootpath : 0/0/0/2/0.6.0


6) Make sure that the boot string for both the boot disks is set as “hpux /stand/vmunix -lq” for RP servers and “boot vmunix –lq” for RX servers.


FOR PA RISC(RP servers):

  1. lifls –l /dev/rdsk/c0t6d0
  2. lifls –l /dev/rdsk/c2t6d0
  3. lifcp /dev/rdsk/c0t6d0:AUTO –
  4. lifcp /dev/rdsk/c2t6d0 :AUTO –
  5. in case the auto boot string is not set as « hpux /stand/vmunix –lq” set this using the following commands
  6. mkboot –a “hpux /stand/vmunix –lq” /dev/rdsk/c0t6d0
  7. mkboot –a “hpux /stand/vmunix –lq” /dev/rdsk/c6t0d0
  8. check the same using commands c,d.



FOR ITANIUM servers(RX servers):

  1. lifls –l /dev/rdsk/c0t6d0s2
  2. lifls –l /dev/rdsk/c2t6d0s2
  3. efi_cp –u –d /dev/rdsk/c0t6d0s1 /efi/hpux/auto /tmp/auto11;cat /tmp/auto11
  4. efi_cp –u –d /dev/rdsk/c2t6d0s1 /efi/hpux/auto /tmp/auto22;cat /tmp/auto22
  5. in case the boot string is not set as “boot /stand/vmunix –lq” set this using the following commands.
  6. #echo “boot /stand/vmunix –lq” > /tmp/auto
  7. #efi_cp –d /dev/rdsk/c0t6d0s1 /tmp/auto /efi/hpux/auto
  8. #efi_cp –d /dev/rdsk/c2t6d0s1 /tmp/auto /efi/hpux/auto
Check the same using the commands in c,d.

7) Split the mirrors of LVs on root VG vg00

for i in /dev/vg00/lv*
do
lvsplit -g PVG2 $i
done


this shall create the split LVS in the name
/dev/vg00/<LV_name>b for all lvs

the all LVs after the split shall be as:

/dev/vg00/lvol1
/dev/vg00/lvol2
/dev/vg00/lvol3
/dev/vg00/lvol4
/dev/vg00/lvol5
/dev/vg00/lvol6
/dev/vg00/lvol7
/dev/vg00/lvol8
/dev/vg00/lvol1b – split LVs
/dev/vg00/lvol2b
/dev/vg00/lvol3b
/dev/vg00/lvol4b
/dev/vg00/lvol5b
/dev/vg00/lvol6b
/dev/vg00/lvol7b
/dev/vg00/lvol8b

  1. cp –pr /etc/fstab /etc/fstab.save

vi /etc/fstab.save --- MODIFY these lines in the file. Do not modify Lines pertaining to NON-VG00 FS.
/dev/vg00/lvol11 / vxfs delaylog 0 1 # lvol3 of original /etc/fstab
/dev/vg00/lvol9 /stand hfs defaults 0 1 # lvol1 of original /etc/fstab
/dev/vg00/lvol12 /home vxfs delaylog 0 2 # lvol4 of original /etc/fstab
/dev/vg00/lvol13 /opt vxfs delaylog 0 2 # lvol5 of original /etc/fstab
/dev/vg00/lvol14 /tmp vxfs delaylog 0 2 # lvol6 of original /etc/fstab
/dev/vg00/lvol15 /usr vxfs delaylog 0 2 # lvol7 of original /etc/fstab
/dev/vg00/lvol16 /var vxfs delaylog 0 2 # lvol8 of original /etc/fstab

NOTE: If the root VG has the LVs as lvol1,2,3,4,5,6,7,8, then we shall use in the new /etc/fstab.save the LVS as lvol9,10,11,12,13,14,15,16 respectivley.

Keep this file handy


10) Now the OS patching can be done. And reboot the server.

11) To mirror back the split LVS after patching and observing the same for over a period of time run the following command.

See man (1M) lvmerge for more information:


#for i in /dev/vg00/lv*
>do
>lvmerge ${i}b $i
>done



MAN LVMERGE Shows also:

/usr/sbin/lvmerge [-A autobackup] [-s] copy_lv_path master_lv_path

Merge /dev/vg00/lvol1b with /dev/vg00/lvol1. Data in /dev/vg00/lvol1b will be overwritten by /dev/vg00/lvol1 and /dev/vg00/lvol1b will be removed.

lvmerge /dev/vg00/lvol1b /dev/vg00/lvol1





In case the patching fails and we need to recover the system with the old pacth level, follow the following steps:


NOTE: following things need to be done before we start patching:





Recovery from the Split mirror disk that is /dev/dsk/c0t6d0 and is set at ALTERNATE boot path:

  1. PARISC SYSTEMS:Reboot the server and interrupting auto-boot from the BCH main menu choose to boot from the alt disk

BCH Main Menu > boot alt

Interact with IPL(y/n)? y

ISL> hpux –lm <for booting the system in LVM Maint mode.

The server shall boot up in the LVM maintenance Mode and you shall get the # prompt
Only root FS shall be mounted as /dev/root on /
Now give the following command:

#vgexport vg00
#mkdir /dev/vg00
#mknod /dev/vg00/group c 64 0x000000
#vgimport –v /dev/vg00 /dev/dsk/c0t6d0 – NOTE THE ALTERNATE BOOT DISK.
#lvrmboot –r /dev/vg00
#lvlnboot –v
#lvlnboot –r /dev/vg00/lvol11 --- specify new ROOT LV as lvol11: earlier this was lvol3
#lvlnboot –b /dev/vg00/lvol9 --- specify new BOOT LV as lvol9: earlier this was lvol1
#lvlnboot –s /dev/vg00/lvol10 --- specify new SWAP LV as lvol10: earlier this was lvol2
#lvlnboot –d /dev/vg00/lvol10--- specify new DUMP LV as lvol10: earlier this was lvol2

#lvlnboot –vR --- to check if the ROOT,BOOT,SWAP and DUMP settings have taken place


# cp –pr /etc/fstab /etc/fstab.ORIG
#cp –pr /etc/fstab.save /etc/fstab

#mount –a – to check if all the FS are mounted and check if all files are seen in there.

#setboot –p <give_path_of_current_ALT_boot_disk> -s on –a on --- to make this path as the pry boot path.

Reboot the server:

#shutdown –ry 00


  1. ITANUIM SYTEMS : Reboot the server and choose the alternate boot path from the EFI MAIN MENU.

Choose to interrupt the auto boot the system and Interact with IPL(y/n)? choose “y” to go to hpux>

On the “hpux>” prompt give the following command to boot in LVM Maintenance Mode:

HPUX> boot vmunix –lq OR
HPUX> hpux –lq


The server shall boot in LVM Maint mode and shall come to # prompt.

#vgexport vg00
#mkdir /dev/vg00
#mknod /dev/vg00/group c 64 0x000000
#vgimport –v /dev/vg00 /dev/dsk/c0t6d02– NOTE THE ALTERNATE BOOT DISK and SLICE 2.
#lvrmboot –r /dev/vg00
#lvlnboot –v
#lvlnboot –r /dev/vg00/lvol11 --- specify new ROOT LV as lvol11: earlier this was lvol3
#lvlnboot –b /dev/vg00/lvol9 --- specify new BOOT LV as lvol9: earlier this was lvol1
#lvlnboot –s /dev/vg00/lvol10 --- specify new SWAP LV as lvol10: earlier this was lvol2
#lvlnboot –d /dev/vg00/lvol10--- specify new DUMP LV as lvol10: earlier this was lvol2

#lvlnboot –vR --- to check if the ROOT,BOOT,SWAP and DUMP settings have taken place


# cp –pr /etc/fstab /etc/fstab.ORIG
#cp –pr /etc/fstab.save /etc/fstab

#mount –a – to check if all the FS are mounted and check if all files are seen in there.

#setboot –p <give_path_of_current_ALT_boot_disk> -s on –a on --- to make this path as the pry boot path.

Reboot the server:

#

HP-UX LVM CheatSheet

HP-UX LVM Cheat Sheet


Add the disk to be used in the LVM #pvcreate /dev/rdsk/cXtYdD
Add the disk to be used as a boot disk #pvcreate -B /dev/rdsk/cXtYdD
Force addition of a Disk to be used in LVM on the current System even if it is having LVM headers #pvcreate -f /dev/rdsk/cXtYdZ


Creation of a Volume Group
Create the VG Directory#mkdir /dev/MYVG

#cd /dev/MYVG


With a unique minor number create the VG Group Device Special file#mknod -c 64 0x0000YY group
Create the VG with one or more disks#vgcreate /dev/MYVG /dev/dsk/cXtYdZ


Add more disks to the VG#vgextend /dev/MYVG /dev/dsk/cXtyDZ


Create a Logical Volume #lvcreate -n <LV_Name> -L <Size_in_MB> /dev/MYVG
Create an LV of Zero Size (do not Specify the -L parameter)#lvcreate -n <LV_Name> /dev/MYVG
Create An LV specifying Number of Les#lvcreate -l <LV_size_in_LEs> - n <LV_Name> /dev/MYVG
Create an LV with the default names (such as lvol1, lvol2 etc) : Do not specify the -n parameter#lvcreate -L <Size_in_MB> /dev/MYVG
Create an LV with 1 mirror#lvcreate -L <Size_in_MB> -m 1 /dev/MYVG
Create an LV with BB Relocation off#lvcreate -L <Size_in_MB> -r n /dev/MYVG
Create an LV with the Strict Mirror Policy #lvcreate -n <LV_Name> -s y /dev/NYVG
Extend an LV to have to have PE on specific PV: You can create a Zero Size LV First#lvcreate -n <LV_name> /dev/MYVG

#lvextend -L 100 /dev/dsk/c0t0d0
Create an LV to be used as alternate SWAP or DUMP (These need that the LV has Bad Block Relocation Turned off, is Contiguous, good also to have strict mirror policy)#lvcreate -L 100 -cy -sy -rn -n <LV_Name> <VG_Name>
Default VG configuration Directory/etc/lvmconf
Default VG configuration backup file/etc/lvmconf/<VG_Name>.conf
LVM TAB file (Note /etc/lvmtab_p for VG versions 2 and above 11iv3 only)/etc/lvmtab
Reduce the Size of the LV (Reduces size to that Specified with -L, this is dangerous, before lvreduce to have lesser risks run fsadm -d -D -e -E; followed by reducing the FS size using fsadm -b <NEW_reduced_size_in_KB> /<MOUNT_POINT>#lvextend -L 100 /dev/dsk/c0t0d2
Mirror an Existing LV#lvextend -m 1 /dev/MYVG/lvol1
Mirror an LV but do not allow synchronization of the PE for the LV#lvextend or lvcreate using -s option
Mirror an Existing LV to a particular disk which is in the same VG#lvextend -m 1 /dev/MYVG/lvol1 /dev/dsk/cXtYDX
Create an Stripped LV with specific Stripe Size#lvcreate -L <Size_of_LV> -I <stripe_size> -i <number_of_stripes> -n <LV_Name> /dev/MYVG
Mirror a stripped LV (You will need 16TB+stripped mirror LV Patch on 11.23)#lvextend -m 1 /dev/MYVG/lvol1
Create a Stripped Mirrored LV (You will need 16 TB+stripped Mirror LV Patch on 11.23)#lvcreate -m 1 -L <Size_of_LV> -I <stripe_size> -i <number_of_stripes> -n <LV_Name> /dev/MYVG
Create a Distributed Extent Based Mirrored LV (You will need to have /etc/lvmpvg and the PVG groups defined first)#lvcreate -L <Size_of_LV> -n <LV_Name> -D y -s g /dev/MYVG
Change the LV Mirror Policy from Strict to Non-strict and vice versa y = Make Strict, n : for non-strict mirror policy#lvchnage -s y|n /dev/MYVG/lvol1
Split a Mirroed LV ( If no Suffix is given this creates the Split of the LV as lvol1b if the actual LV name is lvol1)#lvsplit -s <Suffix> /dev/MYVG/lVOL1


Merge the Split LV (Careful, the syntax specifies the Current LV lvol1 which has the most current information is the source is specified as the second argument and the destination lvol1b which may have older information)#lvmerge /dev/MYVG/lvol1b /dev/MYVG/lvol1
LV Split and Merge for a mirrored LV to take LV backupsSuppose /myfs is mounting the mirrored LV /dev/MYVG/lvol1

Split the LV: # lvsplit /dev/MYVG/lvol1

This creates the Split /dev/MYVG/lvol1b

FSCK on /dev/MYVG/lvol1b : # fsck -F <FS_Type> /dev/MYVG/lvol1b

Mount the FSCK-ed LV: #mount /dev/MYVG/lvol1b /new_myfs

Take backup of /new_myfs using tar/fbackup/cpio/dd/cp or any other Enterprise backup tools.

After Backup unmount and lvmerge:

#umount /new_myfs
#lvmerge /dev/MYVG/lvol1b /dev/MYVG/lvol1
UN mirror the LV#lvreduce -m 0 /dev/MYVG/lvol1
Unmirror the LV from a specific PV#lvreduce -m 0 /dev/MYVG/lvol1 /dev/dsk/cXtYdZ
Displaying the detailed information and LE/PE/PV mapping for the extents of an LV#lvdisplay -v /dev/MYVG/lvol1
Seeing if an LV has mirrors are Synced or are stale#lvdisplay -v /dev/MYVG/lvol1 | grep -i stale
Sync all the stale extents of an LV (This is very much needed when the failed disk has been replaced using vgcfgrestore and the LV have mirrors on it)#lvsync /dev/MYVG/lvol1
Rename an LVUnmount the LV if mounted as a File System
Rename the Device Special file for the LV
#mv /dev/MYVG/lvol1 /dev/MYVG/NEWLV
mount The LV with the new Name.

You may need to make changes to the /etc/fstab or the package configuration file with the new LV name so as to automatically mount the LV as per context.
Rename a VGUnmount all the File systems /LV of the VG

Deactivate the VG : #vgchange -a n /dev/MYVG

Preview Export the VG to create the VG Map file with the VGID: #vgexport -p -v -s -m /tmp/MYVG.mapfile /dev/MYVG

Export the VG : #vgexport /dev/MYVG

Create the NEW VG directory: #mkdir /dev/MYNEWVG

Create the NEW VG Group file: #mknod /dev/MYNEWVG/group c 64 0x0000ZZ

Preview Import the VG with the new name and the MAP File: #vgimport -p -v -s -m /tmp/MYVG.mapfile /dev/MYNEWVG


Actual Import the VG with the new name and the MAP File: #vgimport -v -s -m /tmp/MYVG.mapfile /dev/MYNEWVG

Activate the New VG after import: #vgchange -a y /dev/MYNEWVG (good to take an LVM configuration Backup for the VG after import: #vgcfgbackup /dev/MYNEWVG)

You may need to edit the /etc/fstab file or the Package files where the LV names are specified to reflect the correct LV Names

Mount as needed Manually or by the Service Guard Packages




Create a VG with MAX PV, MAX PE PER PV and EXTENT SIZE parameters#vgcreate -e 65535 -p 64 -s 64 /dev/MYVG /dev/dsk/cXtYdZ#
Activate a VG#vgchange -a y /dev/MYVG
Deactivate a VG (Ensure that the FS /LV are unmounted)#vgchange -a n /dev/MYVG
Synchronize all the stale PE in a VG#vgsync <VG_Name>
Mark a VG cluster aware#vgchange -c y /dev/MYVG
Activate a VG but do not auto synchronize the stales #vgchange -a s
Remove a PV from a VG (Ensure that the PV has no occupied PE/LE on it, you can use commands such as pvmove to evacuate all PE on a PV; or lvremvoe to remove an LV)#vgreduce /dev/MYVG /dev/dsk/cXtYdZ
Delete a VG (This requires that the VG does not have more than 1 PV in it)#vgremove /dev/MYVG
Export a VG (to remove the VG information from the system) : this removes the VG information from /etc/lvmtab /etc/lvmtab_p and the corresponding VG directory e.g., /dev/MYVG#vgexport /dev/MYVG
Create a Cluster aware VG (This requires CLVM)#vgcreate -c y /dev/MYVG /dev/dsk/cXtYdZ
Creating MAP File for a VG (For Importing the VG on the same or the other server): This will create the MAP file of the VG which will contain the VGID (because of -s option) with the LV namesPreview Export the VG to create the VG Map file with the VGID: vgexport -p -v -s -m /tmp/MYVG.mapfile /dev/MYVG




Taking VG Configuration Backup (Please note that for each LVM configuration Changes HP-UX LVM automatically takes a backup of the LVM configuration by automatically calling vgcfgbackup #vgcfgbackup /dev/MYVG
Seeing the Current PV Members in the VG Configuration backup#vgcfgrestore -l -n <VG_Name>
Replacing a Failed Disks: restoring the VG configuration backup on to the new disk (here cXtYdZ) is the path where the disk has been replaced#vgcfgrestore -n <VG_Name> /dev/rdsk/cXtYdZ


Prevent Running of the LVMM Autoconfiguration backup while making the LVM Changesuse -A n with the VG commands


Seeing the Free PE and PE Size in a VG#vgdisplay -v <VG_Name>


Move all the PE of a PV to another PV#pvmove <PV1> <PV2>
Move all the PE of an ZLV to another PV#pvmove -n <LV_Name> <Source_PV> <to_other+_PV1> <to_+other_PV2>
Move the First PE to make room for bigger VGRA#pvmove /dev/dsk/cXtYdZ:0
Move a Range 0f PE (11iv3 only)#pvmove /dev/dsk/cXtYdZ:0-115 <Optional_Target_PV>
Recreate the /etc/lvmtab file#vgscan -av




Deactivate a PV#pvchange -a n /dev/dsk/cXYdZ
Deactivate all paths for a PV#pvchange -a N /dev/dsk/cXtYdZ


See all the configurable limits for LVM in 11iv3#lvmadm -T


Change the VG parameters (please note that the the PE Size parameter cannot be changed for a VG without destorying it)#vgmodify -t -r -e <new_value> -p <new_value> /dev/MYVG : -t is to run vgmodify in test mode and -r for PE renumbering if needed

Actual Run which requires the VG to be deactivated : vgmodify -r -e <new_value> -p <new_value> /dev/MYVG
Create /etc/lvmtab with only PDSF of PV (11iv3 only)#vgscan -N or vgimport -N
Scan only the kernel structures of a LVM also only specific VG (11iv3 only) and update the information only for that VG in the LVMTAB file#vgscan -k -f /dev/vg00


Online Dynamic LUN expansion (11iv3 only) Use -r option for PE Renumbering also : see more in man page of#vgmodify -a -E <VG_name>


Change the version of VG (11iv3 only) See more for MAN page of the vgversion command#vgversion
Seeing the PV Key of for the PV (Useful in case of PV which are not responding)#lvdisplay -v -k /dev/MYVG/lvol1
Removing the PE from a unresponsive PV whose PV Key is 2 (for example)#lvreduce -m 0 /dev/MYVG/lvol1 -k 2
Activate a VG in read-only mode (helpful in the Service Guard Environment for Troubleshooting) : This activates the VG and the LV Inside that to be activated in Read-only mode for read-only operations)#vgchange -a r /dev/MYVG