Link to home
Create AccountLog in
Avatar of sminfo
sminfo

asked on

Synchronize folders on two AIX taking into account a DNS record.

ok,

We have two AIX boxes with rsync installed. One server is 'b5' and the other 'b5cont'.  There's a DNS record 'b5srv' which can be the IP of 'b5' or 'b5cont' depending where we want to have the service running. On the initial state the IP of 'b5' is the same of 'b5srv'.

Both servers has a folder /FOLDER which has to be identical no matter the service 'b5srv' is running.

We must use RSYNC or other open source software, there's no $$$ for HACMP, GLVM or other commercial software.

What we have thought is to make an script that runs on both servers which compares the IP of 'b5srv' with the local IP and if it's the same, it invokes the rsync command to make the synchronization.

Questions?

Is there another simple or better way to do that?
If we use this way, which is the best way to get AIX's IP? ifconfig? netstat -in? other?

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of sminfo
sminfo

ASKER

yes, b5srv is always the source...

as always.. your idea is ALWAYS more efficient than our..thanks
Avatar of sminfo

ASKER

wmp,

after the 'if'
if netstat -in | grep -q $IP_OF_B5SRV ; then ...

how do I know if 'b5' or 'b5cont' is the remote host for the rsync command?

rsync -ahv /backups root@xxxxxx:/
IP_OF_B5SRV=$(host -n b5srv |awk '{print $NF}')
IP_OF_B5CONT=123.123.123.123  # or use "host" if it's also in DNS
IP_OF_B5=223.223.223.223      # or use "host" if it's also in DNS

if netstat -in | grep -q $IP_OF_B5SRV ; then
  echo "We are b5srv!"
    if netstat -in |grep -q $IP_OF_B5 ; then
     echo "We are also b5, so let's sync to b5cont."
     TARGET=$IP_OF_B5CONT
       else
        if netstat -in |grep -q $IP_OF_B5CONT ; then
           echo "We are also b5cont, so let's sync to b5."
           TARGET=$IP_OF_B5
       else
          echo "Can't determine base address. Exiting!"
          exit
       fi
     fi
        # "echo" for testing.
        echo rsync -ahv /backups root@$TARGET:/
        exit
fi
echo "We are not b5srv, nothing to do!"
exit

Open in new window

Avatar of sminfo

ASKER

perfect!! thanks much
i do not care about points there, but beware, that unless you are 100% sure that all these are true :
- your rsync completes instantaneously (unlikely)
- your DNS are synchronous at all times (very unlikely)
- your rsync is run continuously or at least after each commit and before the writer gets confirmation (unthinkable)
you are 100% sure to loose data anytime yiou switch from one host to the next
but data integrity is likely to be decent as long as one machine does not die during the rsync

maybe this is not a problem to you, but just beware that multi-master replication in storage is far from being that simple when you actually need to preserve data.

if you do the rsync both ways, beware that you also need to make sure they do not run both ways at the same time when the dns entry is flipped (ie make sure the master is actually dead before you make a change and stays dead long enough)

----

also, please do not determine the IP using this command

netstat -in | grep -q $IP_OF_B5SRV

unless the AIX netstat does not work as i expect, it will return true on both machines as long as there is at least one established connection between them. replacing the netstat with ipconfig should do the trick, though it is likely not the most economic solution.
Avatar of sminfo

ASKER

don't worry wmp, in this case the RSYNC will run few times daily becuase folders aren't change continusly. The change on the DNS record is done manually, so you are prepared to make the switch to b5cont if necessary and have lot of time to DNS servers to be sincronized. ALso, it's not a super critical service for us, and files to be  rsynced only change a couple of time on a week.

We use HACMP/GLVM, dataguard, DB2-HADR and other commercial powerfull softwares on the critical services.

And, I'll make the change to 'ifconfig' as I thought before write you today...
Don't worry yourself, Israel!

"netstat -in" on AIX does everything right.

The author of the previous comment seems to confuse it with "netstat -an", at least they're not aware of what "netstat -in" does on AIX!

Test it on the command line!

wmp
i believe you must be right as usual wmp ;)