Let me know if you have any questions or additions/corrections.
AIX RPM Dependency Script at GitHub
]]>
https://github.com/jmsearcy/scripts/tree/master/AIX
I will eventually move these to a dedicated DDPWR GitHUb account, but they will be under my personal account for now. If you have any personal scripts you’re fond of, feel free to shoot them this way and I can add them to the collection (or add you to the repo on GitHub).
Enjoy!
]]>In a few environments, you may even be faced with picking up the pieces where other, less skilled folk, may have been in charge. This can often leave you scratching your head asking, “What in the heck were they thinking…” One common scenario I’ve encountered is when someone built the system and included application/database volumes within “rootvg”. Although not a complete wreck, I highly recommend not doing this, for more reasons than it’s worth to explain. This leads me to the topic if this post, how to migrate a logical volume from one volume group to another. Let’s dive in:
NOTE: This example shows how to migrate the “optopenv” LV from “rootvg’ to “nbuvg” and renames the LV to “nbu_optopenv_lv”
Create new VG (or use an existing VG)
$ mkvg -S -y [vgname] -s [pp size in MB] [pv1] [pv2] ...
EXAMPLE:
$ mkvg -S -y nbuvg -s 512 hdisk3
Copy the LV to the new VG
NOTE: The LV being copied needs to be inactive for this, please make sure the associated FS is unmounted
$ cplv -v [new vg] [lv name]
EXAMPLE:
$ cplv -v nbuvg optopenv
NOTE: The new LV will have a generic name similar to “lv00”
Setup LV log
– For inline log FS’s
$ logform /dev/[lvname]
EXAMPLE:
$ logform /dev/lv00
– For external log
$ mklv -t jfs2log [vg name] 1
EXAMPLE:
$ mklv -t jfs2log nbuvg 1
NOTE: this will create a new log LV similar to “loglv00”
$ logform /dev/loglv00
Change the FS to reference the new log
– For inline log FS’s
$ chfs -a /dev/[lv name] -a log=INLINE /filesystem
EXAMPLE:
$ chfs -a /dev/lv00 -a log=INLINE /opt/openv
– For external log FS’s
$ chfs -a /dev/[lv name] -a log=/dev/[log lv name] /filesystem
EXAMPLE:
$ chfs -a /dev/lv00 -a log=/dev/loglv00 /opt/openv
Perform a FS integrity check
$ fsck -p /dev/[lv name]
EXAMPLE:
$ fsck -p /dev/lv00
NOTE: It is common to receive errors after running fsck -p /dev/lvname prior to mounting the filesystem.
These errors are due to a known bug that development is currently aware of and which will be resolved in a future release of AIX.
Once the filesystem is mounted, a future fsck with the filesystem unmounted should no longer produce an error.
Mount the FS
$ mount /[fs name]
EXAMPLE:
$ mount /opt/openv
Remove old LV
$ rmlv [old lv name]
EXAMPLE:
$ rmlv optopenv
Rename new LV
$ chlv -n [new name] [old name]
EXAMPLE:
$ chlv -n nbu_optopenv_lv lv00
]]>
We’ll tweet a link for all new articles posted to give you even more ways to access our content.
]]>
View the current priority for an individual path:
$ lspath -l -p -E
Example with output:
$ lspath -l hdisk0 -p vscsi0 -E
priority 1 Priority True
To set priority for an individual path:
$ chpath -l -p -a priority=
Example:
$ chpath -l hdisk0 -p vscsi1 -a priority=2
Simple right?! There’s really not much to it at all. The hard part is establishing your standard for how you balance traffic across your entire environment. Do you balance all odd number LPARS to VIOS1 and all even to VIOS2, do you split each managed system in half? That answer I can’t give you as it will depend on your specific scenario, as well as your needs. In ending this first part, here’s a short script you can use to set priority for all disks in an LPAR.
for i in `lspv | awk '{ print $1 }'`
do
chpath -l $i -p vscsi1 -a priority=2
echo "$i's path for vscsi1 is now set to Priority 2"
done
[UPDATE]
Here’s a little more advanced script for setting the path priority based on an even/odd hdisk numbering scheme (ie. hdisk2, hdisk3, etc.)
#!/usr/bin/ksh
#
# PowerVM vSCSI Path Balancing Script
# by: Joe M. Searcy
# email: jmsearcy@thewebroot.com
#
#
# This script is used to direct vSCSI path priority to "$VSCSI0" for all even numbered disks, and to
# "$VSCSI1" for all odd number disks. This is to help balance the CPU/Memory load attributed to vSCSI
# traffic across 2 VIO Servers.
#
# v1.0 -> 08-16-2012
# Initial script
#
#
# Variables ######
EVENS="0"
ODDS="1"
TOTDISKS=`lspv | awk '{ print $1 }' | wc -l | sed 's/^ *//'`
TOTDISKS2="$TOTDISKS"
VSCSI0="vscsi0"
VSCSI1="vscsi1"
# Print total number of disks
echo
echo "Total disks in this system: $TOTDISKS"
echo
# Determine even or odd number of disks
let x="$TOTDISKS % 2"
if [ $x -gt 0 ]
then
ISODD=true
else
ISODD=false
fi
# Uncomment for DEBUG
#echo "This is an odd number of disks: $ISODD"
#echo
# Main Routine
if [ $ISODD == true ]
then
let LASTEVEN="$TOTDISKS - 1"
let LASTODD="$TOTDISKS"
echo "#### EVEN DISKS ############"
echo
while [ $EVENS -le $LASTEVEN ]
do
chpath -l hdisk$EVENS -p $VSCSI0 -a priority=1
chpath -l hdisk$EVENS -p $VSCSI1 -a priority=2
echo "hdisk$EVENS's path for $VSCSI0 is now set to Priority 1"
((EVENS+=2))
if [ $EVENS -gt $LASTEVEN ]
then
echo "No more even numbered disks."
echo
echo
else
echo "The next even numbered disk is \"hdisk$EVENS\""
echo
fi
done
echo "#### ODD DISKS ############"
echo
while [ $ODDS -le $LASTODD ]
do
chpath -l hdisk$ODDS -p $VSCSI0 -a priority=2
chpath -l hdisk$ODDS -p $VSCSI1 -a priority=1
echo "hdisk$ODDS's path for $VSCSI1 is now set to Priority 2"
((ODDS+=2))
if [ $ODDS -gt $LASTODD ]
then
echo "No more odd numbered disks."
echo
echo
else
echo "The next odd numbered disk is \"hdisk$ODDS\""
echo
fi
done
else
let LASTEVEN="$TOTDISKS"
let LASTODD="$TOTDISKS - 1"
echo "#### EVEN DISKS ############"
echo
while [ $EVENS -le $LASTEVEN ]
do
chpath -l hdisk$EVENS -p $VSCSI0 -a priority=1
chpath -l hdisk$EVENS -p $VSCSI1 -a priority=2
echo "hdisk$EVENS's path for $VSCSI0 is now set to Priority 1"
((EVENS+=2))
if [ $EVENS -gt $LASTEVEN ]
then
echo "No more even numbered disks."
echo
echo
else
echo "The next even numbered disk is \"hdisk$EVENS\""
echo
fi
done
echo "#### ODD DISKS ############"
echo
while [ $ODDS -le $LASTODD ]
do
chpath -l hdisk$ODDS -p $VSCSI0 -a priority=2
chpath -l hdisk$ODDS -p $VSCSI1 -a priority=1
echo "hdisk$ODDS's path for $VSCSI1 is now set to Priority 2"
((ODDS+=2))
if [ $ODDS -gt $LASTODD ]
then
echo "No more odd numbered disks."
echo
echo
else
echo "The next odd numbered disk is \"hdisk$ODDS\""
echo
fi
done
fi
exit
[/UPDATE]
[UPDATE2]
Here’s yet another update. After helping a customer increase performance for an LPAR using vSCSI storage I developed this script to balance path priority in a situation where you may have multiple vSCSI server adapters. For example:
The customer has 200 LUN’s mapped in a round robin format across 8 different vSCSI server adapters (4 per VIOS using MPIO in the client).
#!/usr/bin/ksh93
# set -x
#
# PowerVM Multi-vSCSI Path Balancing Script
# by: Joe M. Searcy
# email: jmsearcy@us.ibm.com
#
#
# This script is used to dynamically balance hdisk path priority across multiple vSCSI adapters
# for all disks within a system.
#
# This was developed for customers who have vSCSI disks federated across multiple vSCSI adapters
# for improved performance.
#
# v1.0 ->
# 01-18-2013 - Joe Searcy -> Initial script
# 01-18-2013 - Joe Searcy -> Added filter for non-vSCSI disks
# 01-18-2013 - Joe Searcy -> Added logic for single path vSCSI disks
# 01-25-2013 - Joe Searcy -> Fixed vSCSI count array arithmetic
# 01-27-2013 - Joe Searcy -> Added some additional comments and configured to
# perform changes instead of only echoing to stdout
# 03-07-2014 - Joe Searcy -> Added debug mode and fixed variable values (stuff never removed from testing)
#
#### Variables ####
DEBUG=echo
LSPATH_OUT=`lspath`
DISKLIST=`echo ${LSPATH_OUT} | awk '{print $2}' | sort -u | grep "vscsi"`
VSCSILIST=`echo ${LSPATH_OUT} | awk '{print $3}' | sort -u | grep "vscsi" | sed 's/vscsi//'`
#### Create Arrays ####
typeset -a vscsiCountArray
typeset -A path1Array
typeset -A path2Array
#### Build vscsiCountArray ####
for vscsi in $VSCSILIST
do
vscsiCountArray[$vscsi]=0
done
#### Build path1Array ####
for hdisk in $DISKLIST
do
PATH1=`echo ${LSPATH_OUT} | grep "${hdisk} " | head -1 | awk '{ print $3 }' | sed s/vscsi//`
path1Array[$hdisk]=$PATH1
done
#### Build path2Array ####
for hdisk in $DISKLIST
do
PATH2=`echo ${LSPATH_OUT} | grep "$hdisk " | tail -1 | awk '{ print $3 }' | sed s/vscsi//`
path2Array[$hdisk]=$PATH2
done
#### Main Loop to set path priority per hdisk ####
for hdisk in $DISKLIST
do
PATH1=${path1Array[$hdisk]}
PATH2=${path2Array[$hdisk]}
if [ $PATH1 == $PATH2 ]
then
echo
echo "Disk \"$hdisk\" does not have multiple paths"
echo
echo "#######################################################"
echo
else
# Compare Path 1 count to Path 2 count and set priority
if [ ${vscsiCountArray[$PATH1]} == ${vscsiCountArray[$PATH2]} ]
then
echo "$hdisk uses \"vscsi${path1Array[$hdisk]}\" & \"vscsi${path2Array[$hdisk]}\""
#### Begin DEBUG ####
#echo "Path 1 count: ${vscsiCountArray[$PATH1]}"
#echo "Path 2 count: ${vscsiCountArray[$PATH2]}"
#echo
#### End DEBUG ####
echo
# Actually change path priority (comment out for DEBUG)
${DEBUG} chpath -l $hdisk -p vscsi$PATH1 -a priority=1
${DEBUG} chpath -l $hdisk -p vscsi$PATH2 -a priority=2
((vscsiCountArray[$PATH1]+=1))
#### Begin DEBUG ####
#echo "Path 1 count: ${vscsiCountArray[$PATH1]}"
#echo "Path 2 count: ${vscsiCountArray[$PATH2]}"
#### End DEBUG ####
echo
echo "#######################################################"
echo
else
echo "$hdisk uses \"vscsi${path1Array[$hdisk]}\" & \"vscsi${path2Array[$hdisk]}\""
#### Begin DEBUG ####
#echo "Path 1 count: ${vscsiCountArray[$PATH1]}"
#echo "Path 2 count: ${vscsiCountArray[$PATH2]}"
#### End DEBUG ####
echo
# Actually change path priority (comment out for DEBUG)
${DEBUG} chpath -l $hdisk -p vscsi$PATH1 -a priority=2
${DEBUG} chpath -l $hdisk -p vscsi$PATH2 -a priority=1
((vscsiCountArray[$PATH2]+=1))
#### Begin DEBUG ####
#echo "Path 1 count: ${vscsiCountArray[$PATH1]}"
#echo "Path 2 count: ${vscsiCountArray[$PATH2]}"
#### End DEBUG ####
echo
echo "#######################################################"
echo
fi
fi
done
]]>