`
Openhearted
  • 浏览: 29702 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

RMAN备份基本用法

    博客分类:
  • Java
阅读更多

一. 创建RMAN CATALOG
      RMAN 可以之用控制文件来存储RMAN的备份metadata, 也可以配置CATALOG来存储RMAN的备份信息. 一般来说最好在另一数据库上配置CATALOG来管理RMAN备份信息,这样当所有的控制文件都无效的时候还可以保证用CATALOG来重建控制文件和数据库.
    1).SQL> create tablespace rmantbs datafile '/data/oradata/orcl/rmantbs01.dbf' size 50M
                     autoextend on next 5M maxsize 200M
                     extent management local
                     segment space management auto;

     2).SQL> create user rman identified by oracle
                      default tablespace rmantbs
                      temporary tablespace temp
                      quota unlimited on rmantbs;

     3).SQL> grant create session, recovery_catalog_owner to rman;

     4).$ rman catalog rman/oracle
           RMAN> create catalog tablespace rmantbs;
           RMAN> connect target /
           RMAN> register database;

二. 配置RMAN
RMAN> show all;
RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET PARALLELISM 1;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BZIP2'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.1.0/db_1/dbs/snapcf_orcl.f'; # default

1. 配置保留策略retention policy
    RMAN有两种保留策略:DEDUNDANCY(默认值为1)和 RECOVERY WINDOW
    1.1) 配置保留2份冗余备份
RMAN> configure retention policy to redundancy 2;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

   1.2) 配置保留策略为7天
     RMAN> configure retention policy to recovery window of 7 days;
old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

2. 配置优化的备份
   RMAN> configure backup optimization on;
new RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

3. 配置默认的设备类型
    默认的设备类型为DISK硬盘,配置默认的设备类型为TAPE磁带
    RMAN> configure default device type to sbt;
new RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

4. 配置自动控制文件和SPFILE备份
   RMAN> configure controlfile autobackup on;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

5. 配置自动控制文件和SPFILE备份的格式
    默认是备份到DB_RECOVERY_FILE_DEST/$ORACLE_SID/autobackup/$date目录,格式为'%F'
    注: 格式必须包含'%F'
RMAN> configure controlfile autobackup format for device type disk to '/u01/app/oracle/admin/orcl/controlfile/ctl_%F';
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/oracle/admin/orcl/controlfile/ctl_%F';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

6. 配置默认产生备份集还是拷贝COPY
   6.1 配置备份类型为COPY
RMAN> configure device type disk backup type to copy;
old RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET PARALLELISM 1;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY PARALLELISM 1;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

6.2 配置并行度PARALLELISM
RMAN> configure device type disk backup type to backupset parallelism 2;
old RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY PARALLELISM 1;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET PARALLELISM 2;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN> configure device type sbt_tape backup type to backupset parallelism 2;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE 'SBT_TAPE' BACKUP TYPE TO BACKUPSET PARALLELISM 2;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete
注: 如果配置磁带设备的PARALLELISM,必须配置磁带的个数等于PARALLELISM的个数,否则报错.

6.3 配置默认压缩备份(注如果用压缩备份必须配置WALLET并OPEN)
RMAN> configure device type disk backup type to compressed backupset;
old RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET PARALLELISM 2;
new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 2;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

7. 配置渠道CHANNEL
RMAN> configure channel device type disk format '/bakup/rman/orcl/%d_%s_%p_%t';
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/bakup/rman/orcl/%d_%s_%p_%t';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

8. 配置加密和加密算法
    RMAN 加密可以采用TRANSPARANT Data encryption(TDE)加密和密码加密两种方法. TDE的算法有:AES128(默认值), AES192, AES256等. 备份和恢复时都需要WALLET打开状态.
RMAN> configure encryption for database on;
new RMAN configuration parameters:
CONFIGURE ENCRYPTION FOR DATABASE ON;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN> configure encryption algorithm 'AES256';
new RMAN configuration parameters:
CONFIGURE ENCRYPTION ALGORITHM 'AES256';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

参考实例: http://users.telenet.be/oraguy.be/encryption1.htm

查看配置结果:
RMAN> show all;
RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE';
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/app/oracle/admin/orcl/controlfile/ctl_%F';
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE SBT_TAPE TO '%F'; # default
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 2;
CONFIGURE DEVICE TYPE 'SBT_TAPE' BACKUP TYPE TO BACKUPSET PARALLELISM 2;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE SBT_TAPE TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/bakup/rman/orcl/%d_%s_%p_%t';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE ON;
CONFIGURE ENCRYPTION ALGORITHM 'AES256';
CONFIGURE COMPRESSION ALGORITHM 'BZIP2'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.1.0/db_1/dbs/snapcf_orcl.f'; # default

三. 创建存储的备份脚本
1. 基本0的增量备份
create script. b_whole_inc0{
backup
incremental level 0 database
format '/bakup/rman/backup/orcl/db0_%d_%s_%p_%t'
tag = 'WHOLE_INC0';
}

2. 基本1的增量备份
create script. b_whole_inc1{
backup
incremental level 1 cumulative database
format '/bakup/rman/backup/orcl/db1_%d_%s_%p_%t'
tag='WHOLE_INC1';
}

3. 基本2的增量备份
create script. b_whole_inc2{
backup
incremental level 2 cumulative database
format '/bakup/rman/backup/orcl/db2_%d_%s_%p_%t'
tag='WHOLE_INC2';
}

4. 归档当前的重做日志组
create script. archive_log_current{
sql "ALTER SYSTEM ARCHIVE LOG CURRENT";
}

5. 备份前两天的归档日志
create script. b_archive_2days{
execute script. archive_log_current;
backup archivelog from time 'SYSDATE-2'
format '/bakup/rman/backup/orcl/ar_%d_%s_%p_%t';
}

6. 备份大前天的归档日志并删除
create script. archive_delete3{
execute script. archive_log_current;
backup archivelog from time 'SYSDATE-3' until time 'SYSDATE-2'
format '/bakup/rman/backup/orcl/ar_%d_%s_%p_%t'
delete input;
}

7. 备份类型为COPY
run{
    allocate channel d1 type disk;
    copy
    datafile 1 to '/bakup/rman/backup/orcl/system01.dbf.bak',
    datafile 2 to '/bakup/rman/backup/orcl/undotbs01.dbf.bak',
    datafile 3 to '/bakup/rman/backup/orcl/sysaux01.dbf.bak',
    datafile 4 to '/bakup/rman/backup/orcl/users01.dbf.bak',
    datafile 5 to '/bakup/rman/backup/orcl/example01.dbf.bak',
    datafile 6 to '/bakup/rman/backup/orcl/rmantbs01.dbf.bak',
    current controlfile to '/bakup/rman/backup/orcl/control_bakup.ctl';
}

or

run{
      backup as copy database;
}

8. 备份增量基本为0的数据库备份和所有的归档日志
run{
    allocate channel c1 type disk;
    backup incremental level 0 database
    format '/bakup/rman/backup/orcl/db_%d_%s_%p_%t'
    tag = 'WHOLE_INC0'
    archivelog all
    format '/bakup/rman/backup/orcl/ar_%d_%s_%p_%t'
    tag 'BACKUP_ARCHIVELOG_ALL';
}


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/sopost/archive/2009/10/27/4734395.aspx

分享到:
评论

相关推荐

    oracle10g 使用RMAN备份初学者指南

    总结,Oracle 10g的RMAN是数据库管理的重要工具,掌握其使用方法对于保障数据安全至关重要。通过理解RMAN的基础知识、备份类型、恢复操作以及最佳实践,初学者可以逐步熟练地进行数据库的备份和恢复工作,为企业的...

    RMAN备份与恢复

    ### RMAN备份与恢复知识点详解 #### 一、进入RMAN **1.1 连接本地数据库** 在Oracle环境中,可以通过以下两种方式连接到本地数据库: - 直接输入`rman target /` - 或者简写为`rman` 这种方式会提示用户输入...

    Oracle数据库RMAN备份与恢复.pdf

    RMAN备份特点是跳过未使用的数据块,使用Oracle特有的二进制压缩模式,能够最大程度地压缩数据块中的典型数据。 定制备份策略正确的备份策略不仅能保证数据库服务器高效率高性能的运行和使用,还能确保恢复与备份的...

    RMAN备份技术解决方案.pdf

    RMAN备份技术解决方案 RMAN(Recovery Manager)是一种强大的数据库备份工具,由 Oracle 公司提供,用于保护和恢复 Oracle 数据库。该解决方案旨在提供一个完整的 RMAN 备份方案,涵盖了 Linux/AIX 和 Windows 等...

    Rman备份与恢复

    ### RMAN备份与恢复知识点详解 #### 一、概述 RMAN(Recovery Manager)是...以上介绍了RMAN的一些基本使用方法和操作,这些命令和步骤对于数据库管理员来说非常重要,可以帮助他们在数据库出现故障时有效地进行恢复。

    oracle11g_rman备份还原初步方案(20190524).docx

    ### Oracle 11g RMAN备份与恢复初步方案解析 #### 一、RMAN备份与恢复概述 **RMAN(Recovery Manager)**是Oracle提供的一种强大工具,主要用于数据库的备份、还原及恢复操作。RMAN支持从Oracle 8及更高版本的...

    Oracle 12c备份恢复-RMAN工具技术手册

    本文档旨在提供 Oracle 12c 备份恢复的技术手册,主要介绍 RMAN 工具的概念、架构、备份类型和使用方法。 一、RMAN 概念 RMAN(Recovery Manager)是 Oracle 推荐的备份和恢复工具。使用 RMAN 可以进行数据库备份...

    Oracle Database 11g RMAN备份与恢复

    本书《Oracle Database 11g RMAN备份与恢复》不仅对前一版本的内容进行了修订,也增加了许多新内容,以帮助读者掌握最新的RMAN使用方法。 在学习RMAN之前,需要对Oracle数据库的基础备份与恢复有所了解。Oracle...

    Oracle数据库RMAN备份与恢复技术

    ### Oracle数据库RMAN备份与恢复技术详解 #### 引言 在信息技术领域,数据安全与完整性至关重要。Oracle数据库,作为全球领先的数据库管理系统之一,提供了多种数据保护机制,其中RMAN(Recovery Manager,恢复...

    完整Oracle rman备份恢复成功案例

    本文将详细介绍完整的 Oracle RMAN 备份恢复步骤,并提供实践案例,以帮助读者更好地理解 RMAN 的使用方法。 Step 1: 创建 RMAN 库作为 Repository 在开始备份恢复之前,需要创建 RMAN 库作为Repository,用于...

    rman的基本概念及备份和恢复

    #### 二、RMAN备份与恢复过程 - **备份集和镜像副本**:根据需求选择合适的备份类型(备份集或镜像副本),并确定备份的范围(如整个数据库或特定表空间)。 - **增量备份**:定义增量备份的级别和频率,确保能够...

    RMAN管理的备份和恢复.pdf

    6. **初始化参数调整**: 使用RMAN备份时,可能需要调整初始化参数,如`sessions`和`processes`,以确保有足够的资源供RMAN及其通道使用。 #### 四、RMAN备份流程详解 - **备份过程**: RMAN读取控制文件获取待备份...

    ORACLE RMAN备份恢复指南

    本文旨在为瑞航公司当前所使用的Oracle RMAN备份恢复机制提供详尽的指导,涵盖全量备份、增量备份、数据恢复等多个方面,尤其关注于数据丢失、控制文件丢失、参数文件丢失、密码文件丢失、redo文件丢失以及表空间...

    rman备份与恢复实例

    本文详细介绍了RMAN备份与恢复的各种操作方法和技术要点,涵盖了基础操作、备份策略、恢复操作以及操作模式等方面的内容。RMAN作为Oracle数据库管理的重要工具,其深入理解和熟练掌握对于确保数据库的安全稳定运行至...

    Oracle数据库RMAN备份

    ### Oracle数据库RMAN备份知识点详解 #### 一、RMAN简介 RMAN(Recovery Manager)是Oracle...综上所述,掌握RMAN的使用方法对于Oracle DBA来说是非常重要的,它能够帮助DBA们有效地管理和保护数据库中的宝贵数据。

    oracle rman备份脚本

    在Oracle数据库管理中,RMAN备份脚本的编写是至关重要的,因为它确保了数据的安全性和可恢复性。 标题"oracle rman备份脚本"指出我们要讨论的是如何利用RMAN来创建数据库的备份脚本。这个脚本通常包含了备份的配置...

    Oracle数据库RMAN备份策略研究

    本文以Oracle数据库为例,重点探讨了RMAN(Recovery Manager)备份工具的使用方法及其备份策略,旨在为Oracle数据库的稳定运行提供保障。 #### 关键词 Oracle, 备份策略, RMAN #### 引言 数据库作为企业核心资产之...

Global site tag (gtag.js) - Google Analytics