此处为了演示,由于内存资源有限,采用docker 启动多个mysql容器
角色主机机名/ipmastermysql1/172.20.0.2slave1mysql2/172.20.0.3slave2mysql3/172.20.0.4在mysql-slave上,查看数据是否同步
################# 1,登陆mysql主节点: mysql1 ################ root@60e91267022e:/# mysql -uroot -p123456 -hmysql1 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 5.7.27-log MySQL Community Server (GPL) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.01 sec) mysql> create database test; Query OK, 1 row affected (0.01 sec) mysql> use test; Database changed mysql> create table per(id int,name varchar(10)); Query OK, 0 rows affected (0.17 sec) mysql> insert into per values(1,'a'),(2,'b'); Query OK, 2 rows affected (0.08 sec) Records: 2 Duplicates: 0 Warnings: 0 ################ 2,登陆mysql从节点: mysql2 ################ mysql> ^DBye root@60e91267022e:/# mysql -uroot -p123456 -hmysql2 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 11 Server version: 5.7.27 MySQL Community Server (GPL) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | test | +--------------------+ 5 rows in set (0.00 sec) mysql> use test; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show tables; +----------------+ | Tables_in_test | +----------------+ | per | +----------------+ 1 row in set (0.00 sec) mysql> select * from per; +------+------+ | id | name | +------+------+ | 1 | a | | 2 | b | +------+------+ 2 rows in set (0.00 sec)