Setting Replica Configuration

Link: https://dev.mysql.com/doc/refman/8.0/en/replication-howto-slavebaseconfig.html

-- db01
mysql> SET GLOBAL server_id = 1;
$ vim /etc/my.cnf
[mysqld]
server-id=1

-- db02
mysql> SET GLOBAL server_id = 2;
$ vim /etc/my.cnf
[mysqld]
server-id=2

Create Replica User

Link: https://dev.mysql.com/doc/refman/8.0/en/replication-howto-repuser.html

mysql> CREATE USER 'repl'@'<SOURCE IP ADDR>' IDENTIFIED BY 'password';
mysql> GRANT REPLICATION SLAVE ON *.* TO 'repl'@'<SOURCE IP ADDR>';

CHANGE REPLICATION SOURCE TO

Link: https://dev.mysql.com/doc/refman/8.0/en/replication-howto-slaveinit.html

-- db01
mysql> show master status \G
*************************** 1. row ***************************
             File: mysql-bin.000003
         Position: 447
     Binlog_Do_DB:
 Binlog_Ignore_DB:
Executed_Gtid_Set:

-- db02
mysql> show master status \G
*************************** 1. row ***************************
             File: mysql-bin.000002
         Position: 154
     Binlog_Do_DB:
 Binlog_Ignore_DB:
Executed_Gtid_Set:

-- db01
mysql> CHANGE REPLICATION SOURCE TO
    ->     SOURCE_HOST='db02',
    ->     SOURCE_USER='repl',
    ->     SOURCE_PASSWORD='password',
    ->     SOURCE_LOG_FILE='mysql-bin.000002',
    ->     SOURCE_LOG_POS=154;
mysql> start replica;
mysql> show replica status \G

-- db02
mysql> CHANGE REPLICATION SOURCE TO
    ->     SOURCE_HOST='db01',
    ->     SOURCE_USER='repl',
    ->     SOURCE_PASSWORD='password',
    ->     SOURCE_LOG_FILE='mysql-bin.000003',
    ->     SOURCE_LOG_POS=447;
mysql> start replica;
mysql> show replica status \G
profile
DataBase Administrator

0개의 댓글

Powered by GraphCDN, the GraphQL CDN