04 February 2016

iSCSI connection failure in RHEL / Linux

Condition

We're running a Dell PowerVault MD3600i iSCSI connection to a RHEL server. From time to time (rarely but more frequently than I like it) it seems to lose the mount and needs intervention.

Herewith the script that I've written to repair the lost mount connection - hope it's useful for someone. 

Script solution

Run a cronjob to check the mount exists and if not, perform a mount repair...
(note the *** portions of the below script are going to be different for your personal setup)

if grep -qs /data /proc/mounts; then
date >> /usr/local/sbin/logs/checkdatamount.log
echo "/data is mounted" >> /usr/local/sbin/logs/checkdatamount.log
echo "---" >> /usr/local/sbin/logs/checkdatamount.log
else
date >> /usr/local/sbin/logs/checkdatamount.log
echo "!!! /data is NOT mounted !!!" >> /usr/local/sbin/logs/checkdatamount.log
echo "^^^" >> /usr/local/sbin/logs/checkdatamount.log
echo "attempting repair" >> /usr/local/sbin/logs/checkdatamount.log
echo "..." >> /belfry/logs/checkdatamount.log
iscsiadm --m node -T iqn.1984-05.com.dell:powervault.md3600i.6f0******2d788ac --portal 10.***.***.1**:3260 -u
iscsiadm -m discovery -t st -p 10.***.***.1**
iscsiadm -m node --targetname "iqn.1984-05.com.dell:powervault.md3600i.6f0******2d788ac" --portal "10.***.***.1**:3260" --login
iscsiadm -m session
vgchange -an MD3600i***01
vgchange -ay MD3600i***01
mount /dev/mapper/MD3600i***01-MD3600i***Vol01 /data
echo "... repaired (possibly)" >> /belfry/logs/checkdatamount.log
fi

No comments: