Switch Database Role

Hi @all,

is there a way to decide which Node has the Role “database” or “database-standby”?

Thanks Frank

One for @mbordere

There’s not really a direct way to do it.
dqlite, the backing database for a lxd cluster, supports the concept of weights and failure domains, that can influence if a node becomes database (dqlite voter), database-standby (dqlite standby) or none (dqlite spare).

failure domain: A node can be assigned a failure domain, the reasoning is that nodes belonging to the same failure domain have a correlated risk of exhibiting issues (e.g. same rack, geography etc …).
Thus choosing nodes from a different failure domain diversifies the risk. When a node is promoted (none → standby or standby → database) preference is given to nodes from a different failure domain in comparison with the nodes currently in the group.

e.g when you have 3 database nodes and 2 standby nodes.

node-id | failure-domain | role
1|1|db   
2|2|db 
3|2|db
4|1|standby
5|3|standby

When node 3 goes down, node 5 will be promoted to db node, because it has a different failure domain than the nodes currently in the db group.

weight: A node with a lower weight compared to other nodes will be preferred to be promoted. You can more or less compare weight with (expected) load.

node-id | weight | role
1|1|db   
2|1|db 
3|1|db
4|4|standby
5|2|standby

When node 2 goes down, node 5 will be promoted because it has a lower weight.

I’m not sure if LXD supports/exposes failure domain and weight currently.

TLDR: short answer is no :wink:

1 Like

Well, then explained differently. I have now a cluster with two nodes. An old server and the new server. I have completely transferred all the containers to the new one. Now I want to take the old one out. Will the new server automatically switch the role to database, or do I have to do something?

You need to make sure you’re either on LXD 4.0.8 or LXD 4.19 as this very scenario was buggy before then. If you are, then lxc cluster remove of the old server will cause it to first transfer role to the new one and then leave the cluster.

It’s something that @masnax sorted out a few weeks back and that we have pretty good testing for now (it’s part of the tests that run every time we push a change to LXD).

1 Like