Because the actual business requirements recently need to deploy some MySQL server, and in the deployment of MySQL server in the master from synchronization with the MySQL replication of the slave-to-host synchronization method, of course, there are many ways to achieve MySQL master-slave synchronization, this is only said to use MySQL Replication's master-slave synchronization function, in the implementation of MySQL master-slave synchronization of the common 2 ways of configuration, of course, according to the actual production environment to choose a different way, Here simply put 2 configuration method configuration my.cnf say, because there have been written MySQL master-slave synchronization method, here will not repeat, need to see: http://jim123.blog.51cto.com/4763600/1835480, here for the convenience of the above as an example
One, specify one or more libraries to replicate
In this way, master-slave synchronization is mostly used for some libraries or tables in master, and the rest is not replicated, the advantage is that in master, as long as you copy the library or table you want to copy, the other library tables are not copied. The disadvantage is also obvious is that if you want to add a new library in master needs to be replicated when the MySQL service needs to modify the MY.CNF restart Mysqld service, the MY.CNF configuration is as follows:
#在master中的 "[mysqld]" Add Server-id = # General Master is 1, of course, if it is other architecture is not necessarily log-bin=mysql-binrelay-log = mysql-relay-bin# This is the key to synchronization # in Slave "[mysqld]" Add Server-id = 2log-bin=mysql-binreport-host=192.168.168.253# Main Library Iprelay-log = mysql-relay-binreplicate-wild-do-table=database.% #需要同步主库里的某一个库, multiple libraries can be added by themselves
Second, the exclusion of MySQL permissions library, etc., all the rest of the copy
The pros and cons of this approach are in contrast to the previous one, so there is no need to restart the MYSQLD service when the Create new library is synchronized in master, the MY.CNF configuration is as follows:
Add Server-id = 1log-bin=mysql-binrelay-log = Mysql-relay-binreplicate_wild_ignore_table=mysql #在master中的 "[Mysqld]". %replicate_wild_ignore_table=information_schema.% #当然如果默认的test库没有drop也要加上 # Add Server-id under "[Mysqld]" in slave Iprelay-log = Mysql-relay-binreplicate_wild_ignore_table=mysql of the 2log-bin=mysql-binreport-host=192.168.168.253# Main library. %replicate_wild_ignore_table=information_schema.%skip-slave-start# this plus avoid booting when the slave replication process starts mysqld
So the MySQL replication master-Slave synchronization of the common method of configuration my.cnf file is over
This article from the "Technical essay" blog, reproduced please contact the author!
MySQL Replication 2 Ways to configure master-slave synchronization