0

我即将复制一个频繁读/写的生产数据库。按照 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 完成时,表将自动解锁。

4

1 回答 1

0

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

于 2012-10-13T22:32:03.507 回答