While theupgrade cluster command can be used to perform a downgrade for an NDB Cluster (see the description for theupgrade cluster command for the restrictions that apply), special steps are required when that involves a downgrade formysqld for which in-place downgrade is not supported. For example, downgrading from NDB Cluster 7.5 to 7.4 involves downgrading the MySQL server from 5.7 and 5.6, for which the logical downgrade method must be employed (seeDowngrade Paths, for information on downgradingmysqld). This section explains the steps to take in the situation. Let us use this sample cluster as an example:
mcm> show status -r mycluster;+--------+----------+----------+---------+-----------+----------+| NodeId | Process | Host | Status | Nodegroup | Package |+--------+----------+----------+---------+-----------+----------+| 49 | ndb_mgmd | tonfisk | running | | 7.5-DMR1 || 1 | ndbmtd | flundra | running | 0 | 7.5-DMR1 || 2 | ndbmtd | grindval | running | 0 | 7.5-DMR1 || 50 | mysqld | flundra | running | | 7.5-DMR1 || 51 | mysqld | grindval | running | | 7.5-DMR1 || 52 | ndbapi | * | added | | |+--------+----------+----------+---------+-----------+----------+Assuming the NDB Cluster has been upgraded from version 7.4 to 7.5 and the user then encountered a major problem and now needs to revert the cluster to version 7.4, these are the steps to follow:
Backup all the cluster data:
mcm> backup cluster mycluster;+-------------------------------+| Backup completed successfully |+-------------------------------+Usemysqldump to backup non-NDB data from each of themysqld nodes.
Assuming the package for the lower version of NDB Cluster you want to downgrade to is still available to MySQL Cluster Manager (if it is not the case, use the
add packagecommand to supply the package), use theupgrade clustercommand and the–-nodeidoption to downgrade the management and data nodes:mcm> upgrade cluster -P 7.4.10 --nodeid=49,1,2 --retry mycluster;+-------------------------------+| Cluster upgraded successfully |+-------------------------------+Remember to include ALL management nodes and data nodes with the
–-nodeidoption, but leave out anymysqld node. Theshow statuscommand shows which nodes have now been downgraded:mcm> show status -r mycluster;+--------+----------+----------+---------+-----------+----------+| NodeId | Process | Host | Status | Nodegroup | Package |+--------+----------+----------+---------+-----------+----------+| 49 | ndb_mgmd | tonfisk | running | | 7.4.10 || 1 | ndbmtd | flundra | running | 0 | 7.4.10 || 2 | ndbmtd | grindval | running | 0 | 7.4.10 || 50 | mysqld | flundra | running | | 7.5-DMR1 || 51 | mysqld | grindval | running | | 7.5-DMR1 || 52 | ndbapi | * | added | | |+--------+----------+----------+---------+-----------+----------+Recreate the data directory for eachmysqld node:
Stop themysqld node:
mcm> stop process 50 mycluster;+-------------------------------+| Process stopped successfully |+-------------------------------+Delete the data directory of themysqld node and recreate it, as an empty folder:
user@host$ cd mcm_data/clusters/mycluster/50/user@host$ rm -rf datauser@host$ mkdir dataInitialize the recreated data directory using themysql_install_db script in the package of the NDB Cluster version you are downgrading to:
user@host$ /clusters/7.4/scripts/mysql_install_db \ --defaults-file=/mcm_data/clusters/mycluster/50/cfg/my.cnf \ --datadir=/mcm_data/clusters/mycluster/50/data --basedir=/clusters/7.4.10 \ > mysql_install_db.log 2>&1(When you are downgrading to NDB Cluster 7.5 or later, themysqld data directory should be initialized with themysqld
--initializecommand; seeInitializing the Data Directory for details.)Restart themysqld node using MySQL Cluster Manager (due to the downgrade already performed earlier on the management and data nodes,mcmd is going to start themysqld node with the binary of the cluster version you are downgrading to ):
mcm> start process 50 mycluster;ERROR 9003 (00MGR): Tx {690be0d6 270 0 15} timed out on agent 0 @{19 0 50Wait for mysqld to start} participants: 0@tonfisk:18620[X] 1@flundra:18620[ ] 2@grindval:18620[ ]There might be a timeout error as shown above, which is due to the fact that themcmd user is still to be created on themysqld node (this happens in the next step). The error can be avoided if you perform the next step soon enough. But even if the error occurs, there is no issue here, asmcmd will keep trying to connect to themysqld node.
Recreate the
mcmduser on themysqld node:mysql> CREATE USER 'mcmd'@'127.0.0.1' IDENTIFIED BY '<manager-password>';mysql> GRANT ALL PRIVILEGES ON *.* TO 'mcmd'@'127.0.0.1' IDENTIFIED BY \ '<manager-password>' WITH GRANT OPTION;mysql> FLUSH PRIVILEGES;Reload onto themysqld node the non-NDB data you backed up earlier usingmysqldump:
mysql -h 127.0.0.1 -P 3306 -u root -p < dumpfile.sql
Repeat step 4 above and each of its substeps for everymysqld node of your cluster.
After all themysqld nodes have been downgraded and their data directories prepared,mcmd eventually reconnects with them all:
mcm> show status -r mycluster;+--------+----------+----------+---------+-----------+---------+| NodeId | Process | Host | Status | Nodegroup | Package |+--------+----------+----------+---------+-----------+---------+| 49 | ndb_mgmd | tonfisk | running | | 7.4.10 || 1 | ndbmtd | flundra | running | 0 | 7.4.10 || 2 | ndbmtd | grindval | running | 0 | 7.4.10 || 50 | mysqld | flundra | running | | 7.4.10 || 51 | mysqld | grindval | running | | 7.4.10 || 52 | ndbapi | * | added | | |+--------+----------+----------+---------+-----------+---------+