MySql database master double (two-way) to achieve synchronous dual master database hot backup configuration steps are a little complex, we must be careful every step of the small details Oh, I hope you will bring the article to help it.
Prior wrote mysql Master Slave master-slave synchronization (replication) configuration, belong to the database backup levels. Now the demand is, are equipped on both database servers, in order to prevent some server problems affect the operation of the business, you need two servers are running mysql, and the need to keep the data on both servers is synchronized. That is to say now mysql-way synchronization, realize standby mode database.
Basic environment
Server operating system: Ubuntu 12.04 64-Bit
Database version: MySql 5.1 +
Two servers IP: 192.168.1.2 192.168.1.3
Synchronization account settings
First of all to each add a new account can be found on both servers.
grant all privileges on db_name.* to 'dbuser'@'192.168.1.3' identified by 'dbpassword';
flush privileges;
grant all privileges on db_name.* to 'dbuser'@'192.168.1.2' identified by 'dbpassword';
flush privileges;
Configuration data see
To modify the database server's configuration file first:
we /etc/mysql/my.cnf
The following information in [mysqld] configuration:
default-character-set=utf8
log-bin=mysql-bin
relay-log=relay-bin
relay-log-index=relay-bin-index
server-id = 1 # server ID
master-host=192.168.1.2
master-user=root
master-password=pwd123
master-port=3306
master-connect-retry=30
binlog-do-db=abc
replicate-do-db = db_name # to synchronize database
replicate-ignore-table = udb.table # sync table
Note: Note added content above, if there are multiple databases, and there is no need to synchronize, you need to add replicate-ignore-db, followed by the name of the database is not synchronized.
Similarly, modify the configuration file on a separate database server: /etc/mysql/my.cnf
default-character-set=utf8
log-bin=mysql-bin
relay-log=relay-bin
relay-log-index=relay-bin-index
server-id = 1 # server ID
master-host=192.168.1.3
master-user=root
master-password=pwd123
master-port=3306
master-connect-retry=30
binlog-do-db=abc
replicate-do-db = db_name # to synchronize database
replicate-ignore-table = udb.table # sync table
Manual synchronization
A master server, then restart the database server B:
service mysql restart
Then execute:
stop slave
Manual synchronization:
load data from master;
Then start synchronizing:
start slave;
A restart MySQL server;
View database synchronization status:
show slave status \G ;
View:
slave_IO_Running : Yes
slave_SQL_Running: Yes
If these two values are Yes, then that pass successfully.
problem
If there is a synchronization delay large, you need to modify the configuration file:
slave-net-timeout=30 ;
It can restart.