有关MySQL数据库复制的问题 - READ LOCK后的不同二进制日志坐标

时间:2012-10-13 20:52:46

标签: mysql locking replication

我即将复制一个频繁读/写的生产数据库。按照MySQL手册页上的说明,执行以下命令

mysql> FLUSH TABLES WITH READ LOCK;
Query OK, 0 rows affected (0.16 sec)

mysql> show master status;
+------------------+-----------+--------------+------------------+
| File             | Position  | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+-----------+--------------+------------------+
| mysql-bin.000061 | 717697391 |              |                  |
+------------------+-----------+--------------+------------------+
1 row in set (0.00 sec)

然后我通过执行以下命令开始我的备份过程

shell> mysqldump --lock-all-table --databases first second third -u root -p > dbdump.sql

然后我运行以下命令

mysql> show master status;
+------------------+-----------+--------------+------------------+
| File             | Position  | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+-----------+--------------+------------------+
| mysql-bin.000061 | 717697462 |              |                  |
+------------------+-----------+--------------+------------------+
1 row in set (0.00 sec)

mysql> show master status;
+------------------+-----------+--------------+------------------+
| File             | Position  | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+-----------+--------------+------------------+
| mysql-bin.000061 | 717697462 |              |                  |
+------------------+-----------+--------------+------------------+
1 row in set (0.00 sec)

如果在执行“READ LOCK”语句后表已被锁定,为什么两个连续的“show master status”命令中的坐标位置不同?我应该使用哪个位置值进行复制?

顺便说一句,我是否需要运行

mysql> UNLOCK TABLES;

备份过程后?或者当mysqldump完成时表将自动解锁。

1 个答案:

答案 0 :(得分:0)

如果您将mysqldump--lock-all-tables选项一起使用,mysqldump将在转储开始时发送FLUSH TABLES WITH READ LOCK,因此您无需手动执行此操作。