文档章节

oracle 用rman 备份

胡子叭槎
 胡子叭槎
发布于 2017/04/06 23:50
字数 2018
阅读 36
收藏 1
  1. 全量备份
    backup database;可以全量备份 数据文件,参数文件,控制文件
    RMAN> backup database;
    
    Starting backup at 06-APR-17
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=146 device type=DISK
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    input datafile file number=00001 name=/u01/oracle/oradata/orcl/system01.dbf
    input datafile file number=00002 name=/u01/oracle/oradata/orcl/sysaux01.dbf
    input datafile file number=00003 name=/u01/oracle/oradata/orcl/undotbs01.dbf
    input datafile file number=00005 name=/u01/oracle/oradata/orcl/user02.dbf
    input datafile file number=00006 name=/u01/oracle/oradata/orcl/tmpspace0327
    input datafile file number=00004 name=/u01/oracle/oradata/orcl/users01.dbf
    channel ORA_DISK_1: starting piece 1 at 06-APR-17
    channel ORA_DISK_1: finished piece 1 at 06-APR-17
    piece handle=/tmp/0ds11ob8_1_1 tag=TAG20170406T221256 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:01:46
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    including current control file in backup set
    including current SPFILE in backup set
    channel ORA_DISK_1: starting piece 1 at 06-APR-17
    channel ORA_DISK_1: finished piece 1 at 06-APR-17
    piece handle=/tmp/0es11oej_1_1 tag=TAG20170406T221256 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 06-APR-17
    

     

  2. 参数文件备份
    backup spfile;
    
    RMAN> backup spfile;
    
    Starting backup at 06-APR-17
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=146 device type=DISK
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    including current SPFILE in backup set
    channel ORA_DISK_1: starting piece 1 at 06-APR-17
    channel ORA_DISK_1: finished piece 1 at 06-APR-17
    piece handle=/tmp/0fs11p18_1_1 tag=TAG20170406T222440 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 06-APR-17
    

    backup spfile format '/tmp/spfile.bkp';
    RMAN> backup spfile format '/tmp/20170406spfile.bkp';
    
    Starting backup at 06-APR-17
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    including current SPFILE in backup set
    channel ORA_DISK_1: starting piece 1 at 06-APR-17
    channel ORA_DISK_1: finished piece 1 at 06-APR-17
    piece handle=/tmp/20170406spfile.bkp tag=TAG20170406T222553 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 06-APR-17
    

     

  3. 控制文件备份
    backup current controlfile;
    控制文件有多个,但是当前使用的只有1个,所以要备份当前使用的控制文件才有效
    RMAN> backup current controlfile;
    
    Starting backup at 06-APR-17
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    including current control file in backup set
    channel ORA_DISK_1: starting piece 1 at 06-APR-17
    channel ORA_DISK_1: finished piece 1 at 06-APR-17
    piece handle=/tmp/0hs11phs_1_1 tag=TAG20170406T223332 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 06-APR-17
    

    backup current controlfile format '/tmp/20170406controlfile.bkp';
    RMAN> backup current controlfile format '/tmp/20170406controlfile.bkp';
    
    Starting backup at 06-APR-17
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    including current control file in backup set
    channel ORA_DISK_1: starting piece 1 at 06-APR-17
    channel ORA_DISK_1: finished piece 1 at 06-APR-17
    piece handle=/tmp/20170406controlfile.bkp tag=TAG20170406T223744 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 06-APR-17
    
  4. 拷贝式备份文件
    backup 备份文件式备份的更新的block。还有一种方式就是backup as copy current controlfile; 相当于直接被文件用scp拷贝了一份。

    RMAN> backup as copy current controlfile;
    
    Starting backup at 06-APR-17
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting datafile copy
    copying current control file
    output file name=/tmp/cf_D-ORCL_id-1461163151_0ks11q2h tag=TAG20170406T224225 RECID=5 STAMP=940632145
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
    Finished backup at 06-APR-17
    

     

  5. 数据文件备份
    数据文件的备份可以在backup database;中备份这里就不多少了,下面主要介绍一下单独对数据文件进行备份。
    备份表空间:backkup tablespace user,example;
      多个表空间哦那个逗号分隔。
    SQL> select TABLESPACE_NAME,STATUS from dba_tablespaces;
    
    TABLESPACE_NAME 	       STATUS
    ------------------------------ ---------
    SYSTEM			       ONLINE
    SYSAUX			       ONLINE
    UNDOTBS1		       ONLINE
    TEMP			       ONLINE
    USERS			       ONLINE
    USER02			       ONLINE
    TMP_SPACE_0327		       ONLINE
    
    7 rows selected.
    RMAN> backup tablespace users,TMP_SPACE_0327;
    
    Starting backup at 06-APR-17
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=33 device type=DISK
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    input datafile file number=00006 name=/u01/oracle/oradata/orcl/tmpspace0327
    input datafile file number=00004 name=/u01/oracle/oradata/orcl/users01.dbf
    channel ORA_DISK_1: starting piece 1 at 06-APR-17
    channel ORA_DISK_1: finished piece 1 at 06-APR-17
    piece handle=/tmp/0ls11re5_1_1 tag=TAG20170406T230541 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
    Finished backup at 06-APR-17

    备份数据文件:backup datafile 1,2,3;或者backup datafile 'path'
     

    SQL>  select file#, STATUS,ENABLED,NAME from v$datafile;
    
         FILE# STATUS  ENABLED    NAME
    ---------- ------- ---------- --------------------------------------------------
    	 1 SYSTEM  READ WRITE /u01/oracle/oradata/orcl/system01.dbf
    	 2 ONLINE  READ WRITE /u01/oracle/oradata/orcl/sysaux01.dbf
    	 3 ONLINE  READ WRITE /u01/oracle/oradata/orcl/undotbs01.dbf
    	 4 ONLINE  READ WRITE /u01/oracle/oradata/orcl/users01.dbf
    	 5 ONLINE  READ WRITE /u01/oracle/oradata/orcl/user02.dbf
    	 6 ONLINE  READ WRITE /u01/oracle/oradata/orcl/tmpspace0327
    
    6 rows selected.
    RMAN> backup datafile 4,6;
    
    Starting backup at 06-APR-17
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=9 device type=DISK
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    input datafile file number=00006 name=/u01/oracle/oradata/orcl/tmpspace0327
    input datafile file number=00004 name=/u01/oracle/oradata/orcl/users01.dbf
    channel ORA_DISK_1: starting piece 1 at 06-APR-17
    channel ORA_DISK_1: finished piece 1 at 06-APR-17
    piece handle=/tmp/0ms11rn0_1_1 tag=TAG20170406T231023 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
    Finished backup at 06-APR-17
    
    RMAN> backup datafile '/u01/oracle/oradata/orcl/users01.dbf';
    
    Starting backup at 06-APR-17
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting full datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    input datafile file number=00004 name=/u01/oracle/oradata/orcl/users01.dbf
    channel ORA_DISK_1: starting piece 1 at 06-APR-17
    channel ORA_DISK_1: finished piece 1 at 06-APR-17
    piece handle=/tmp/0ns11rns_1_1 tag=TAG20170406T231052 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 06-APR-17
    

    数据文件备份同样也可以用backup as copy tablespace users;

  6. 快速备份
    备份文件的时候系统要查看哪些block是更新了的,这样也会消耗不少资源,有一种办法就是对更新的block 进行整理标记速度就会快一点,这个就是跟踪文件。
    alter database enable block change tracking using file '/tmp/hurrup.file';
    
    SQL> alter database enable block change tracking using file '/tmp/hurrup.file';
    
    Database altered.
    SQL> select * from v$block_change_tracking;
    
    STATUS	   FILENAME			       BYTES
    ---------- ------------------------------ ----------
    ENABLED    /tmp/hurrup.file		    11599872
    

     
  7. 归档备份
    backup archive log all;备份后归档日志和备份的归档日志都有
    backup archive log all delete input; 备份归档日志后把原来的归档日志删除
    backup database plus archivelog; 可以在全量备份的时候添加上备份归档日志。
  8. 检查备份文件
    list backup of spfile/controlfile/datafile;
    list copy of spfile/controlfile/datafile;
    RMAN> list copy of controlfile;
    
    List of Control File Copies
    ===========================
    
    Key     S Completion Time Ckp SCN    Ckp Time       
    ------- - --------------- ---------- ---------------
    5       A 06-APR-17       2283452    06-APR-17      
            Name: /tmp/cf_D-ORCL_id-1461163151_0ks11q2h
            Tag: TAG20170406T224225
    
    4       A 17-JAN-17       1105880    17-JAN-17      
            Name: /u01/oracle/11g/dbs/snapcf_orcl.f
            Tag: TAG20170117T000003
    
    
    RMAN> list backup of spfile;
    
    
    List of Backup Sets
    ===================
    
    
    BS Key  Type LV Size       Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    2       Full    9.83M      DISK        00:00:03     06-APR-17      
            BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20170406T221256
            Piece Name: /tmp/0es11oej_1_1
      SPFILE Included: Modification time: 06-APR-17
      SPFILE db_unique_name: PORCL
    
    BS Key  Type LV Size       Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    3       Full    80.00K     DISK        00:00:00     06-APR-17      
            BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20170406T222440
            Piece Name: /tmp/0fs11p18_1_1
      SPFILE Included: Modification time: 06-APR-17
      SPFILE db_unique_name: PORCL
    
    BS Key  Type LV Size       Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    4       Full    80.00K     DISK        00:00:00     06-APR-17      
            BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20170406T222553
            Piece Name: /tmp/20170406spfile.bkp
      SPFILE Included: Modification time: 06-APR-17
      SPFILE db_unique_name: PORCL
    
    BS Key  Type LV Size       Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    7       Full    80.00K     DISK        00:00:00     06-APR-17      
            BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20170406T224132
            Piece Name: /tmp/0js11q0s_1_1
      SPFILE Included: Modification time: 06-APR-17
      SPFILE db_unique_name: PORCL
    
  9. 差异备份和增量备份
    差异备份:备份从上一次备份到现在更新的block
      关键字:incremantal
      sql:backup incremantal level 0 database;
      解释:0 表示0级备份也就是全量备份

    增量备份:增量累计量备份,从上次增量级别-1以来变化的block
        关键字:cumulative
         sql:backup cumulative incremantal level 2 database;
         解释:例如一周每天都做一个增量,只是级别不同,如下:
    7         1         2         3         4         5         6
    L0       L2       L2        L1       L2       L2       Lc1
    全量备份
     |-------| 2-1=1 是从0 到1 的备份
                |-------| 2-1=1 是从1 到1
    |-----------------------|1-1=0 从0到现在的备份
                                      |-------|2-1=1 上次0到1
                                                 |-------|2-1=1 从上次0到1
    |----------------------------------------------| 从0到C1 再做一次全量备份
    注意:级别0 是必须要有的,其他1,2,3,4都是基于0的基础上累计的。

  10. backup recovery;恢复

© 著作权归作者所有

胡子叭槎
粉丝 22
博文 140
码字总数 147885
作品 0
成都
数据库管理员
私信 提问
oracle-rman-常用命令

备份数据库: 显示RMAN配置 RMAN>show all; RMAN configuration parameters are: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default CONFIGURE BACKUP OPTIMIZATION OFF; # default C......

sijinge
2017/11/07
50
0
oracle-rman-list命令收集

参考Oracle Database Backup and Recovery Reference文档。 列出备份信息 列出详细备份信息:备份集(Backup Sets),镜像备份(image copies),proxy copies的信息。 lists backup sets, image...

sijinge
2017/11/07
16
0
Oracle9i rman备份恢复总结

Recovery Manager(RMAN)是一种用于备份(backup)、还原(restore)和恢复(recover)数据库的Oracle 工.RMAN只能用于ORACLE8或更高的版本中。它能够备份整个数据库或数据库部件,如表空间、数据...

♂.Cent
2010/12/08
412
0
catalog恢复目录介绍和配置

2.1、nocatalog介绍 nocatalog方式 就是用control file作为catalog,每一次备份都要往控制文件里面写好多备份信息,控制文件里面会有越来越多的备份信息。因此,当使用rman nocatalog方式备份...

PengChonggui
2018/06/28
0
0
RMAN多种备份脚本分享

1.相关参数介绍: 命令行参数 描述 TARGET 为目标数据库定义的一个连接字符串,当连接到一个目标数据库时,该连续是SYSDBA连接。该用户拥有启动和关闭数据库的权利,必须属于OSDBA组,必须建...

长平狐
2013/09/17
148
0

没有更多内容

加载失败,请刷新页面

加载更多

OSChina 周二乱弹 —— 开发语言和语言开发的能一样么

Osc乱弹歌单(2019)请戳(这里) 【今日歌曲】 @花间小酌:#今日歌曲推荐# 分享The Score的单曲《Revolution》 《Revolution》- The Score 手机党少年们想听歌,请使劲儿戳(这里) @批判派...

小小编辑
今天
890
10
oracle ORA-39700: database must be opened with UPGRADE option

ORA-01092: ORACLE instance terminated. Disconnection forced ORA-00704: bootstrap process failure ORA-39700: database must be opened with UPGRADE option 进程 ID: 3650 会话 ID: 29......

Tank_shu
今天
3
0
分布式协调服务zookeeper

ps.本文为《从Paxos到Zookeeper 分布式一致性原理与实践》笔记之一 ZooKeeper ZooKeeper曾是Apache Hadoop的一个子项目,是一个典型的分布式数据一致性的解决方案,分布式应用程序可以基于它...

ls_cherish
今天
4
0
聊聊DubboDefaultPropertiesEnvironmentPostProcessor

序 本文主要研究一下DubboDefaultPropertiesEnvironmentPostProcessor DubboDefaultPropertiesEnvironmentPostProcessor dubbo-spring-boot-project-2.7.3/dubbo-spring-boot-compatible/au......

go4it
昨天
2
0
redis 学习2

网站 启动 服务端 启动redis 服务端 在redis 安装目录下 src 里面 ./redis-server & 可以指定 配置文件或者端口 客户端 在 redis 的安装目录里面的 src 里面 ./redis-cli 可以指定 指定 连接...

之渊
昨天
2
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部