Search code examples
mariadbgalera

MariaDB / Galera Cluster add nodes dynamically


I'm running into an issue with the way Galera cluster is set up to work with MariaDB.

Each node in the cluster has to have a configuration that houses the IP addresses of every other node (inclusive) in the cluster. If I ever want to add a node to the cluster, I have to manually add that node's IP address to the configurations on every other node.

This makes spinning up and down servers dynamically for the cluster difficult.

Are there any work arounds for this? Possibly a way to notify every node of a new node being added to the cluster remotely?


Solution

  • Galera clusters only need one server working as a master node. You can use any or all of the servers in the cluster as the cluster address for the new node and the new node will automatically connect to the rest of the nodes.

    Example

    Active Cluster:

    10.0.0.2 (the first node of the galera cluster)
    10.0.0.3
    10.0.0.4 
    

    If we want to add 10.0.0.5 to the cluster, we can use any of the following as a cluster address for it:

    gcomm://10.0.0.2
    gcomm://10.0.0.3
    gcomm://10.0.0.4
    gcomm://10.0.0.2,10.0.0.3
    gcomm://10.0.0.2,10.0.0.4
    gcomm://10.0.0.3,10.0.0.4
    gcomm://10.0.0.2,10.0.0.3,10.0.0.4
    

    The down side to this is that the new node would lose the other servers as fall back if the ones that they have configured in their cluster address are down.

    So a work around for this is to have X number of static nodes that will never go down, then use all of those as the cluster addresses for any new slaves that you bring up.