Oracle RMAN备份与还原

2024年 4月 25日 62.2k 0

RMAN在数据库服务器的帮助下实现数据库文件、控制文件、数据库文件与控制文件的映像副本、归档日志文件、数据库服务器参数文件的备份。

  RMAN的特点:

(1) 支持增量备份:传统的exp与expdp备份工具,只能实现一个完整备份而不能增量备份,RMAN采用备份级别实现增量备份,在一个完整的备份基础上采用增量备份可以大大减少备份的数量;

(2) 自动管理备份文件:RMAN备份的数据是RMAN自动管理的,包括文件名字,备份文件存储目录等;

(3) 自动化备份与恢复:在备份与恢复操作时,使用简单的指令就可以实现备份与恢复,执行过程完全有RMAN维护。

(4) 不产生重做信息: RMAN联机备份不产生重做信息。

(5) 支持映像复制: 使用RMAN可以实现映像复制,映像以操作系统的文件格式存在,这种复制类似于用户管理的脱机备份方式。

(6) 备份的数据文件压缩处理: RMAN提供一个参数,说明是否对备份文件进行压缩,压缩的备份文件以二进制文件格式存在,可以减少备份文件的存储空间。

(7) 备份文件有效性检查功能: 可以在备份之后恢复检测备份文件是否可用,避免无效恢复操作。

 

1 RMAN 脱机备份与还原

 

1.1 使用RMAN命令连接到数据库

[oracle@oracledb ~]$ rman target/

Recovery Manager: Release 11.2.0.1.0 - Production on Tue May 30 14:33:04 2017

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

connected to target database: ORCL (DBID=1452257309)

 

1.2 脱机备份之前确定数据库处于非归档模式下,使用管理员账号登录到数据库查看

SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 1
Current log sequence

 

1.3 脱机备份时数据必须处于mount状态下,关机启动数据库到mount状态下

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area 450953216 bytes
Fixed Size 2214256 bytes
Variable Size 339740304 bytes
Database Buffers 104857600 bytes
Redo Buffers 4141056 bytes
Database mounted.

 

1.4 RMAN模式下输入脱机备份命令,系统会自动备份整个数据库到默认的目录下

RMAN> backup as compressed backupset database;

Starting backup at 30-MAY-17
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/usr/oracle/app/oradata/orcl/CTRR_DATA.dbf
input datafile file number=00007 name=/home/oracle/data/CTRR_DATA_1.dbf
channel ORA_DISK_1: starting piece 1 at 30-MAY-17
channel ORA_DISK_1: finished piece 1 at 30-MAY-17
piece handle=/usr/oracle/app/flash_recovery_area/ORCL/backupset/2017_05_30/o1_mf_nnndf_TAG20170530T105100_dlsqjoft_.bkp tag=TAG20170530T105100 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:26
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00009 name=/home/oracle/data/rman_ts1.dbf
input datafile file number=00006 name=/usr/oracle/app/oradata/orcl/APSALU3_DATA.dbf
channel ORA_DISK_1: starting piece 1 at 30-MAY-17
channel ORA_DISK_1: finished piece 1 at 30-MAY-17
piece handle=/usr/oracle/app/flash_recovery_area/ORCL/backupset/2017_05_30/o1_mf_nnndf_TAG20170530T105100_dlsqmdbx_.bkp tag=TAG20170530T105100 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/usr/oracle/app/oradata/orcl/system01.dbf
input datafile file number=00004 name=/usr/oracle/app/oradata/orcl/users01.dbf
input datafile file number=00008 name=/home/oracle/data/default_tablespace.dbf
input datafile file number=00003 name=/usr/oracle/app/oradata/orcl/undotbs01.dbf
input datafile file number=00002 name=/usr/oracle/app/oradata/orcl/sysaux01.dbf
channel ORA_DISK_1: starting piece 1 at 30-MAY-17
channel ORA_DISK_1: finished piece 1 at 30-MAY-17
piece handle=/usr/oracle/app/flash_recovery_area/ORCL/backupset/2017_05_30/o1_mf_nnndf_TAG20170530T105100_dlsqmfgv_.bkp tag=TAG20170530T105100 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:26
Finished backup at 30-MAY-17

 

Starting Control File and SPFILE Autobackup at 30-MAY-17
piece handle=/usr/oracle/app/flash_recovery_area/ORCL/autobackup/2017_05_30/o1_mf_s_945338539_dlsqp4yv_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 30-MAY-17

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论