1. master-Slave configuration
#主从都要加入以下配置如下 [mysqld]log-bin=mysql-bin# master or slave server-id=222 #在主上建立一个用户给从的用GRANT REPLICATION slave,reload,super on *. * to [e-mail protected] '% ' identified by ' 1234 '; #在从连接主CHANGE MASTER to master_host= ' 182.180.50.118 ', master_user= ' backup ' , master_password= ' 1234 ', master_log_file= ' mysql-bin.000001 ', master_log_pos=0; #开始执行START SLAVE;
2. Primary master Configuration
#主主配置 #h1 New User grant replication slave on * * to ' water ' @ '% ' identified by ' 1234 '; #h1新建用户grant replication Slave on * * to ' W Ater ' @ '% ' identified by ' 1234 '; #主从都要配置如下 [mysqld] #给server取个唯一标记server-id=222# The binary log is enabled here, the master from the use to log-bin=mysql-bin# Master configuration Start # A database that requires logging into the log. If there are multiple databases that can be separated by commas, or if multiple binlog-do-db options are used binlog-do-db=ts# the database that does not require logging into the log. If there are multiple databases that can be separated by commas, Or use multiple binlog-do-db options to binlog-ignore-db=mysql,information_schema# the database that needs to be synchronized. If there are multiple databases that can be separated by commas, Or use multiple replicate-do-db options to replicate-do-db=ts# databases that do not need to be synchronized. If you have multiple databases that can be separated by commas, or use multiple replicate-ignore-db options replicate-ignore-db=mysql,information_schema# synchronization parameters: #保证slave挂在任何一台master上都会接收到另一个master的写入信息 log-slave-updates sync_binlog=1auto_increment_offset=1auto_increment_increment=2# filter out some of the wrong things. slave-skip-errors=all# master Configuration End # View data Device status flush tables with read Lock;show master status\g, value of #可以看出master_log_file, Master_log_pos # Specify master server change master to Master_host= ' 182.180.50.118 ', master_user= ' water ', master_password= ' 1234 ', master_log_file= ' mysql-bin.000002 ', Master_log_pos=106;change Master to Master_host= ' 182.180.57.3 ', master_user= ' water ', master_password= ' 1234 ', master_log_file= ' mysql-bin.000003 ', Master_log_ pos=106, #要解除锁unlock tables;
MySQL Notebook cluster