要将复制用作备份解决方案,请将数据从源复制到副本,然后备份副本。副本可以暂停并关闭而不影响源的正常运行,因此您可以生成“实时” data that would otherwise require the source to be shut down.To use replication as a backup solution, replicate data from the source to a replica, and then back up the replica. The replica can be paused and shut down without affecting the running operation of the source, so you can produce an effective snapshot of “live” data that would otherwise require the source to be shut down.
如何备份数据库取决于其大小,以及您是仅备份数据,还是备份数据和副本状态,以便在发生故障时可以重建副本。因此有两种选择:How you back up a database depends on its size and whether you are backing up only the data, or the data and the replica state so that you can rebuild the replica in the event of failure. There are therefore two choices:
如果您正在使用复制作为一种解决方案,以便能够备份源上的数据,并且您的数据库大小不是很大,mysqldump 工具可能适用。请参见 第 19.4.1.1 节,“使用 mysqldump 备份副本”。If you are using replication as a solution to enable you to back up the data on the source, and the size of your database is not too large, the mysqldump tool may be suitable. See Section 19.4.1.1, “Backing Up a Replica Using mysqldump”.
对于较大的数据库,当 mysqldump 不切实际或效率低下时,您可以备份原始数据文件。使用原始数据文件选项还意味着您可以备份二进制日志和中继日志,从而在副本发生故障时可以重建副本。有关更多信息,请参见 第 19.4.1.2 节,“从副本备份原始数据”。For larger databases, where mysqldump would be impractical or inefficient, you can back up the raw data files instead. Using the raw data files option also means that you can back up the binary and relay logs that make it possible to re-create the replica in the event of a replica failure. For more information, see Section 19.4.1.2, “Backing Up Raw Data from a Replica”.
另一种备份策略,可用于源服务器或副本服务器,是将服务器置于只读状态。备份是在只读服务器上执行的,然后服务器恢复到通常的读/写操作状态。请参见第 19.4.1.3 节,“通过将源或副本设置为只读来备份”。Another backup strategy, which can be used for either source or replica servers, is to put the server in a read-only state. The backup is performed against the read-only server, which then is changed back to its usual read/write operational status. See Section 19.4.1.3, “Backing Up a Source or Replica by Making It Read Only”.