Replication rebuilding is required in CUBRID HA when data in the CUBRID HA group is inconsistent because of multiple failures in multiple-slave node structure, or because of a generic error. Rebuliding replications in CUBRID HA is done using a script.
For rebuilding replications to happen, the following environment must be the same in the slave node and in the master node.
- CUBRID version
- Environmental variable ($CUBRID, $CUBRID_DATABASES, $LD_LIBRARY_PATH, $PATH)
- Database volume, log and replication log path
To rebuild replications, use the ha_make_slavedb.sh. This script is located in $CUBRID/share/script/ha. Before rebuilding replications, the following items must be configured for the environment of the user.
- master_host: The host name of the master node during replication rebuilding. It should be registered in /etc/hosts.
- db_name: Specifies the name of the database to be replicated and rebuilt.
- repl_log_home: Specifies the home directory of the replication log of the master node. It is usually the same as $CUBRID_DATABASES.
The following are optional items:
- dba_password: If the CUBRID dba account is password protected, sets the password.
- backup_dest_path: When executing backupdb at the master node, configures the path in which the backup volume will be created.
- backup_option: Configures necessary options when executing backupdb at the master node.
- restore_option: Configures necessary options when executing a restore at the slave node in which the replication will be rebuilt.
- scp_option: An option that is used to configure the scp option to copy the backup volume of the master node to the slave node. Its default value is 16M so it will not cause network overload in the master node.
Once the script has been configured, execute the ha_make_slavedb.sh script at the slave node in which a replication will be rebuilt. When the script is executed, replication rebuilding occurs in a number of phases. To move to the next stage, the user must enter an appropriate value. The following are the descriptions of available values.
- yes: Continue.
- no: Do not move forward with any stages from now on.
- skip: Skip to the next stage. This input value is used to ignore a stage that has not necessarily been executed when retrying the script after it has failed.
- Online backup of a master node: Existing backups of master or the slave nodes cannot be used for replication rebuilding. You must use the online backup of the master node that is automatically created by the script.
- Error while executing the replication rebuilding script: The replication rebuilding script is not automatically rolled back to its previous stage, even when an error occurs during the execution. This is because the slave node cannot provide normal service before the replication rebuilding script is executed. To return to the stage in which the replication rebuilding script had not been executed, you must back up the db_ha_apply_info information, which is an internal catalog of the master and slave nodes, and the existing replication log, before executing the replication rebuilding script.