#!!!UNDER CONSTRUCTION!!! # # This is not a production quality shell code, # Use at your own risk. # Whenever possible, copy-paste to the interactive shell, # instead of running directly. # # Andrei.Ryjov@Credit-Suisse.COM aka aryzhov@spasu.net # # # Purpose: EMC 1:1 frame-to-frame host data migrations # # Method: # In a given Vx diskgroup, # export the vxmake stream at plex layer, recursively down. # Fake the stream, replacing ctlr/trg by a destination ones. # Rename existing Vx objects (from plex layer down to dmdisk) # of the given diskgroup group to X$name. But keep the volume names! # Vxinit and vdxg-add new disks with non-X names, matching the Xnames. # Run vxmake against the fake command stream (this creates new plexes # with old non-X names on destination disks using original layout. # (i.e. all subdisks offset/len are as per source disks and Xnames). # Mirror (vxplex att) to new plexes, sync, detach and remove all # source objects (plexes, subdisks, dm_disks) with Xnames. # # See the inline comments for more details. # # Assumptions: # 1.LUNs and sizes of the destination disks are exactly as on source. # 2.Each volume consists of one plex only. # # # Example: # # OLDCT=c3t2d # NEWCT=c3t0d # G=opics_t_db_dg # # Duplicate # WaitForSync # DetachAndClean # Duplicate() { # Generate the list of all Vx object names, recursively, # starting at plexes layer, down to subdisk layer VxObjNames=`vxprint -g$G -p -h -F%name | sort -u` # List the only Vx dm_disks that are actually USED in diskgrp, # i.e. list only the dm_disks associated with existing subdisks. VxDiskNames=`vxprint -g$G -s -F%disk | sort -u` # Generate a fake VxMake stream VxMakeComms=`vxprint -g$G -p -h -m | sed "s/$OLDCT/$NEWCT/g"` # Rename source Vx objects to X$name for i in $VxObjNames $VxDiskNames ; do vxedit -g$G rename $i X$i || return 1 done # Add destination disks to the group, re-using old (pre-X) names. for DmName in $VxDiskNames ; do D=`vxprint -g$G -d -F%assoc X$DmName | sed "s/$OLDCT/$NEWCT/;s/s2$//"`1 echo "$D \c" vxdisk offline $D 2>/dev/null echo "y\nty\n0\nla\ny\n" | format -s $D 2>&1 | grep -v expected /etc/vx/bin/vxdisksetup -i $D || return 2 vxdg -g $G adddisk $DmName=$D || return 3 done ; echo # Create the plexes on destination disks, using fake VxMakeComms. # Thus, layout is exactly as on source disks echo "$VxMakeComms" | vxmake -g$G -d - || return 4 # Attach new plexes to the volumes associated with corresponding Xplexes for P in `vxprint -g$G -p -F%name | egrep -v '^X'` ; do vxplex -g$G att `vxprint -g$G -p -F%assoc X$P` $P & done } WaitForSync() { while [ `vxtask list | wc -l` -gt 1 ] ; do sleep 60 ; done ; } DetachAndClean() { for P in `vxprint -g$G -p -F%name | grep '^X'` ; do vxplex -g$G -o rm dis $P ; done for D in `vxprint -g$G -d -F%name | grep '^X'` ; do vxdg -g$G rmdisk $D ; done } #--------------------------------------------------------------------------------------- OLDCT=c6t11d NEWCT=c6t12d G=oracle_dg Duplicate