[root@db03 ~]# sh multisource_env.sh
----- init mysql -----
2020-04-23T09:31:44.655575Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation formore details).
2020-04-23T09:31:44.835648Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-04-23T09:31:44.871478Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-04-23T09:31:44.927662Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 3f4a0c4e-8545-11ea-b265-02000aba3d09.
2020-04-23T09:31:44.928659Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-04-23T09:31:44.929158Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2020-04-23T09:31:46.839819Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation formore details).
2020-04-23T09:31:47.014100Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-04-23T09:31:47.047423Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-04-23T09:31:47.103188Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 40960162-8545-11ea-b2ea-02000aba3d09.
2020-04-23T09:31:47.104036Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-04-23T09:31:47.104698Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2020-04-23T09:31:48.987927Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation formore details).
2020-04-23T09:31:49.138326Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-04-23T09:31:49.168599Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-04-23T09:31:49.225036Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 41d9c677-8545-11ea-b44d-02000aba3d09.
2020-04-23T09:31:49.225900Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-04-23T09:31:49.226466Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
----- start mysql -----
----- sleep 10s -----
----- create replication slave user -----
----- Done -----
[root@db03 ~]# netstat -tunpl |grep mysqld
tcp 0 0 0.0.0.0:3311 0.0.0.0:* LISTEN 2842/mysqld
tcp 0 0 0.0.0.0:3312 0.0.0.0:* LISTEN 2845/mysqld
tcp 0 0 0.0.0.0:3313 0.0.0.0:* LISTEN 2848/mysqld
在3313实例对3311/3312创建主从连接信息
也就是说3313实例同时做3311和3312两个实例的从库。(注意:两个主库不要搞冲突的数据)
[root@db03~]# mysql -P 3313
Welcome to the MySQL monitor. Commands endwith;or \g.
Your MySQL connection id is2
Server 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.
root@localhost[(none)]> prompt 3313>;
PROMPT setto'3313 >'3313>3313>CHANGE MASTER TO-> MASTER_HOST='127.0.0.1',-> MASTER_USER='repl',-> MASTER_PASSWORD='oracle',-> MASTER_PORT=3311,-> MASTER_CONNECT_RETRY=10,-> MASTER_AUTO_POSITION=1->FOR CHANNEL 'master1';
Query OK,0rows affected,2warnings(0.01 sec)3313>CHANGE MASTER TO-> MASTER_HOST='127.0.0.1',-> MASTER_USER='repl',-> MASTER_PASSWORD='oracle',-> MASTER_PORT=3312,-> MASTER_CONNECT_RETRY=10,-> MASTER_AUTO_POSITION=1->FOR CHANNEL 'master2';
Query OK,0rows affected,2warnings(0.00 sec)3313>start slave for channel 'master1';
Query OK,0rows affected (0.01 sec)3313>start slave for channel 'master2';
Query OK,0rows affected (0.01 sec)