-
Notifications
You must be signed in to change notification settings - Fork 28
Replication
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.
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;
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.
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. |
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, the replication will be turned on in the background.