CentOS环境下MySQL 5.7主从复制搭建( 二 )

找到字段Slave_IO_Running和Slave_SQL_Running,如果Slave_IO_Running=找到字段Slave_IO_Running和Slave_SQL_Running,如果Slave_IO_Running=No
Slave_SQL_Running=Yes
当前Slave_IO_Running:值为No,向下查看错误信息:
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.修改auto.cnf中的UUID值,随意更改一个值即可 。
[root@localhost ~]# vim /usr/local/mysql/data/auto.cnfserver-uuid=修改一下[root@localhost ~]# systemctl restart mysqld 再次登录MySQL查看从节点信息Slave_SQL_Running 和Slave_IO_Running值是否为Yes状态,表示配置成功验证从是否同步数据

  • 在主服务器上新建数据库test
mysql> create database test;Query OK, 1 row affected (0.01 sec)mysql> use test;Database changed
  • 创建test表,并插入数据
mysql> mysql> CREATE TABLE test -> ( -> id int, -> name varchar(255) -> ) -> ;Query OK, 0 rows affected (0.06 sec)mysql> show tables;+----------------+| Tables_in_test |+----------------+| test |+----------------+1 row in set (0.00 sec)
  • 在slave上查看是否更新数据
mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys || test |+--------------------+5 rows in set (0.03 sec)mysql> use test;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> show tables;+----------------+| Tables_in_test |+----------------+| test |+----------------+1 row in set (0.00 sec)mysql> 恭喜主从复制配置成功!!!




推荐阅读