The example shell script generates two scripts, list_griddisk.sh
and drop_griddisk.sh
, that are run later in this procedure. Do not run the generated scripts until instructed.
#!/bin/bash
# Run this script as the Grid Infrastructure software owner.
#
# This script identifies griddisks used by this cluster and the cells to
# which they belong, then creates two shell scripts - the list script to
# show the current status, and the drop script to drop the griddisks.
#
# In order for the drop script to succeed, the griddisks must not be in use,
# meaning databases and CRS are down, and the list script returns no output.
#
# The generated scripts are designed to run via dcli -x
ORACLE_SID=$(awk -F: '/^+ASM/{print $1}' /etc/oratab)
ORAENV_ASK=NO . oraenv >/dev/null
listGriddiskScript=list_griddisk.sh
dropGriddiskScript=drop_griddisk.sh
rm -f $listGriddiskScript $dropGriddiskScript
gridDiskList=$(asmcmd lsdsk --suppressheader | awk -F'/' '{print $NF}')
if [[ ${PIPESTATUS[0]} != 0 ]]; then echo "asmcmd failed - exiting"; exit 1; fi
cellList=$(echo "$gridDiskList" | awk -F_ '{print $NF}' | sort -u)
for cell in $cellList; do
myGriddisks=$(echo "$gridDiskList" | grep ${cell}$ | tr '\n' ',')
echo "[[ \$(hostname -s) == ${cell} ]] && cellcli -e 'LIST GRIDDISK \
${myGriddisks%,} attributes name, asmDiskGroupName, asmModeStatus \
where asmModeStatus != UNKNOWN'" >> $listGriddiskScript
echo >> $listGriddiskScript
done
chmod +x $listGriddiskScript
echo
echo "Run the following command to list griddisks in use by this cluster:"
echo
echo "# dcli -l celladmin -c ${cellList//$'\n'/,} -x $listGriddiskScript"
echo
for cell in $cellList; do
myGriddisks=$(echo "$gridDiskList" | grep ${cell}$ | tr '\n' ',')
echo "[[ \$(hostname -s) == ${cell} ]] && cellcli -e 'DROP GRIDDISK \
${myGriddisks%,}'" >> $dropGriddiskScript
echo >> $dropGriddiskScript
done
chmod +x $dropGriddiskScript
echo
echo "Stop CRS on all nodes in this cluster, then run the following"
echo "command to drop all griddisks used by this cluster:"
echo
echo "# dcli -l celladmin -c ${cellList//$'\n'/,} -x $dropGriddiskScript"
echo
exit