Skip to content

Instantly share code, notes, and snippets.

@DaffyDuke
Created March 5, 2017 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DaffyDuke/3f68a53746548c13120b5bb88af54328 to your computer and use it in GitHub Desktop.
Save DaffyDuke/3f68a53746548c13120b5bb88af54328 to your computer and use it in GitHub Desktop.
Migration de LPAR de datacenter
#!/bin/ksh93
### Initial Check
while getopts ":l:f:" argument
do
case $argument in
l) SRV_TARGET=$OPTARG;;
f) PARAM=$OPTARG;;
:) echo "Option -$OPTARG need argument"; exit;;
\?) echo "Option -$OPTARG invalid"; exit;;
esac
done
echo server=$SRV_TARGET
if (( ${#SRV_TARGET} == 0 ))
then
echo "\nERROR! You must give short hostname as argument"
echo "ERROR!\t\tExample $0 -l <lpar_name>\n"
exit 99
fi
CONFIG_FILE="vegaV2/$SRV_TARGET/lpar_param.txt"
PARAM=${PARAM:-$CONFIG_FILE}
echo "File Parameter=$PARAM"
if [[ ! -f $PARAM ]] || [[ ! -s $PARAM ]]
then
echo "\nERROR! You must give a pameter file as argument"
echo "ERROR!\t\tExample $0 -f <param_file>\n"
exit 99
fi
if (( $(id -u) != 0 ))
then
echo "ERROR! you should connect as root user to exec this script"
exit 99
fi
if ! lsnim -l $SRV_TARGET > /dev/null 2>&1
then
echo "ERROR! ($SRV_TARGET) is not NIM client for $(hostname) "
exit 99
fi
RC=$(ssh -o BatchMode=yes -o ConnectTimeout=10 $SRV_TARGET "date >/dev/null 2>&1 && echo 0 || echo 1")
if (( RC == 1 ))
then
echo "ERROR! ($SRV_TARGET) not available by ssh"
exit 99
fi
################## Main script ##########################
# identify queue_depth rootvg sytem source
QUEUE_DEPTH=$(awk -F";" ' $1 == "rootvg" {print $NF}' $PARAM)
echo "Queue_Depth = $QUEUE_DEPTH"
for i in $(ssh $SRV_TARGET "lsdev -Cc disk | awk ' {print \$1}'")
do
typeset -i qd=$(ssh $SRV_TARGET "lsattr -El $i -a queue_depth| awk '{print \$2}'")
if (( qd != QUEUE_DEPTH ))
then
echo "modify $i ..."
ssh $SRV_TARGET "chdev -l $i -a queue_depth=$QUEUE_DEPTH -a reserve_policy=no_reserve -P"
fi
done
echo "Hdisk List ..."
ssh $SRV_TARGET "lsdev -Cc disk"
exit 0
./ident_hdisk_vg_lun.sh
#!/bin/ksh93
#
# [Oct 21 2015, 15:28:43]
#
### Initial Check
while getopts ":l:" argument
do
case $argument in
l) SRV_TARGET=$OPTARG;;
:) echo "Option -$OPTARG need an argument"; exit;;
\?) echo "Option _$OPTARG invalid";exit;;
esac
done
if (( ${#SRV_TARGET} == 0 ))
then
echo "ERROR! You must give short hostname as argument"
echo "ERROR!\t\tExample $0 -l <lpar_name>"
exit 99
fi
if (( $(id -u) != 0 ))
then
echo "ERROR! you should connect as root user to exec this script"
exit 99
fi
if ! lsnim -l $SRV_TARGET > /dev/null 2>&1
then
echo "ERROR! ($SRV_TARGET) is not NIM client for $(hostname) "
exit 99
fi
RC=$(ssh -o BatchMode=yes -o ConnectTimeout=10 $SRV_TARGET "date >/dev/null 2>&1 && echo 0 || echo 1")
if (( RC == 1 ))
then
echo "ERROR! ($SRV_TARGET) not available by ssh"
exit 99
fi
################## Main script ##########################
CONFIG_DIR="vegaV2/$SRV_TARGET"
if [[ ! -d $CONFIG_DIR ]]
then
mkdir -p $CONFIG_DIR
fi
CONFIG_FILE="$CONFIG_DIR/lpar_param.txt"
printf "%-4s %-5s %-4s %-12s %s\n" "# VG" HDISK LUN PVID QDEPTH > $CONFIG_FILE
for HD in $(ssh $SRV_TARGET "lspv | awk ' { print \$1 }'")
do
VG=$(ssh $SRV_TARGET "lspv | awk ' \$1 == hd { print \$3 }' hd=$HD")
LDEV=$(ssh $SRV_TARGET "lscfg -vl $HD | awk -F. ' \$2 == \"(Z1)\" { print substr(\$10,1,4)}'")
QDEPTH=$(ssh $SRV_TARGET "lsattr -El $HD -a queue_depth | awk ' { print \$2}'")
PVID=$(ssh $SRV_TARGET "lspv | awk ' \$1 == hd { print \$2 }' hd=$HD")
#printf "%-8s=> %-8s: %s\n" $VG $HD $LDEV
echo "$VG;$HD;$LDEV;$PVID;$QDEPTH" >> $CONFIG_FILE
done
ssh $SRV_TARGET "prtconf;lspv -u;lsdev -Cc disk;lspv | awk '{print(\"####### \" \$1);system(\"lsattr -El \" \$1)}';lsvg |lsvg -i -l;ifconfig -a;netstat -nr;netstat -i;bootlist -om normal" > $CONFIG_DIR/lpar_definition.txt
echo "Config file available in <$CONFIG_DIR>"
exit 0
./importvg_g1k.sh
#!/bin/ksh93
### Initial Check
while getopts ":l:f:" argument
do
case $argument in
l) SRV_TARGET=$OPTARG;;
f) PARAM=$OPTARG;;
:) echo "Option -$OPTARG need an argument"; exit;;
\?) echo "Option _$OPTARG invalid";exit;;
esac
done
if (( ${#SRV_TARGET} == 0 ))
then
echo "ERROR! You must give short hostname as argument"
echo "ERROR!\t\tExample $0 -l <lpar_name>"
exit 99
fi
CONFIG_FILE="vegaV2/$SRV_TARGET/lpar_param.txt"
PARAM=${PARAM:-$CONFIG_FILE}
echo "File Parameter=$PARAM"
if [[ ! -f $PARAM ]] || [[ ! -s $PARAM ]]
then
echo "\nERROR! You must give a pameter file as argument"
echo "ERROR!\t\tExample $0 -f <param_file>\n"
exit 99
fi
if (( $(id -u) != 0 ))
then
echo "ERROR! you should connect as root user to exec this script"
exit 99
fi
if ! lsnim -l $SRV_TARGET > /dev/null 2>&1
then
echo "ERROR! ($SRV_TARGET) is not NIM client for $(hostname) "
exit 99
fi
RC=$(ssh -o BatchMode=yes -o ConnectTimeout=10 $SRV_TARGET "date >/dev/null 2>&1 && echo 0 || echo 1")
if (( RC == 1 ))
then
echo "ERROR! ($SRV_TARGET) not available by ssh"
exit 99
fi
################## Main script ##########################
echo "importVG Hitachi..."
# identify queue_depth rootvg
cat $PARAM | grep -Ev -e "^#|^rootvg" | while IFS=";" read VG HD LDEV PVID QDEPTH
do
echo "Import VG : $VG"
ssh $SRV_TARGET "lspv | awk ' \$2 == \"$PVID\" {system(\"echo importvg -y $VG \" \$1 \" ; importvg -y $VG \" \$1)}'"
done
echo "Hdisk List ..."
ssh $SRV_TARGET "lspv"
exit 0
./install_hds_odm5410.sh
#!/bin/ksh93
#
# [Oct 21 2015, 15:28:43]
#
### Initial Check
while getopts ":l:q:" argument
do
case $argument in
l) SRV_TARGET=$OPTARG;;
:) echo "Option -$OPTARG need and argument";exit;;
\?) echo "Option -$OPTARG invalid";exit;;
esac
done
if (( ${#SRV_TARGET} == 0 ))
then
echo "\nERROR! You must give short hostname as argument"
echo "ERROR!\t\tExample $0 -l <lpar_name>\n"
exit 99
fi
if (( $(id -u) != 0 ))
then
echo "ERROR! you should connect as root user to exec this script"
exit 99
fi
if ! lsnim -l $SRV_TARGET > /dev/null 2>&1
then
echo "ERROR! ($SRV_TARGET) is not NIM client for $(hostname) "
exit 99
fi
RC=$(ssh -o BatchMode=yes -o ConnectTimeout=10 $SRV_TARGET "date >/dev/null 2>&1 && echo 0 || echo 1")
if (( RC == 1 ))
then
echo "ERROR! ($SRV_TARGET) not available by ssh"
exit 99
fi
################## Main script ##########################
echo "Begin ODM Hitachi Install V5.4.1.0"
/usr/lpp/bos.sysmgt/nim/methods/m_sm_nim update_all -t $SRV_TARGET -l 'lpp_hds_odm5410' -f 'c' -f 'N' -f 'g' -f 'X' -f 'Y'
RC=$?
if (( RC == 0 ))
then
echo "End ODM Hitachi Install V5.4.1.0"
else
echo "ERROR! Install terminated with error, please check level"
fi
# Change default parameter on HDS Driver
echo "Update Default Parameter : reserve_policy=no_reserve queue_depth=16"
ssh -o BatchMode=yes -o ConnectTimeout=10 $SRV_TARGET "chdef -a reserve_policy=no_reserve -c disk -s fcp -t htcvspg1000mpio"
ssh -o BatchMode=yes -o ConnectTimeout=10 $SRV_TARGET "chdef -a queue_depth=16 -c disk -s fcp -t htcvspg1000mpio"
# Change and display bootlist
ssh -o BatchMode=yes -o ConnectTimeout=10 $SRV_TARGET "bootlist -m normal \$(lsvg -p rootvg | awk ' NR == 3 { print \$1}');bootlist -om normal"
# display HDS driver level
ssh -o BatchMode=yes -o ConnectTimeout=10 $SRV_TARGET "/usr/bin/lslpp -l devices.fcp.disk.Hitachi.array.mpio.rte"
echo "\nWARNING!\nWARNING \t you should reboot this LPAR now to apply last level\n"
exit 0

Avant la migration

NIM source> ssh <lpar_name> "chdev -l sys0 -a ghostdev=1

NIM target> cd /home/admin
NIM target> ./ident_hdisk_vg_lun.sh -l <lpar_name>

Migration

Arrêt de la lpar source

HMC source> chsysstate -m <managed_system> -r lpar -o shutdown -n <lpar_name> --immed

HDS : suspend de réplication et RW sur la cible

Reboot sur système cible en mode SMS pour affecter le boot volume

HMC target>  chsysstate -m <manage_system> -r lpar -o on -n <lpar_name> -f <lpar_name>_normal -b sms
HMC target>  vtmenu  ==> selection du disque de boot SAN, scan , ...

reconfiguration

Config TCPIP => smit tcpip, fixer en1 via les paramètres collectés plus haut, puis en0 avec le nom pour NIM

Config NIM => rm /etc/niminfo ; smit nim

Install du driver HDS

NIM target> ./install_hds_odm5410.sh -l <lpar_name>     # mise en oeuvre HDS Driver 5.4.1.0
HMC target> chsysstate -m <managed_system> -r lpar -o osshutdown -n <lpar_name> --immed --restart

Attente du reboot de la lpar !!

Replication de la Configuration Queue_depth

NIM target> ./configure_new_hd.sh -l <lpar_name>

Import des VGs

NIM target> ./importvg_g1k.sh -l <lpar_name>

Post Operation

reboot final

HMC target> chsysstate -m <managed_system> -r lpar -o osshutdown -n <lpar_name> --immed --restart

Attente du reboot de la lpar !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment