ÎÊÌâ´¦Àí½è¼øÖÁÍøÉϵÄÄÚÈÝ
ÖØÐÂ×öÖ÷´Ó£¬Íêȫͬ²½
ÔÚÖ÷¿âн¨Ò»Õűíºó£¬ÔÚslave ¶Î·¢ÏÖÊý¾ÝûÓÐͬ²½¹ýÈ¥¡£
mysql version£º5.6.10
os £ºrhel 5.6
?
½â¾ö²½ÖèÈçÏ£º
1.Ö÷¿â½øÐÐËø±í£¬·ÀÖ¹Êý¾ÝдÈë
mysql> flush tables with read lock;
?
½âËøÃüÁ
Mysql> unlock tables;
?
2.½øÐÐÊý¾Ý±¸·Ý £¬Êý¾Ý±¸·Ýµ½mysql.sqlÎļþ
#mysqldump -uroot -pmysql --all-databases > mysql.sql
?
3.²é¿´master ״̬
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position |Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000003 | 335 |test | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
?
4.°Ñmysql±¸·ÝÎļþ´«µ½´Ó¿â»úÆ÷£¬½øÐÐÊý¾Ý»Ö¸´
scp or ftp
?
5.Í£Ö¹´Ó¿âµÄ״̬
mysql> stop slave;
?
6.´Ó¿âµ¼ÈëÊý¾Ý±¸·Ý
mysql> source /lixora/mysql.sql£»
?
7.ÉèÖôӿâͬ²½£¬×¢Òâ¸Ã´¦µÄͬ²½µã£¬¾ÍÊÇÖ÷¿âshow master statusÐÅÏ¢ÀïµÄ| File| PositionÁ½Ïî
change master to
master_host='10.80.18.241', -----Ö÷¿âIPµØÖ·
master_user='root',
master_password='mysql',
master_port=3306,
master_log_file='mysql-bin.000003',
master_log_pos=335;
ÆäÖÐMASTER_HOSTÊÇmaster»úµÄip£¬
MASTER_USERºÍMASTER_PASSWORDÊÇÔÚmasterÉÏÌí¼ÓµÄÓû§£¬ÓÃÀ´¸´ÖƲÙ×÷µÄÓû§
MASTER_LOG_FILEºÍMASTER_LOG_POS¶ÔÓ¦Óëshow master statusÀïµÄÐÅÏ¢
?
8.ÖØÐ¿ªÆô´Óͬ²½
mysql> start slave;
?
9.²é¿´Í¬²½×´Ì¬
mysql> show slave status\G
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
?
ͬ²½²âÊÔ£º
¡¾master¡¿
mysql> use test;
Database changed
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| lixora |
| max |
| test |
+----------------+
3 rows in set (0.00 sec)
mysql> create table lixora_2015_0317 as select * from mysql.user;
Query OK, 5 rows affected (0.68 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> show tables;
+------------------+
| Tables_in_test |
+------------------+
| lixora |
| lixora_2015_0317 |
| max |
| test |
+------------------+
4 rows in set (0.00 sec)
mysql> select * from lixora_2015_0317;
¡£¡£¡£
5 rows in set (0.00 sec)
¡¾slave¡¿
mysql> use test
Database changed
mysql> show tables;
+------------------+
| Tables_in_test |
+------------------+
| lixora |
| lixora_2015_0317 |
| max |
| test |
+------------------+
4 rows in set (0.00 sec)
mysql> select count(*) from lixora_2015_0317;
+----------+
| count(*) |
+----------+
| 5 |
+----------+
1 row in set (0.06 sec)
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.80.18.241
Master_User: root
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000003
Read_Master_Log_Pos: 1166
Relay_Log_File: oracle11g-dag-relay-bin.000002
Relay_Log_Pos: 1114
Relay_Master_Log_File: mysql-bin.000003
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: 1166
Relay_Log_Space: 1295
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_