Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

As its not possible to get NFS replication or active-active high availability cluster i took some simple approach to achieve my requirement.

NFS4 Installed on NFS1 and NFS2, Both NFS server allowing all of my client IP’s.

Both NFS1 and NFS2 mounted locally on client machine. And these two simple bash script as client side lookups for NFS server availability.

Script1: Does set’s timeout of 3 second to read if that is reachable. If Not available change symlink of mount point to next available in first given scenario it would be (test-mnt1). And second check for vice-versa.

This ble to failover with available one, and “race-to-fix” if both are unavailable i.e. in availability of 1 takes 29 second max to failover.
kept into cronjob with sleep 20; i.e. running every 30 Second. [Script is smart enough to read termination of timeout and nested if in case it has both nfs dead.]

#!/bin/bash

/usr/bin/timeout 3 ls -al /test-mnt2/ && { echo "Alive"; } || { /usr/bin/timeout 3 /bin/ln -sfn /test-mnt1 /imgsrv; } && { echo "Alive"; } || { /usr/bin/timeout 3 /bin/ln -sfn /test-mnt2 /imgsrv; }
/usr/bin/timeout 3 ls -al /test-mnt1/ && { echo "Alive"; } || { /usr/bin/timeout 3 /bin/ln -sfn /test-mnt2 /imgsrv; } && { echo "Alive"; } || { /usr/bin/timeout 3 /bin/ln -sfn /test-mnt1 /imgsrv; }

Script2: Continuous replication (rsync push) if any changes detected by inotify.

#!/bin/bash

inotifywait -r -m -e close_write --format '%w%f' /mnt/test  | while read newfiledir
do
    rsync -Pzarve "ssh -p22 -i /root/temp-key" ${newfiledir} root@xx.xx.xx.xx:/${newfiledir} >> /tmp/sync_log

done