[email protected][(none)]> grant replication slave on *.* to ‘repl‘@‘192.168.1.177‘ identified by ‘xxx‘; Query OK, 0 rows affected (0.01 sec) --全局读锁 [email protected][(none)]> flush tables with read lock; Query OK, 0 rows affected (0.02 sec) [email protected][(none)]> system pwd /data/inst3406 --获取master binlog位置 [email protected][(none)]> show master status; +--------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +--------------------+----------+--------------+------------------+-------------------+ | inst3406bin.000001 | 2169 | | | | +--------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec) --使用mysqldump导出实例 [email protected][(none)]> system mysqldump -uroot -pxxx -S /tmp/mysql3406.sock --routines --all-databases --opt >alldb.sql [email protected][(none)]> system ls alldb.sql data3406 --解锁 [email protected][(none)]> unlock tables; [email protected][(none)]> exit --从库上面导入dump [[email protected] inst3406]$ mysql -uroot -pxxx -S /tmp/mysql3506.sock <alldb.sql --从库上设置主库的相关信息(host,port等等) [[email protected] inst3506]$ mysqls [email protected][(none)]> change master to -> MASTER_HOST=‘192.168.1.177‘, -> MASTER_USER=‘repl‘, -> MASTER_PASSWORD=‘xxx‘, -> MASTER_PORT=3406, -> MASTER_LOG_FILE=‘inst3406bin.000001‘, -> MASTER_LOG_POS=2169; Query OK, 0 rows affected, 2 warnings (0.01 sec) --启动slave [email protected][(none)]> start slave;
部分从库
[email protected][(none)]> grant replication slave on *.* to ‘repl‘@‘192.168.1.177‘ identified by ‘xxx‘; Query OK, 0 rows affected (0.01 sec) --全局读锁 [email protected][(none)]> flush tables with read lock; Query OK, 0 rows affected (0.02 sec) [email protected][(none)]> system pwd /data/inst3406 --获取master binlog位置 [email protected][(none)]> show master status; +--------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +--------------------+----------+--------------+------------------+-------------------+ | inst3406bin.000001 | 2169 | | | | +--------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec) --使用mysqldump导出实例 [email protected][(none)]> system mysqldump -uroot -pxxx -S /tmp/mysql3406.sock --routines --all-databases --opt >alldb.sql [email protected][(none)]> system ls alldb.sql data3406 --解锁 [email protected][(none)]> unlock tables; [email protected][(none)]> exit --从库上面导入dump [[email protected] inst3406]$ mysql -uroot -pxxx -S /tmp/mysql3506.sock <alldb.sql --从库上设置主库的相关信息(host,port等等) [[email protected] inst3506]$ mysqls [email protected][(none)]> change master to -> MASTER_HOST=‘192.168.1.177‘, -> MASTER_USER=‘repl‘, -> MASTER_PASSWORD=‘xxx‘, -> MASTER_PORT=3406, -> MASTER_LOG_FILE=‘inst3406bin.000001‘, -> MASTER_LOG_POS=2169; Query OK, 0 rows affected, 2 warnings (0.01 sec) --启动slave [email protected][(none)]> start slave;
时间: 2024-10-09 06:13:47