There are three types of nodes that you might want to add to an existing MySQL Cluster: mysqld (API) nodes, management server nodes, and data nodes.
Adding a new mysqld (API) node
In order to add a new mysqld node, you simply need to add the new [mysqld] section to the config.ini and then perform a rolling upgrade. After you have done this, then you can start up the new mysqld node and it will have all of the cluster data available. To do this, following you would follow these steps:
- Edit the config.ini to add the new [mysqld] section.
- Perform a rolling restart.
- Start up the new mysqld node.
Note that you don’t have to shut down the entire server in order to add a new mysqld node.
While the steps above do work, it is often a good practice to have a few extra [mysqld] and/or [api] sections in the config.ini that are not used. The reason you can safely have extra unused slots is because you do not have to have all mysqld nodes running in order to start the cluster. In the case where you have one of these empty slots, you only need to start up the mysqld to fill it. There is no need to do a rolling upgrade if you already have the extra slot available.
Adding a new management server node
Adding a new management server is very similar to adding a new mysqld node. To add a new one follow this process:
- Edit the config.ini file to add a new [MGM] group.
- Edit all of the nodes to have a new connect-string parameter including the extra management node information.
- Shut down the existing management node(s)
- Start the existing management node(s) with –initial. This is one of the cases where –initial is required for the management node. If you try –reload, the new management node will not have the same configuration version as the old and will be refused to connect to the cluster.
- Start up the new management node with –initial.
- Complete the rolling restart for the data and api/mysqld nodes to get the new connection string information and config.ini information loaded into each node.
Again, you do not need to completely shutdown the cluster. While MySQL Cluster supports three and more ndb_mgmd nodes there are generally little reasons to have more than two.
Adding a new data node (ndbd or ndbmtd)
The procedure to add a new data node depends on the version of MySQL Cluster.
MySQL Cluster 6.4.0 and Later
You can add a data node online. Refer the post below for the detailed steps:
MySQL Cluster 6.3 and Earlier
In these versions, you cannot add a complete new data node without interrupting service on the cluster. To add a new data node you have to do the following:
- Take a backup of the data in MySQL Cluster either using mysqldump or with the hot online backup tool.
- Change the config.ini file to the new specified setup.
- Do a full initial restart of the MySQL Cluster.
- Shutdown every single node in the cluster.
- Startup the data nodes (ndbd) using the –initial flag. This will remove all existing data in the cluster.
- Re-import your data into MySQL Cluster using the appropriate tool depending on how you took your backup.
This will cause all of the data to be redistributed amongst the new nodes added into the cluster. Note that this does require a full restart, so you will have shutdown time in order to implement it. While you can not add a new node on the fly, it is possible to replace a down node with another node. Meaning, if you lose one node permanently, it is possible to replace it with a new server without causing any downtime.
To replace a node, you just start it up as if it was the other node. That means you need to give it the appropriate node-id and make sure that the hostname is the same as the previous one. The node will then synchronize off of the other members of the node group like a crash recovery.