Two-master actually is a replication, just introduced some new topological structure
There are two modes of primary-master replication:
Active-Active Mode primary-primary replication (Master-master in active-active mode) master-master replication (Master-master in active-passive modes) and of course, Ring and have master-master replication from the server, but are all the extensions above. With respect to the first two-master mode, data conflicts are bound to occur. Although you can use the configuration auto_increment_increment=2 and auto_increment_offset=1 to solve the problem of automatic insertion, the data will be inconsistent if you allow data to be inserted at the same time. For example: The following two commands are executed at the same time:
First primary server: Mysql>update tbl set Col=col +1; second primary server: Mysql>update tbl set col=col*2; What was the result? One server has a value of 4, and the other one is 3. And there is no replication error at all. Therefore, the individual recommends active-passive dual-master mode, just let one server write on the line, let it service, another as a backup. Only data is accepted. Below start to get to the point, how to configure the dual master.The first step, the MYSQL.CNF must be configured with the following statement when starting the database for the station 3306:server-id = 323306
log_slave_updates = 1Auto_increment_increment=2auto_increment_offset=1 3307:server-id = 323307log_slave_updates = 1auto_increment_increment=2auto_increment_offset=2read-only (guaranteed read only)Of course each server's Port,user,socket,pid-file,basedir,datadir,tmpdir and log-Related: Log-bin (this must be turned on), Slow_query_log_file (of course, also to open And so on Don't say it. The most important thing here is log_slave_updates, without it, the double master is not worthy of, about it's detailed introduction. At the following address: Http://dev.mysql.com/doc/refman/5.5/en/replication-options-slave.html#option_mysqld_log-slave-updates plainly , which can be a, B, C, to ensure that a can be used as master, copy to B,b can be as master, copy to C. So, if A and B each other, it is the double master.the second step, then two servers are equipped with REPL users。 mysql> CREATE USER ' repl ' @ ' 192.168.1.50 ' identified by ' Repl ';mysql> GRANT REPLICATION SLAVE on * * to ' repl ' @ ' 192.1 68.1.50 '; Note: ' 192.168.1.50 ' This IP is to tell the host from this IP to have replication slave permissions.The third step is the same as configuring replication. Ensure consistent backups. SHOW MASTER STATUS; know the corresponding binlog. Change Master tomysql>change Master Tomaster_host = ' 192.168.1.40 ', master_port = 3306,mster_user = ' repl ' on slave Master_password = ' Repl ', master_log_file = ' mysql-bin.000004 ', master_log_pos = 107; Then change over, because slave accepted Master's Binlog, and set the Log_slave_updates and Binlog also opened, so Salva can also see their binlog. Then do the above, and do it again. In this way, the dual master even if the configuration is successful. (There are no more detailed steps, but basically it's in place.) Configuration, consistent with MySQL replication. Http://blog.chinaunix.net/uid-26446098-id-3267475.html can refer to this article) http://blog.chinaunix.net/uid-26446098-id-3267556.html
Kind MySQL Learning-mysql dual Master