Simple script to move AIX LVs from one VG to another

OS -- AIX 5.3

This is a very simple script that can be used to transfer set of AIX logical volumes (LV) from one volume group (VG) to another.

This was used to move all oracle db LVs from one VG to another.

1. List all LVs to be moved in a txt file in the format of "lsvg -l" output.
 [root@BLOGHOST:/vg_move]$lsvg -l datavg | grep -i ora > oracle_lv.txt  
 [root@BLOGHOST:/vg_move]$ cat oracle_lv.txt   
 oracle_home2_lv   jfs2    40   40   1  open/syncd  /oracle  
 oracle_home3_lv   jfs2    32   32   1  open/syncd  /cust  
 fslv02       jfs2    120   120   3  open/syncd  /orahome11g  
 fslv05       jfs2    80   80   1  open/syncd  /orahome  
 nms_temp      jfs2    8    8    1  open/syncd  /ora_temp  
 orahome10gg_2    jfs2    280   280   2  open/syncd  /orahome10_2  
 oradataictpslt_   jfs2    444   444   5  open/syncd  /oradata2  
 oradata1_lv     jfs2    400   400   9  open/syncd  /oradata1  
 oradataicp1_lv   jfs2    400   400   5  open/syncd  /ora  
 fx_orahome     jfs2    32   32   1  open/syncd  /oracle/orahome  
 orr_lv       jfs2    200   200   2  open/syncd  /oracle_home  
This txt file is the input to below script lv_move.sh, which will move the above lvs from datavg (original) to daatvg01 (new).
 [root@BLOGHOST:/vg_move]$ cat lv_move.sh  
 while read line  
 do  
   name=$line  
   lv=`echo $name | awk '{print $1}'`   
   mp=`echo $name | awk '{print $7}'`    
   j=`echo $mp | sed 's/[/]//g'`  
 #echo "Text read from file - $name testsss $lv"  
 umount $mp > um_status_$j.txt  
 if [ -s um_status_$j.txt ]  
 then  
   echo "umount failed for $j" > umount_failed_log.txt     
 else  
   echo "umount ok for $j" > umount_ok_log.txt   
   cplv -v datavg01 $lv  
 nlv=`lsvg -l datavg01 | awk '{print $1}' | grep -i fslv | tail -1`  
 chfs -a dev=/dev/$nlv -a log=/dev/loglv01 $mp   
 fsck -p /dev/$nlv > fsck_report_$j.log  
 fi  
 done < $1  
 [root@BLOGHOST:/vg_move]$ sh lv_move.sh oracle_lv.txt   
Note : This script is an example only, changes will be required for different setup.

Comments

Popular posts from this blog

ORA-16433: The database or pluggable database must be opened in read/write

Oracle Multitenant - Create new service for PDB using DBMS_SERVICE

Wait for unread message on broadcast channel - Blocking Sessions