当前位置:  数据库>oracle

RMAN 异机迁移实战操作-附加常用命令

    来源: 互联网  发布时间:2017-06-17

    本文导语: 操作操作场景  源服务器      OEL 6.3 11G R2 11.2.0.3目标服务器    OEL 6.3 11G R2 11.2.0.3源服务器和目标服务器存放数据路径一样  源服务器[Oracle@mxq ~]$ rman target /  Recovery Manager: Release 11.2.0.2.0 - Production on Sat May 16 08:51:05 2015  Copyrigh...

操作操作场景

 源服务器      OEL 6.3 11G R2 11.2.0.3
目标服务器    OEL 6.3 11G R2 11.2.0.3
源服务器和目标服务器存放数据路径一样

 源服务器
[Oracle@mxq ~]$ rman target /

 Recovery Manager: Release 11.2.0.2.0 - Production on Sat May 16 08:51:05 2015

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

 connected to target database: ORACLE11 (DBID=2573050700)

 RMAN> run
 {allocate channel orademo type disk MAXPIECESIZE 1024m;
 backup incremental level 0 as compressed backupset database include current controlfile tag='full' format '/home/oracle/db_%s_%p_%t' plus archivelog tag='arch_all' format  '/home/oracle/arch_%s_%p_%t' delete input;
 }2> 3> 4>

 released channel: ORA_DISK_1
 allocated channel: orademo
 channel orademo: SID=147 device type=DISK


 Starting backup at 16-MAY-15
 current log archived
 channel orademo: starting compressed archived log backup set
 channel orademo: specifying archived log(s) in backup set
 input archived log thread=1 sequence=96 RECID=69 STAMP=879840530
 channel orademo: starting piece 1 at 16-MAY-15
 channel orademo: finished piece 1 at 16-MAY-15
 piece handle=/home/oracle/arch_59_1_879840531 tag=ARCH_ALL comment=NONE
 channel orademo: backup set complete, elapsed time: 00:00:01
 channel orademo: deleting archived log(s)
 archived log file name=/orafile/arc/1_96_879804940.arc RECID=69 STAMP=879840530
 Finished backup at 16-MAY-15

 Starting backup at 16-MAY-15
 channel orademo: starting compressed incremental level 0 datafile backup set
 channel orademo: specifying datafile(s) in backup set
 including current SPFILE in backup set
 including current control file in backup set
 input datafile file number=00002 name=/orafile/oradata/sysaux01.dbf
 input datafile file number=00001 name=/orafile/oradata/system01.dbf
 input datafile file number=00003 name=/orafile/oradata/undotbs01.dbf
 input datafile file number=00004 name=/orafile/oradata/users01.dbf
 channel orademo: starting piece 1 at 16-MAY-15
 channel orademo: finished piece 1 at 16-MAY-15
 piece handle=/home/oracle/db_60_1_879840533 tag=FULL comment=NONE
 channel orademo: backup set complete, elapsed time: 00:02:55
 Finished backup at 16-MAY-15

 Starting backup at 16-MAY-15
 current log archived
 channel orademo: starting compressed archived log backup set
 channel orademo: specifying archived log(s) in backup set
 input archived log thread=1 sequence=97 RECID=72 STAMP=879840713
 channel orademo: starting piece 1 at 16-MAY-15
 channel orademo: finished piece 1 at 16-MAY-15
 piece handle=/home/oracle/arch_61_1_879840714 tag=ARCH_ALL comment=NONE
 channel orademo: backup set complete, elapsed time: 00:00:01
 channel orademo: deleting archived log(s)
 archived log file name=/orafile/arc/1_97_879804940.arc RECID=72 STAMP=879840713
 Finished backup at 16-MAY-15
 released channel: orademo

把新的备份集拷贝到目标服务器
[oracle@mxq ~]$ cd /home/oracle/
 [oracle@mxq ~]$ ls
 arch_59_1_879840531  arch_61_1_879840714  db_60_1_879840533
 [oracle@mxq ~]$ ll
 total 248900
 -rw-r----- 1 oracle oinstall    219648 May 16 08:08 arch_59_1_879840531
 -rw-r----- 1 oracle oinstall  1256448 May 16 08:11 arch_61_1_879840714
 -rw-r----- 1 oracle oinstall 253394944 May 16 08:11 db_60_1_879840533
 [oracle@mxq ~]$ scp * oracle@192.168.0.253:/home/oracle/
 oracle@192.168.0.253's password:
 arch_59_1_879840531                          100%  215KB 214.5KB/s  00:00   
 arch_61_1_879840714                          100% 1227KB  1.2MB/s  00:00   
 db_60_1_879840533                            100%  242MB  13.4MB/s  00:18 

目标服务器

 提示:
 如果已经数据文件、控制文件、在线日志文件、参数文件那么新删除掉在进行做恢复不然后面报错

[oracle@mxq ~]$ rman target /

 Recovery Manager: Release 11.2.0.2.0 - Production on Sun May 17 12:10:05 2015

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

 connected to target database (not started)


 RMAN> startup force nomount;

 Oracle instance started

 Total System Global Area    521936896 bytes

 Fixed Size                    2228072 bytes
 Variable Size                159383704 bytes
 Database Buffers            352321536 bytes
 Redo Buffers                  8003584 bytes


 RMAN> restore spfile from '/home/oracle/db_54_1_879855779';

 Starting restore at 17-MAY-15
 allocated channel: ORA_DISK_1
 channel ORA_DISK_1: SID=134 device type=DISK

 channel ORA_DISK_1: restoring spfile from AUTOBACKUP /home/oracle/db_54_1_879855779
 channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
 Finished restore at 17-MAY-15

 RMAN> shutdown immediate;

 Oracle instance shut down

 RMAN> set DBID=2573050700

 executing command: SET DBID

 RMAN> startup nomount;

 connected to target database (not started)
 Oracle instance started

 Total System Global Area    521936896 bytes

 Fixed Size                    2228072 bytes
 Variable Size                176160920 bytes
 Database Buffers            335544320 bytes
 Redo Buffers                  8003584 bytes


 RMAN> restore controlfile from '/home/oracle/db_54_1_879855779';

 Starting restore at 17-MAY-15
 allocated channel: ORA_DISK_1
 channel ORA_DISK_1: SID=134 device type=DISK

 channel ORA_DISK_1: restoring control file
 channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
 output file name=/orafile/oradata/control01.ctl
 output file name=/orafile/oradata/control02.ctl
 Finished restore at 17-MAY-15

 RMAN> alter database mount;

 database mounted


 RMAN> list backup summary;


 List of Backups
 ===============
 Key    TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
 ------- -- -- - ----------- --------------- ------- ------- ---------- ---
 10      B  A  A DISK        16-MAY-15      1      1      YES        ARCH_ALL
 11      B  A  A DISK        16-MAY-15      1      1      YES        ARCH_ALL
 12      B  0  A DISK        16-MAY-15      1      1      YES        FULL

 RMAN> restore database from tag='FULL';

 Starting restore at 17-MAY-15
 allocated channel: ORA_DISK_1
 channel ORA_DISK_1: SID=133 device type=DISK

 channel ORA_DISK_1: starting datafile backup set restore
 channel ORA_DISK_1: specifying datafile(s) to restore from backup set
 channel ORA_DISK_1: restoring datafile 00001 to /orafile/oradata/system01.dbf
 channel ORA_DISK_1: restoring datafile 00002 to /orafile/oradata/sysaux01.dbf
 channel ORA_DISK_1: restoring datafile 00003 to /orafile/oradata/undotbs01.dbf
 channel ORA_DISK_1: restoring datafile 00004 to /orafile/oradata/users01.dbf
 channel ORA_DISK_1: reading from backup piece /home/oracle/db_60_1_879840533
 channel ORA_DISK_1: piece handle=/home/oracle/db_60_1_879840533 tag=FULL
 channel ORA_DISK_1: restored backup piece 1
 channel ORA_DISK_1: restore complete, elapsed time: 00:01:45
 Finished restore at 17-MAY-15

 RMAN> recover database from tag='ARCH_ALL';

 Starting recover at 17-MAY-15
 using channel ORA_DISK_1

 starting media recovery

 archived log for thread 1 with sequence 97 is already on disk as file /orafile/arc/1_97_879804940.arc
 archived log for thread 1 with sequence 1 is already on disk as file /orafile/arc/1_1_879955249.arc
 archived log for thread 1 with sequence 2 is already on disk as file /orafile/arc/1_2_879955249.arc
 archived log for thread 1 with sequence 3 is already on disk as file /orafile/arc/1_3_879955249.arc
 archived log file name=/orafile/arc/1_97_879804940.arc thread=1 sequence=97
 archived log file name=/orafile/arc/1_2_879955249.arc thread=1 sequence=2
 media recovery complete, elapsed time: 00:00:17
 Finished recover at 17-MAY-15

 RMAN> alter database open;

 database opened

 -----------------------
 The migration completed

附加常用命令:

1、概念

 差异增量:是备份上级及同级备份以来所有变化的数据块,差异增量是默认增量备份方式
 累积增量:是备份上级备份以来所有变化的块

 因为累积增量是备份上级备份以来所有变化的数据块,所以累积增量需要更多的备份时间,同时需要较小的恢复时间;
 而差异增量正好相反,它可以备份同级备份以来变化的数据块。所以会减少备份时间,但需要更多的恢复时间.在oracle
 9中增量备份需要通过扫描整个数据库的数据块才能知道哪些数据块发生了变化,这是一个代价很大,时间很长的过程,
 而且由于增量备份形成多个不同的备份集,使恢复变得更加不可靠,所以增量备份在版本9中仍然不被推荐使用;在10g中,
 增量备份作了很大的改进,不需要再扫描所有数据块就能得知哪些数据块发生变化,从而大大提升备份效率。但这些却以牺牲磁盘i/o为代价,
 所以在oltp事务系统中还得衡量是否愿意以i/o为代价来保证安全及高可用性。10g还支持增量合并,增量备份可支持7级增量。

 

1、镜像复制(Image Copies)

  镜像复制实际上就是数据文件、控制文件或归档文件的复制,与用户通过操作系统命令建立的文件复制实质一样,只不过RMAN是利用目标数据库中的服务进程来完成文件复制,而用户则是用操作系统命令。所以镜像复制的方式体现不出RMAN的优势,也并非我们讨论的重点,大家了解一下即可(啥?想知道镜像复制咋用?卡,问村长去~~~~~)。

2、备份集(Backup Sets)

  备份集是通过RMAN创建的逻辑备份对象。一个备份集中可以包含多个数据文件、控制文件或归档文件。备份集在物理上是由多个备份片段组成,每个备份片段是一个操作系统文件。

 

1. List 当前RMAN所备份的数据库:

    完全恢复
   
    restore database 修复数据库
    recover database 恢复数据库
   
    不完全恢复
   
    set until time '2012-06-06 21:00:00'; 设置基于时间不完全恢复
    set until scn 3404460;                设置基于scn不完全恢复
    set until sequence=3;                设置基于序列号不全恢复
    restore database
    recover database
   
    backup
       
        备份整个数据库
      后面指定备份到那里
     
        bakckup database format='/home/oracle/all_U'
       
        备份当前控制文件
     
        backup current controlfile format='/home/oracle/all_U'
       
        备份表空间
     
        backup tablespace user format='/home/oracle/all_U'
       
        备份参数文件
     
        backup spfile format '/home/oracle/spfile_U'
       
        备份所有归档日志,删除备份后的归档日志
     
        backup archivelog all delete input format '/home/oracle/arc_U'
       
       
      保留策略:

 基于时间:

CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF  n  DAYS;

基于冗余数量:

CONFIGURE RETENTION POLICY TO REDUNDANCY  n
       


    1.1. list backup summary; --概述可用的备份
          list incarnation;--汇总查询

                    --如果备份文件多的话多用这两个list命令可以对备份文件有个总体了解。
        B 表示backup
        A 表示Archivelog、 F 表示full backup、 0,1,2 表示incremental level备份
        A 表示可用AVALIABLE、 X 表示EXPIRED

        列出可以用备份集
        list backup of database summary
        列出可以用的归档日志
        list backup of archivelog all summary
        列出可以用的表空间
        list backup of tablespace users summary;
        列出可以用的数据文件
        list backup of datafile n,n,n summary
   
    列出所有备份参数文件
    list backup of spfile;


    列出所有备份的控制文件
    list backup of controlfile;


    列出所有备份数据文件
    list backup of datafle n,n,n,n;


    列出所有的备份表空间
    list backup of tablespace tablespace_name;
       
    列出过期所有过期备份
    list expired backup;
   
    列出所有备份归档文件
    list archivelog all;
   
    delele
   
    删除所有过旧的备份
    delete noprompt obsolete;
   
    删除过期备份
  delete noprompt expired backup;
  上面命令物理备份文件被删除通过下面检查备份是否可用
  corsscheck backup;
 
  删除所有过期归档
  delete expired archivelog all;
   
  删除指定60天后归档
  delete archivelog all completed before 'sysdate-60’;
 
  crosscheck backup of archivelog all;
 
  crosscheck backup of controlfile  核对控制文件的备份集;
 
  crosscheck backup of spfile    核对SPFILE的备份集;

--------------------------------------推荐阅读 --------------------------------------

RMAN 配置归档日志删除策略

Oracle基础教程之通过RMAN复制数据库

RMAN备份策略制定参考内容

RMAN备份学习笔记

Oracle数据库备份加密 RMAN加密

--------------------------------------分割线 --------------------------------------


    
 
 

您可能感兴趣的文章:

 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • rman备份脚本和rman增量备份脚本分享
  • Oracle数据库备份和恢复工具 RMan
  • catalog方式的rman备份与恢复示例
  • rman配置及rman常用命令操作
  • win平台oracle rman备份和删除dg备库归档日志脚本
  • linux自动运行rman增量备份脚本
  • 9i下RMAN的备份及恢复步骤
  • Oracle相关:Rman Crosscheck删除失效归档
  • ORACLE 数据库RMAN备份恢复
  • rman恢复方案和oracle异机恢复
  • WEB前端 iis7站长之家


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3