Posted
Filed under Computer/Linux
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
2015/04/15 05:43 2015/04/15 05:43
[로그인][오픈아이디란?]
Posted
Filed under Computer/Linux
Master     : 172.16.1.13
Slave       : 172.16.1.14
ID            : sync_adm
Password  : PassWord

Master)

[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;




Slave)
[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


If it have an issue :
mysql> slave stop;
mysql> set global sql_slave_skip_counter=1;
mysql> slave start;



Test)

Master)
mysql> use test
Database changed

mysql> create table aaa(a int,b char(20));
Query OK, 0 rows affected (0.00 sec)

mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| aaa |
+----------------+
1 rows in set (0.00 sec)


Slave)
This waiting meaning is good status =>
Slave_IO_State: Waiting for master to send event

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: 203
Relay_Log_File: mysql-relay-bin.000002
Relay_Log_Pos: 348
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: 203
Relay_Log_Space: 503
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> use test
Database changed

mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| aaa |
+----------------+
1 row in set (0.00 sec)
2015/04/14 04:46 2015/04/14 04:46
[로그인][오픈아이디란?]