mysqldump at replica master

MySQL , , , , , ,


mysqldump --master-data=1 --all-databases > all-databases.sql


–master-data:当值为0时,什么也不做。当值为1时,在SQL中自动加上CHANGE MASTER命令,当值为2时自动加上CHANGE MASTER命令,但是被注释的,导入时并不会自动执行。启用这个参数时如果没有启用–single-transaction,就会自动启用–lock-all-tables,当然了–lock-tables永远都是关闭的。

-x, --lock-all-tables
                      Locks all tables across all databases. This is achieved
                      by taking a global read lock for the duration of the
                      whole dump. Automatically turns --single-transaction and
                      --lock-tables off.
  --master-data[=#]   This causes the binary log position and filename to be
                      appended to the output. If equal to 1, will print it as a
                      CHANGE MASTER command; if equal to 2, that command will
                      be prefixed with a comment symbol. This option will turn
                      --lock-all-tables on, unless --single-transaction is
                      specified too (in which case a global read lock is only
                      taken a short time at the beginning of the dump; don't
                      forget to read about --single-transaction below). In all
                      cases, any action on logs will happen at the exact moment
                      of the dump. Option automatically turns --lock-tables

Leave a Reply