一、架构
三台msyql服务器221,222,223,每台服务器开两个实例,3306作为主库,3307作为另外一台服务器的从库
二、每台服务器安装双实例
参照:https://www.cnblogs.com/sky-cheng/p/10919447.html
进行双实例安装
三、每台服务器的3306实例创建一个复制账号
在172.28.5.221上
[root@push-5-221 ~]# mysql -uroot -p -S /var/lib/mysql/3306/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connectionid is 16Server version:5.7.26MySQL 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 clearthe current input statement.
mysql> grant replication slave,replication client on *.* to 'repl'@'%' identified by 'XXXXXXX';
Query OK,0 rows affected, 1 warning (0.00sec)
mysql>
在172.28.5.222上
[root@push-5-222 ~]# mysql -uroot -p -S /var/lib/mysql/3306/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connectionid is 11Server version:5.7.26MySQL 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 clearthe current input statement.
mysql> grant replication slave,replication client on *.* to 'repl'@'%' identified by 'XXXXXXXX';
Query OK,0 rows affected, 1 warning (0.01sec)
mysql>flush privileges;
Query OK,0 rows affected (0.00sec)
mysql>
在172.28.5.223上
[root@push-5-223 ~]# mysql -uroot -p -S /var/lib/mysql/3306/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connectionid is 7Server version:5.7.26MySQL 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 clearthe current input statement.
mysql> grant replication slave,replication client on *.* to 'repl'@'%' identified by 'xxxxxxxx';
Query OK,0 rows affected, 1 warning (0.00sec)
mysql>flush privileges;
Query OK,0 rows affected (0.00sec)
mysql>
三、主从配置
1、首先设置好每个3306mysql实例的server_id参数为本机IP地址最后一位,3307实例server_id参数为本机IP地址最后一位再加端口号
在172.28.5.221服务器的3306配置文件中打开日志文件设置
[root@push-5-221 ~]# vim /etc/mysql/my-3306.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
# innodb_buffer_pool_size=128M
# join_buffer_size=128M
# sort_buffer_size=2M
# read_rnd_buffer_size=2M
user=mysql
port=3306datadir=/home/mysql-5.7.26/data/3306socket=/var/lib/mysql/3306/mysql.sock
server_id=2213306log-bin=master-221binlog_format=row
#skip-grant-tables
symbolic-links=0pid-file=/var/run/mysqld/3306/mysqld.pid
log-error=/home/mysql-5.7.26/log/3306/mysqld.log
[mysqld_safe]
log-error=/home/mysql-5.7.26/log/3306/mysqld.log
server_id=221 设置server_id
log-bin=master-221 设置log_bin日志文件名
binlog_format=row 指定日志格式为row
2、重启3306实例,使配置生效
[root@push-5-221 ~]# mysqladmin -uroot -p -S /var/lib/mysql/3306/mysql.sock shutdown
[root@push-5-221 ~]# mysqld_safe --defaults-file=/etc/mysql/my-3306.cnf &[1] 3459[root@push-5-221 ~]# 2019-05-27T02:55:18.758733Z mysqld_safe Logging to '/home/mysql-5.7.26/log/3306/mysqld.log'.2019-05-27T02:55:18.813602Z mysqld_safe Starting mysqld daemon with databases from /home/mysql-5.7.26/data/3306
3、客户端连接
^C
[root@push-5-221 ~]# mysql -uroot -p -S /var/lib/mysql/3306/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connectionid is 2Server version:5.7.26-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.
4、显示server_id参数
mysql> show variables like '%server_id%';+----------------+---------+
| Variable_name | Value |
+----------------+---------+
| server_id | 2213306 |
| server_id_bits | 32 |
+----------------+---------+
2 rows in set (0.00 sec)
5、显示主库状态
mysql>show master status\G;*************************** 1. row ***************************File: master-221.000002Position:154Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set:1 row in set (0.00sec)
ERROR:
No query specified
此时,需要记住上面的参数: File: master-221.000001 Position: 154 ,日志文件名和偏移量,需要在从库上做主从设置时要用到这两个参数
6、从库设置
在172.28.5.222服务器上的3307配置文件
[mysqld]
# innodb_buffer_pool_size=128M
# join_buffer_size=128M
# sort_buffer_size=2M
# read_rnd_buffer_size=2M
user=mysql
port=3307datadir=/home/mysql-5.7.26/data/3307socket=/var/lib/mysql/3307/mysql.sock
server_id=2223307symbolic-links=0pid-file=/var/run/mysqld/3307/mysqld.pid
log-error=/home/mysql-5.7.26/log/3307/mysqld.log
[mysqld_safe]
log-error=/home/mysql-5.7.26/log/3307/mysqld.log
7、重启3307实例,使配置生效
[root@push-5-222 ~]# mysqladmin -uroot -p -S /var/lib/mysql/3307/mysql.sock shutdown
[root@push-5-222 ~]# mysqld_safe --defaults-file=/etc/mysql/my-3307.cnf &[1] 23445[root@push-5-222 ~]# 2019-05-27T03:11:33.550199Z mysqld_safe Logging to '/home/mysql-5.7.26/log/3307/mysqld.log'.2019-05-27T03:11:33.610157Z mysqld_safe Starting mysqld daemon with databases from /home/mysql-5.7.26/data/3307
8、查看相应参数
[root@push-5-222 ~]# mysql -uroot -p -S /var/lib/mysql/3307/mysql.sock
mysql> show variables like '%server_id%';+----------------+---------+
| Variable_name | Value |
+----------------+---------+
| server_id | 2223307 |
| server_id_bits | 32 |
+----------------+---------+
2 rows in set (0.00 sec)
9、执行从库命令
mysql>change master to-> master_host='172.28.5.221',-> master_port=3306,-> master_user='repl',-> master_password='xxxxxxxx',-> master_log_file='master-221.000002',-> master_log_pos=154;
Query OK,0 rows affected, 2 warnings (0.31 sec)
10、启动从库
mysql>start slave;
Query OK,0 rows affected (0.05 sec)
11、显示从库状态
mysql>start slave;
Query OK,0 rows affected (0.05sec)
mysql>show slave status\G;*************************** 1. row ***************************Slave_IO_State: Waitingformaster to send event
Master_Host:172.28.5.221Master_User: repl
Master_Port:3306Connect_Retry:60Master_Log_File: master-221.000002Read_Master_Log_Pos:154Relay_Log_File: push-5-222-relay-bin.000002Relay_Log_Pos:321Relay_Master_Log_File: master-221.000002Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:0Last_Error:
Skip_Counter:0Exec_Master_Log_Pos:154Relay_Log_Space:533Until_Condition: None
Until_Log_File:
Until_Log_Pos:0Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master:0Master_SSL_Verify_Server_Cert: No
Last_IO_Errno:0Last_IO_Error:
Last_SQL_Errno:0Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:2213306Master_UUID: 3e61e5be-7dff-11e9-8945-6c2b5992e632
Master_Info_File:/home/mysql-5.7.26/data/3307/master.infoSQL_Delay:0SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waitingfor more updates
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
同步线程都已经启动成功、
Exec_Master_Log_Pos: 154 同步主库日志文件偏移量跟主库的日志文件偏移量相同,说明已经完全同步
12、测试同步
在172.28.5.221上创建test库和test表,并插入一条记录
mysql>create database test;
Query OK,1 row affected (0.12sec)
mysql>show databases;+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+mysql>use test;
Database changed
mysql> create table test( uid int, name varchar(20));
Query OK,0 rows affected (0.43sec)
mysql> insert into test(uid,name)values(1,'aaaa');
Query OK,1 row affected (0.14sec)
mysql> select *from test;+------+------+
| uid | name |
+------+------+
| 1 | aaaa |
+------+------+
1 row in set (0.00 sec)
此时,在172.28.5.222上连接从库3307
[root@push-5-222 ~]# mysql -uroot -p -S /var/lib/mysql/3307/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connectionid is 5Server version:5.7.26MySQL 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 clearthe current input statement.
mysql>show databases;+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.00sec)
mysql>use test;
Reading table informationforcompletion 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 |
+----------------+
| test |
+----------------+
1 row in set (0.00sec)
mysql> select *from test;+------+------+
| uid | name |
+------+------+
| 1 | aaaa |
+------+------+
1 row in set (0.00 sec)
已经跟主库数据同步成功了。
同样在172.28.5.222上将3306配置文件打开
[mysqld]
#innodb_buffer_pool_size=128M
# join_buffer_size=128M
# sort_buffer_size=2M
# read_rnd_buffer_size=2M
user=mysql
port=3306datadir=/home/mysql-5.7.26/data/3306socket=/var/lib/mysql/3306/mysql.sock
server_id=2223306log-bin=master-222binlog_format=row
#skip-grant-tables
symbolic-links=0pid-file=/var/run/mysqld/3306/mysqld.pid
log-error=/home/mysql-5.7.26/log/3306/mysqld.log
[mysqld_safe]
log-error=/home/mysql-5.7.26/log/3306/mysqld.log
重启3306实例
[root@push-5-222 ~]# mysqladmin -uroot -p -S /var/lib/mysql/3306/mysql.sock shutdown
Enter password:
[root@push-5-222 ~]# mysqld_safe --defaults-file=/etc/mysql/my-3306.cnf &[2] 24587[root@push-5-222 ~]# 2019-05-27T03:29:21.804192Z mysqld_safe Logging to '/home/mysql-5.7.26/log/3306/mysqld.log'.2019-05-27T03:29:21.864191Z mysqld_safe Starting mysqld daemon with databases from /home/mysql-5.7.26/data/3306[root@push-5-222 ~]# mysql -uroot -p -S /var/lib/mysql/3306/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connectionid is 2Server version:5.7.26-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 clearthe current input statement.
mysql> show variables like '%server_id%';+----------------+---------+
| Variable_name | Value |
+----------------+---------+
| server_id | 2223306 |
| server_id_bits | 32 |
+----------------+---------+
2 rows in set (0.01sec)
mysql>show msater status\G;
ERROR1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'msater status' at line 1ERROR:
No query specified
mysql>show master status\G;*************************** 1. row ***************************File: master-222.000001Position:154Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set:1 row in set (0.00sec)
ERROR:
No query specified
显示主库状态
在172.28.5.223服务器上打开3307配置文件,将其设置为172.28.5.222的3306的从库
[root@push-5-223 ~]# vim /etc/mysql/my-3307.cnf
[mysqld]
# innodb_buffer_pool_size=128M
# join_buffer_size=128M
# sort_buffer_size=2M
# read_rnd_buffer_size=2M
user=mysql
port=3307datadir=/home/mysql-5.7.26/data/3307socket=/var/lib/mysql/3307/mysql.sock
server_id=2233307#log-bin=master-223#binlog_format=row
#skip-grant-tables
symbolic-links=0pid-file=/var/run/mysqld/3307/mysqld.pid
log-error=/home/mysql-5.7.26/log/3307/mysqld.log
[mysqld_safe]
log-error=/home/mysql-5.7.26/log/3307/mysqld.log
客户端连接,设置从库命令
[root@push-5-223 ~]# mysql -uroot -p -S /var/lib/mysql/3307/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connectionid is 3Server version:5.7.26MySQL 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 clearthe current input statement.
mysql> show variables like '%server_id%';+----------------+---------+
| Variable_name | Value |
+----------------+---------+
| server_id | 2233307 |
| server_id_bits | 32 |
+----------------+---------+
2 rows in set (0.00sec)
mysql>change master to-> master_host='172.28.5.222',-> master_port=3306,-> master_user='repl',-> master_password='xxxxxx',-> master_log_file='master-222.000001',-> master_log_pos=154;
Query OK,0 rows affected, 2 warnings (0.36 sec)
启动从库
mysql>start slave;
Query OK,0 rows affected (0.05sec)
mysql>show slave status\G;*************************** 1. row ***************************Slave_IO_State: Waitingformaster to send event
Master_Host:172.28.5.222Master_User: repl
Master_Port:3306Connect_Retry:60Master_Log_File: master-222.000001Read_Master_Log_Pos:154Relay_Log_File: push-5-223-relay-bin.000002Relay_Log_Pos:321Relay_Master_Log_File: master-222.000001Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:0Last_Error:
Skip_Counter:0Exec_Master_Log_Pos:154Relay_Log_Space:533Until_Condition: None
Until_Log_File:
Until_Log_Pos:0Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master:0Master_SSL_Verify_Server_Cert: No
Last_IO_Errno:0Last_IO_Error:
Last_SQL_Errno:0Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:2223306Master_UUID: de99b6b7-8018-11e9-9a45-6c2b5992e6d2
Master_Info_File:/home/mysql-5.7.26/data/3307/master.infoSQL_Delay:0SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waitingfor moreupdates
Master_Retry_Count:86400Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position:0Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
此时,从库已经启动,并且同步线程启动成功,同步完毕
测试数据
在172.28.5.222的3306上创建test库个test表,并插入一条数据
mysql>create database test;
Query OK,1 row affected (0.11sec)
mysql>use test;
Database changed
mysql> create table test (uid int,name varchar(20));
Query OK,0 rows affected (0.26sec)
mysql> insert into test values(1,'bbbb');
Query OK,1 row affected (0.15sec)
mysql> select *from test;+------+------+
| uid | name |
+------+------+
| 1 | bbbb |
+------+------+
1 row in set (0.00 sec)
此时,在172.28.5.223上连接3307从库
[root@push-5-223 ~]# mysql -uroot -p -S /var/lib/mysql/3307/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connectionid is 6Server version:5.7.26MySQL 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 clearthe current input statement.
mysql>use test;
Reading table informationforcompletion of table and column names
You can turn off this feature to get a quicker startup with-A
Database changed
mysql> select *from test;+------+------+
| uid | name |
+------+------+
| 1 | bbbb |
+------+------+
1 row in set (0.00 sec)
数据同步成功。
同样在172.28.5.223的3306和172.28.5.221的3307做主从配置
编辑172.28.5.223的3306配置文件
[root@push-5-223 ~]# vim /etc/mysql/my-3306.cnf
[mysqld]
# innodb_buffer_pool_size=128M
# join_buffer_size=128M
# sort_buffer_size=2M
# read_rnd_buffer_size=2M
user=mysql
port=3306datadir=/home/mysql-5.7.26/data/3306socket=/var/lib/mysql/3306/mysql.sock
server_id=2233306log-bin=master-223binlog_format=row
#skip-grant-tables
symbolic-links=0pid-file=/var/run/mysqld/3306/mysqld.pid
log-error=/home/mysql-5.7.26/log/3306/mysqld.log
[mysqld_safe]
log-error=/home/mysql-5.7.26/log/3306/mysqld.log
重启3306实例
[root@push-5-223 ~]# mysqladmin -uroot -p -S /var/lib/mysql/3306/mysql.sock shutdown
Enter password:
[root@push-5-223 ~]# mysqld_safe --defaults-file=/etc/mysql/my-3306.cnf &[2] 10352[root@push-5-223 ~]# 2019-05-27T03:46:18.899652Z mysqld_safe Logging to '/home/mysql-5.7.26/log/3306/mysqld.log'.2019-05-27T03:46:18.965604Z mysqld_safe Starting mysqld daemon with databases from /home/mysql-5.7.26/data/3306
^C
[root@push-5-223 ~]# mysql -uroot -p -S /var/lib/mysql/3306/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connectionid is 2Server version:5.7.26-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 clearthe current input statement.
mysql> show variables like'%server_id%';+----------------+---------+
| Variable_name | Value |
+----------------+---------+
| server_id | 2233306 |
| server_id_bits | 32 |
+----------------+---------+
2 rows in set (0.01sec)
mysql>show master status \G*************************** 1. row ***************************File: master-223.000001Position:154Binlog_Do_DB:
Binlog_Ignore_DB:
Executed_Gtid_Set:1 row in set (0.00 sec)
主库启动成功
在172.28.5.221的3307配置文件
[root@push-5-221 ~]# vim /etc/mysql/my-3307.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
# innodb_buffer_pool_size=128M
# join_buffer_size=128M
# sort_buffer_size=2M
# read_rnd_buffer_size=2M
user=mysql
port=3307datadir=/home/mysql-5.7.26/data/3307socket=/var/lib/mysql/3307/mysql.sock
server_id=2213307# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0log-error=/home/mysql-5.7.26/log/3307/mysqld.log
pid-file=/var/run/mysqld/3307/mysqld.pid
[myqld_safe]
log-error=/home/mysql-5.7.26/log/3307/mysqld.log
重启3307实例
[root@push-5-221 ~]# mysqladmin -uroot -p -S /var/lib/mysql/3307/mysql.sock shutdown
[root@push-5-221 ~]# mysqld_safe --defaults-file=/etc/mysql/my-3307.cnf &[2] 6725[root@push-5-221 ~]# 2019-05-27T03:49:31.427996Z mysqld_safe Logging to '/home/mysql-5.7.26/log/3307/mysqld.log'.2019-05-27T03:49:31.482868Z mysqld_safe Starting mysqld daemon with databases from /home/mysql-5.7.26/data/3307
^C
[root@push-5-221 ~]# mysql -uroot -p -S /var/lib/mysql/3307/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connectionid is 2Server version:5.7.26MySQL 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 clearthe current input statement.
mysql> show variables like '%server_id%';+----------------+---------+
| Variable_name | Value |
+----------------+---------+
| server_id | 2213307 |
| server_id_bits | 32 |
+----------------+---------+
2 rows in set (0.01 sec)
执行从库命令
mysql>change master to-> master_host='172.28.5.223',-> master_port=3306,-> master_user='repl',-> master_password='Zaq1xsw@',-> master_log_file='master-223.000001',-> master_log_pos=154;
Query OK,0 rows affected, 2 warnings (0.42sec)
mysql>start slave;
Query OK,0 rows affected (0.06sec)
mysql>
测试数据
在172.28.5.223的3306创建test库和test表,并插入一条记录
mysql>create database test;
Query OK,1 row affected (0.06sec)
mysql>use test;
Database changed
mysql> create table test(id int,name varchar(10));
Query OK,0 rows affected (0.34sec)
mysql> insert into test values(1,'ccc');
Query OK,1 row affected (0.14sec)
mysql> select *from test;+------+------+
| id | name |
+------+------+
| 1 | ccc |
+------+------+
1 row in set (0.00 sec)
在172.28.5.221的3307上查看
sion for the right syntax to use near 'database' at line 1mysql>show databases;+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.00sec)
mysql>use test;
Reading table informationforcompletion of table and column names
You can turn off this feature to get a quicker startup with-A
Database changed
mysql> select *from test;+------+------+
| id | name |
+------+------+
| 1 | ccc |
+------+------+
1 row in set (0.00 sec)
数据同步成功
至此3台MYSQL服务器互为主从设置完毕。
四、多实例的启动和停止
停止3306实例: mysqladmin -uroot -p -S /var/lib/mysql/3307/mysql.sock shutdown
启动3306实例: mysqld_safe --defaults-file=/etc/mysql/my-3306.cnf &
连接3306实例:mysql -uroot -p -S /var/lib/mysql/3306/mysql.sock