mysql在从库备份制作新从库

在已经存在的主从结构中,如果想要新添加从库,可以在主库上dump出备份在制作新从库,也可以在之前的从库上做备份,使用从库的备份制作新从库。
/usr/local/mysql-5.7.18/bin/mysqldump -u root -S /my.sock -p–default-character-set=utf8 –single-transaction –include-master-host-port=true –dump-slave=2 baixyu>baixyu.sql

使用这个命令在制作备份的时候,从库上的同步会中断,在备份完成后,会继续正常同步。对于dump-slave的说明
–dump-slave[=#] This causes the binary log position and filename of the
master to be appended to the dumped data output. Setting
the value to 1, will printit as a CHANGE MASTER command
in the dumped data output; 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 off.

–single-transaction
Creates a consistent snapshot by dumping all tables in a
single transaction. Works ONLY for tables stored in
storage engines which support multiversioning (currently
only InnoDB does); the dump is NOT guaranteed to be
consistent for other storage engines. While a
–single-transaction dump is in process, to ensure a
valid dump file (correct table contents and binary log
position), no other connection should use the following
statements: ALTER TABLE, DROP TABLE, RENAME TABLE,
TRUNCATE TABLE, as consistent snapshot is not isolated
from them. Option automatically turns off –lock-tables.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值