Master1    : 172.16.1.13
Master2    : 172.16.1.14
ID            : sync_adm
Password  : PassWord


Master1)

[root@sql1 ~]# cat /etc/my.cnf

[mysqld]
server-id=1
binlog-format=mixed
log-bin=mysql-bin
binlog-do-db=test
sync_binlog=1


mysql> CREATE USER sync_adm@172.16.1.14;
mysql> GRANT REPLICATION SLAVE ON *.* TO sync_adm@172.16.1.14 IDENTIFIED BY 'PassWord';
[root@sql1 ~]# mysqldump -uroot -p --skip-lock-tables --single-transaction --flush-logs --hex-blob --master-data=2 --events -A > ~/dump.sql

[root@sql1 ~]# head dump.sql -n80 | grep "MASTER_LOG_POS"
-- CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000007', MASTER_LOG_POS=106;




Master2)
[root@sql2 ~]# cat /etc/my.cnf
[mysqld]
server-id=2
binlog-format=mixed
log-bin=mysql-bin
relay-log=mysql-relay-bin
log-slave-updates=1
#read-only=1                     # or comment out this read-only option.
replicate-do-db=test

[root@sql2 ~]# /etc/init.d/mysqld restart

[root@sql2 ~]# mysql -uroot -p < dump.sql

mysql> CHANGE MASTER TO MASTER_HOST='172.16.1.13', MASTER_USER='sync_adm', MASTER_PASSWORD='PassWord', MASTER_LOG_FILE='mysql-bin.000007', MASTER_LOG_POS=106;

mysql> start slave;

mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.16.1.13
Master_User: sync_adm
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000007
Read_Master_Log_Pos: 106
Relay_Log_File: mysql-relay-bin.000002
Relay_Log_Pos: 251
Relay_Master_Log_File: mysql-bin.000007
Slave_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: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 106
Relay_Log_Space: 406
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)

ERROR:
No query specified


mysql> CREATE USER sync_adm@172.16.1.13;
mysql> GRANT REPLICATION SLAVE ON *.* TO sync_adm@172.16.1.13 IDENTIFIED BY 'PassWord';



Master1)
mysql> CHANGE MASTER TO MASTER_HOST='172.16.1.14', MASTER_USER='sync_adm', MASTER_PASSWORD='PassWord', MASTER_LOG_FILE='mysql-bin.000007', MASTER_LOG_POS=106;

mysql> start slave;

mysql> show slave status \G;

*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.16.1.14
Master_User: sync_adm
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000008
Read_Master_Log_Pos: 206
Relay_Log_File: mysql-relay-bin.000002
Relay_Log_Pos: 251
Relay_Master_Log_File: mysql-bin.000008
Slave_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: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 206
Relay_Log_Space: 406
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)

ERROR:
No query specified
크리에이티브 커먼즈 라이센스
Creative Commons License
받은 트랙백이 없고, 댓글이 없습니다.

댓글+트랙백 RSS :: http://www.cep.kr/blog/cep/rss/response/287

댓글+트랙백 ATOM :: http://www.cep.kr/blog/cep/atom/response/287