$ cat /home/mysql/docker-data/3313/conf/my.cnf # For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld] # # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M #datadir=/home/mysql/docker-data/3307/data #socket=/home/mysql/docker-data/3307/mysql.sock
mysql> insert into t_order values(4,"V"); 发现数据已经同步至slave:
mysql> select * from order.t_order; +------+------+ | id | name | +------+------+ | 4 | V | +------+------+ 3 rows in set (0.00 sec) 先停止slave,再在master.order表插入数据: +------+------+ | 4 | V | | 5 | X | +------+------+ 4 rows in set (0.00 sec) 遇到的问题 在slave服务器show slave status:
Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work. 首先检查master和slave的server_id是否一致,如果一致去修改my.cnf文件中的server_id字段:
mysql> show variables like 'server_id'; 然后排查master和slave的uuid是否一致:
mysql> show variables like '%uuid%'; 如果uuid一致去修改data目录下的auto.cnf文件,拷贝整个data目录,把auto.cnf文件也拷贝过来了,里面记录了数据库的uuid,每个库的uuid应该是不一样的。