Skip to content

Replication

waterguo edited this page Mar 7, 2018 · 2 revisions

AntsDB has built-in replication support. The feature allows the data change in AntsDB to be duplicated in another MySQL or AntsDB database in real-time. It can be useful to create a backup database or distribute data to another place. AntsDB Replication supports both DDL and DML. To configure the replication, it takes the following 5 steps.

Create the bookmark table in the slave database

In order for the replication to work, it requires a metadata table in the slave database. The table can help the replication to resume the progress. Execute the following statements to create the bookmark table.

CREATE DATABASE antsdb;

CREATE TABLE antsdb.antsdb_slave (name varchar(100) NOT NULL PRIMARY KEY,value varchar(300) DEFAULT NULL) ENGINE=InnoDB;

Create a dump of the active database

Before the replication starts, the slave database must be identical to the master database. Create a dump file of the master database using mysqldump command.

Configure the slave connection in AntsDB

The replication feature requires the following properties to be set in AntsDB's conf.properties file.

Property Comment
humpback.slave set to true to enable replication
humpback.slave.url JDBC url of the slave database
humpback.slave.user user name to log into the slave database
humpback.slave.password password to log into the slave database
humpback.log-retention.time Number of seconds should the log file to be kept. Recommended value is 604800, i.e. one week.

Restore the dump in the slave database

Then restore the slave database using the dump file created above. At this point, the master database and slave database should have the same structure and data.

Restart AntsDB

Restart AntsDB, the replication will be turned on in the background.