Backing Up Archived Redo Logs with RMAN

本文详细介绍了Oracle数据库中RMAN工具如何处理归档日志备份,包括归档日志失败切换、在线重做日志切换及CDB环境下归档日志备份的特点。RMAN能够自动寻找可用的归档日志来完成备份任务,并确保备份过程中的数据一致性。

(一)About Archived Redo Log Failover

归档日志如果出现缺失或坏块RMAN会自动到其它归档日志路径找对应归档日志

The archived redo log failover feature enables RMAN to complete a backup even when some archiving destinations are missing logs or contain logs with corrupt blocks. If at least one log corresponding to a given log sequence and thread is available in the fast recovery area or any of the archiving destinations, then RMAN tries to back it up. If RMAN finds a corrupt block in a log file during backup, it searches other destinations for a copy of that log without corrupt blocks.

About Online Redo Log Switching

RMAN备份归档日志前均会先进行switch logfile

To make an open database backup of archived redo logs that includes the most recent online redo log, you can execute the BACKUP command with any of the following clauses:

PLUS ARCHIVELOG

ARCHIVELOG ALL

ARCHIVELOG FROM ...

Before beginning the backup, RMAN switches out of the current redo log group, and archives all online redo logs that have not yet been archived, up to and including the redo log group that was current when the command was issued. This feature ensures that the backup contains all redo generated before the start of the command.

在执行BACKUP ... PLUS ARCHIVELOG时步骤如下

An effective way of backing up archived redo logs is the BACKUP ... PLUS ARCHIVELOG command, which causes RMAN to do the following:

  1. Run the ALTER SYSTEM ARCHIVE LOG CURRENT statement.
  2. Run BACKUP ARCHIVELOG ALL. If backup optimization is enabled, then RMAN skips logs that it has already backed up to the specified device.
  3. Back up the rest of the files specified in the BACKUP command.
  4. Run the ALTER SYSTEM ARCHIVE LOG CURRENT statement.
  5. Back up any remaining archived logs generated during the backup. If backup optimization is not enabled, then RMAN backs up the logs generated in Step 1 plus all the logs generated during the backup.

The preceding steps guarantee that data file backups taken during the command are recoverable to a consistent state. Also, unless the online redo log is archived at the end of the backup, DUPLICATE is not possible with the backup.

About Backup of Archived Redo Logs in CDBs

CDB只能通过root在CDB$root中备份,PDB无法备份归档日志,原因就是在pdb你无法switch online log

In a CDB, archived redo logs can be backed up only when you connect to the root as a common user with the SYSDBA or SYSBACKUP privilege.

When you connect to a PDB as a local user with SYSDBA or SYSBACKUP privilege, you cannot back up or delete archived redo logs.

### 备份 MySQL 数据库的方法 为了备份 MySQL 数据库,可以采用多种方法来确保数据的安全性和可恢复性。以下是几种常见的备份方式: #### 使用 `mysqldump` 命令行工具 最常用的方式之一是通过命令行使用 `mysqldump` 工具来进行逻辑备份。这种方式会导出 SQL 脚本文件,其中包含了重建整个数据库所需的所有表结构和数据。 ```bash mysqldump -u username -p --all-databases > alldb.sql ``` 这条命令将会提示输入密码,并将所有数据库的内容保存到名为 `alldb.sql` 的文件中[^1]。 对于单个数据库,则可以用如下命令: ```bash mysqldump -u username -p dbname > dbbackup.sql ``` 这只会针对指定名称的数据库进行备份操作。 #### 物理备份 除了逻辑备份外,还可以考虑物理备份方案,比如直接复制数据库目录下的 `.frm`, `.ibd` 文件等。不过这种方法通常只适用于 MyISAM 存储引擎,在 InnoDB 中不推荐这样做因为可能会破坏事务一致性。 #### 自动化定期备份脚本 编写 shell 或者 Python 等编程语言编写的自动化脚本来定时执行上述提到的各种类型的备份工作是非常有必要的。这样不仅可以减少人工干预带来的风险,而且还能提高效率并保证备份频率的一致性。 ```python import os from datetime import date today = date.today().strftime("%Y%m%d") os.system(f"mysqldump -u root -ppassword databasename > /path/to/backup/{today}_dbbackup.sql") ``` 这段简单的Python代码实现了每日自动创建一个新的SQL转存文件,并按照日期命名以便管理和检索。 #### 使用第三方软件和服务 市场上有许多成熟的商业产品以及开源项目可以帮助简化这个过程,例如 Percona XtraBackup、AutoMySQLBackup 和 AWS RDS 提供的服务等等。这些解决方案往往提供了更高级别的功能支持,如增量备份、压缩传输等功能特性。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值