Install MySQL on two machines, synchronize the contents of two databases with SYRNC
Configure the primary Add Server-id = 1log-bin=mysql-bin (generate binary log) in config file vi/etc/my.cnf above these two are the two optional binlog-do-db=databasename1 that must be added below , databasename2binlog-ignore-db=databasename1,databasename2binlog-do-db= needs to replicate the database name, multiple database names, separated by commas. Binlog-ignore-db= does not need to replicate database library names, multiple database names, separated by commas. [[email protected] bin]# mysql-u root-p (mysql command line ends with; end) Authorization mysql> grant replication Slave on *. * to ' Wang ' @ ' 192.168.72.132 ' identified by ' Wangyongyan ', on (corresponding to which library authorization) to (authorization to that user) @ (from IP) IP becomes percent sign is for any user Identifiedby (password) flush privileges; (Refresh authorization) flush tables with read lock; (Lock read to brush memory to disk) show master status; (keep data unchanged) configuration from open config file vi/etc/my.cnf Modify must add Server-id = 2 (can be any number cannot be the same as the master) comment out Log-bin=mysql-bin optional add Restart the MySQL service with the master's counterpart Replicate-do-db=databasename1,databasename2replicate-ignore-db=databasename1,databasename2/etc/ Init.d/mysqld restart mysql-u Root-p slave stop; (Stop slave service) change master to master_host= ' 192.168.31.131 ', master_port=3306, master_user= ' Wang ', master_ Password= ' WangyonGyan ', master_log_file= ' mysql-bin.000003 ', master_log_pos=478; (The last two options are the one that the Lord lock remains the same value) slave start, (start slave service) show slave status\g; (check the status from) slave_io_running and Slave_sql_ Running: Whether the state is yes in the Lord unlock unlock tables; test Master in the Lord to view the existing library show databases; Create library creation DATABASW Library name; View from the top of the library that you just created show databases; Copy a table in the Lord Show create table aming.pre_forum_post; Open the table after the statement copy and paste, re-view will come out a table
MySQL master-slave configuration