When you use mirror on AIX with 2 or 3 copies of logical volumes (LV), you can choose which copy is faster for read IOs (local copie is faster)
# cat check_fast_copy.sh
#!/usr/bin/ksh93
#set -x
##################################################
#@(#) Check if disks are reading on right site
# Only for 2 copies in a mirror, not test for 3
##################################################
# version: 1.0 08-2019 Manu
##################################################
dir=`dirname $0`
. $dir/.env
# use: lspv -u to get storage ID
serial_storageA="33213600507111111111111"
serial_storageB="33213600507222222222222"
location=$($path_script/location.sh | awk '{print $1}')
case "$location" in
"First_loc") site="siteA" ;;
"Second_loc") site="siteB" ;;
*) echo "Site Unkown"
exit 1 ;;
esac
# list mirrored VG
for vg in $(lsvg -o)
do
copies=$(lsvg -l $vg | awk '{print $2,$3,$4}' | egrep "jfs|boot|paging" | while read i j k
do
echo "scale=0;$k/$j" | bc
done | sort -u | awk '{print $1}')
if [ "$(echo $copies | tr ' ' '\n' | wc -l | awk '{print $1}')" != "1" ]
then
echo "# Mirror error in $vg"
fi
if [ "$copies" == "2" ]
then
countvg=0
lspv -u | tr -s ' ' | sed 's/\ /;/g' | sed -e 's/;active;/;/' -e 's/;concurrent;/;/' | awk -F';' '{print $1";"$3";"$4}' | sed -e "s/${serial_storageA}/siteA;/" -e "s/${serial_storageB}/siteB;/" | awk -F';' '{print $1";"$2";"$3}' | grep ";$vg;" > $logpath/relocate_map.out
for lv in $(lsvg -l $vg | awk '{print $1,$2}' | egrep "jfs|boot|paging" | awk '{print $1}')
do
countlv=0
# check the read copy on the LV, if 0 then the first copy is used
read_copy=$(lslv $lv | tr -s ' ' | sed 's/\ /;/g' | grep ";PREFERRED;READ:" | rev | awk -F';' '{print $1}' | rev | sed 's/0/1/')
if [ "${read_copy}" == "1" ]
then
pvs=$(lslv -m $lv | awk '{print $3}' | sed '/^$/d' | sed 's/$/;/' | grep -v '^PV1;' | sort -u | awk -F';' '{print $1}')
secondcopy="2"
else
if [ "${read_copy}" == "2" ]
then
pvs=$(lslv -m $lv | awk '{print $5}' | sed '/^$/d' | sed 's/$/;/' | grep -v '^PV2;' | sort -u | awk -F';' '{print $1}')
secondcopy="1"
else
echo "# Error bad preferred copy on $logical volume $lv in the vg $vg NOK"
fi
fi
for pv in $pvs
do
if [ $(grep "^$pv;" $logpath/relocate_map.out | awk -F';' '{print $3}') != "$site" ]
then
((countvg = countvg +1))
((countlv = countlv +1))
fi
done
if [ "$countlv" == "0" ]
then
echo "# $vg : LV $lv is on the right location OK"
else
echo "# $vg : Please relocate the LV $lv on second copy"
echo "chlv -R $secondcopy $lv"
fi
done
if [ "$countvg" == "0" ]
then
echo "##### $vg : compliant with sites OK"
else
echo "##### $vg : not compliant with sites"
fi
fi
done