Wondering if anyone out there has any advice or examples on a good algorithm for guaranteeing one and only one server be set as the master among several that start up at the same time?
What I have come up with is the following, but the snag is with the last question below:
Or is this all bad to begin with? Is there a better way to go about it?
There are various solutions to this problem. If you are assuming that a shared file system is always available, then that simplifies the problem.
This is not a fool-proof solution, because it relies on the file system to control access to the file (two computers coming up my both try to write to the file at the same time). However, because the master file should only have one hostname in it, the final step should guarantee that only one computer really thinks its the master.
The problem is a bit harder without the assumption of an up-all-the-time shared file system.