Creating a Unique ID on distributed systems

Hi,

How do you actually create a unique ID on a distributed system. I looked at gethostid but the man page says that its not guaranteed to be unique. Also using the IP address does not seem to be a feasible solution. Is there a function call or mechanism by which this is possible when even the time is not synchronized using NTP ?

Thanks

Whan you install the system, create a file called /etc/unique_id and put a unique_id in it. Then you just read that file. I don't know why you think that time has anything to do with this, but yes, this technique is possible even when the time is not synchronized using NTP.

If you have access to a database, such as Oracle, you may find this useful. However, that would of course cause all the processes using said unique ID to potentially block each another up. There are ways around that too, pre-fetching UIDs etc.

The other way, as Pederabo said, is to assign each distributed machine some machine ID. Then as it feeds transactions (or whatever needs to be uniquely identified) it can prepend/append its unique ID to a machine independant unique ID.

use your ip address + local time + a huge random number to generate a Unique ID

many programs use this kind of technology.

Why not use your network card's mac address? That's a big very-unique number that comes with your PC. The only caveat would be, upgrade your network card and it changes :smiley: Maybye generate /etc/unique_id from the mac address then just use the file thereafter?