Specifying the correct Machine and Datacenter ID options on the Database handle

(Christophe Chevalier) #1

There a settable options on the Database handle for the Machine and Datacenter ID.

I have configured two set of fdb process with two datacenter_id (DC01 and DC02*), but left untouched the machine_id in foundationdb.conf.

Looking at the output of status json for one of the nodes, I see in the locality object:

So I can safely assume that for the datacenter id, I can pass the string “DC01” (or “DC02”). But the machine id looks like a hash from some string unique to the host.

How can a local application, running on the same host, know about that ID to set the corresponding option on the database handle?

Do I need to explicitly set the machine_id in the foundationdb.conf of each host to a known value (probably using the host name), so that the application can also set the same value?

What would happen if an application would set a datacenter or machine id option with a value that is not valid anymore ?

I’m looking for a way to have each client automatically prefer the local node (if there is one present) without having to check out of band to get the correct value.

(A.J. Beamon) #2

Correct, you would need to set the machine_id manually on your machines (using --machine_id or --i) and then set the machine_id on the clients to match using the database option.

Setting one of these fields to a value that doesn’t match anything in the database is basically equivalent to not setting it at all in that your client won’t prefer any particular machine or datacenter.