Showing posts with label vgcfgbackup. Show all posts
Showing posts with label vgcfgbackup. Show all posts

Monday, December 7, 2015

How to migrate the LVM Configuration and VGs from 11iv2 to 11iv3 (HP-UX)

LVM config migration to 11i v3

While migrating VGs from 11iv2 to 11iv3, make sure that you have the latest LVM patches also and have a look at (only) few limitations of 11iv2 Vgs being migrated to 11iv3.





Refer to compatibilty notes on page 14 of 
http://h20000.www2.hp.com/bc/docs/support/SupportManual/c01919369/c01919369.pdf (BSC link updated by admin)

Please note that the above link may have changed refer to the latest if so.

Also it is to be understood that the New generation Mass storage stack on 11iv3 has inbuilt Dynamic multipathing in it. While the legacy device files are well supported on 11iv3, you can choose to have the persistent DSFs that is agile view reflecting in your VGs.
-
Create MAP files of the VGs on 11iv2 using the command as below.

on 11iv2: (please note -p is for preview mode which just creates the map file and does not export the VG physically as such)

vgexport -p -v -s -m <map_file_name> <vg_name>

Keep these map files handy.

Post that import the VGs using the map file on 11iv3 OS



mkdir /dev/vg01



mknod /dev/vg01/group c 64 0x0Y0000


make sure that 0x0y0000 is unique on the system.



vgimport -p -v -s -m <map_file_name> <vg_name>

When the preview is satisfactory and there are no errors. 

Import without the -p option as below

vgimport -v -s -m <map_file_name> 


So once you have imported those VGs from the 11iv2 system to the 11iv3 system, once again re-export and import that VG in the following way. (This is not mandatory though and is needed only if you want to have support of persistent DSF on the VGs)



After you have imported the vgs to the 11iv3 system, say vg01 then re-export

It is worth noting that in general before actual export of a VG the VG has to be deactivated (using vgchange -a n which can be done only if the LVs in the VG are not open that is unmounted).




vgexport -p -v -s -N -m /tmp/vg01.map /dev/vg01

vgexport /dev/vg01


mkdir /dev/vg01

mknod /dev/vg01/group c 64 0x0Y0000


make sure that 0x0y0000 is unique on the system.


vgimport -v -s -N -m /tmp/vg01.map /dev/vg01

Activate the VGs using vgchange -a y <VG_NAME>


Mount the File systems.


For more see man pages of the command vgimport and vgexport also the 11iv3 Next Generation Mass Storage Stack

More on the vgexport/vgimport command on HP-UX


Please note: -f and -s options are mutually exclusive for the commands vgimport and vgexport.



vgexport -p -v -s -N -m /tmp/vg01.map /dev/vg01


this shall create the map file with the VGID of the VG in this.

after this



vgimport -v -s -N -m /tmp/vg01.map /dev/vg01


this shall scan all the disks on the system to match the VGID as in the specified map file and shall import those disks in the specified VG.




-f option of vgexport creates a file that keeps the device files in an file file.out


when this file.out is used with a vgimport command this shall scan the disks and those matching the device files in file.out shall be imported in the VG.



note that the Device Files as in 11iv2 can be different to that while the OS is 11iv3, in that case -f option can be erroneous if that can not match the device files in the target OS.


so it is better to use the -s option.




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