zoukankan      html  css  js  c++  java
  • 转 11g RMAN Restore archivelog用法

    ###sample 1

    感谢 思考v

    https://blog.csdn.net/xiegh2014/article/details/25530335

    11g RMAN Restore archivelog用法

     

    RMAN> BACKUP FORMAT '/u01/backup/arch_%U_%T' skip inaccessible filesperset 5 ARCHIVELOG ALL DELETE INPUT;

    II.使用RMAN方式清除
    RMAN清除方式会自动清除磁盘上的归档日志文件,同时会释放控制文件中对应的归档日志的归档信息。
    可以基于不同的条件来清除归档日志,如基于SCN,基于SEQUENCE,基于TIME等方式。
    对于上述的三种方式又可以配合from, until, between .. and .. 等等子句来限定范围,方式灵活多变。
    下面的命令用于校验归档日志的有效性,列出无效的归档日志,以及以何种方式清除归档日志,列出几种常用的:
    crosscheck archivelog all;                                   --->校验日志的可用性
    list expired archivelog all;                                 --->列出所有失效的归档日志
    delete archivelog until sequence 16;                         --->删除log sequence为16及16之前的所有归档日志
    delete archivelog all completed before 'sysdate-7';          --->删除系统时间7天以前的归档日志,不会删除闪回区有效的归档日志
    delete archivelog all completed before 'sysdate - 1';        --->同上,1天以前的
    delete archivelog from time 'sysdate-1';                     --->注意这个命令,删除系统时间1天以内到现在的归档日志
    delete noprompt archivelog all completed before 'sysdate';   --->该命令清除所有的归档日志
    delete noprompt archivelog all;                              --->同上一命令

    III. Restore archivelog选项

    1.RAC环境下需要加上Thread Number,不加默认是Thread 1
    RMAN> restore archivelog from sequence 112 thread 2;


    2.恢复全部归档日志文件

    RMAN> restore archivelog all;


    3.恢复Sequence范围

    RMAN> restore archivelog from sequence 90 until sequence 98;
    RMAN> restore archivelog sequence between 20 and 35;


    4.恢复从第5个归档日志起

    RMAN> restore archivelog from sequence 5;
    RMAN> restore archivelog low sequence 5;


    5.恢复7天内的归档日志

    RMAN> restore archivelog from time 'sysdate-7';


    6.恢复到哪个日志文件为止

    RMAN> restore archivelog until sequence 110;
    RMAN> restore archivelog high sequence 108;


    7.改变恢复到另外路径下 则可用下面语句

    set archivelog destination to '/u01/backup';

    RMAN> run
    2> {allocate channel c1 type disk;
    3> set archivelog destination to '/u01/backup';
    4> restore archivelog all;
    5> release channel c1;
    6> }


    8.根据时间查看需要的备份集:

    RMAN> list backup of archivelog time between "to_date('2014-04-24 11:00:00','yyyy-mm-dd hh24:mi:ss')" and "to_date('2014-04-24 14:30','yyyy-mm-dd hh24:mi:ss')";

    恢复指定时间段

    RMAN> run {
    set archivelog destination to '/u01/backup';
    SQL 'ALTER SESSION SET NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"';
    restore archivelog time between '2014-04-24 11:00:00' and '2014-04-24 15:00:00';
    }

    附:RMAN 配置归档日志删除策略
    Oracle 11g中对于归档日志的删除,除了遵循RMAN保留策略外,也可以通过RMAN来配置归档日志的删除策略,也就是归档日志何时可以被删除。归档日志删除策略适用于所有归档位置(使用快速闪回区FRA/不使用FRA)。

    1、关于归档日志删除策略
          也就是哪些归档日志符合删除策略能够被删除,如前所述,归档位置适用于所有归档位置(使用快速闪回区FRA/不使用FRA)
          当启用该策略后,如归档日志存在于FRA中,则Oracle会尽可能根据保留他们,一旦FRA空间告急,则Oracle会根据归档日志删除策略自动删除
          对于不在FRA中的归档日志,需要手动使用delete obsolete或delete archivelog方式来删除日志
          无论归档日志存在于FRA内或外,都可以通过BACKUP ... DELETE INPUT or DELETE ARCHIVELOG方式来删除
          该策略不适用于使用LogMiner方式从主数据库传送到逻辑standby生成的外部归档日志文件,因为这些日志文件不能够在逻辑standy上备份或恢复

    2、配置归档日志删除策略
        使用下面的方式来配置归档日志删除策略
            configure archivelog deletion policy to backed up 2 times to sbt;
            configure archivelog deletion policy to backed up 1 times to device type disk;
            configure archivelog deletion policy to applied on standby;
            configure archivelog deletion policy to shipped on standby;
            configure archivelog deletion policy clear;
        对于Oracle 10g没有该特性,但有一个类似的用于配置归档日志被备份次数,如下;
            configure archivelog backup copies for device type disk to ${archiveretention};

    3、禁用归档日志删除策略
          缺省情况下,该策略被设置为none。也就是说根据RMAN备份保留策略,对于FRA中的归档日志,被备份过一次(到磁盘或磁带)即符合条件被删除
        如果Oracle不再需要当前的归档日志用于保证数据库时点恢复或数据库闪回,则RMAN备份保留策略认为当前日志为obsolete
        在SYSDATE-'DB_FLASHBACK_RETENTION_TARGET'之后创建的归档日志是需要被保留的

    4、启用归档日志删除策略
        一旦启用该策略,则指定的归档日志被备份数量达到设定值后,这些归档日志能够被删除
        BACKUP ARCHIVELOG 会在未超出指定备份数的情况下(比如设置为2)备份归档日志到指定位置,如超出2次,则RMAN会跳过这些备份过2次的归档日志
        对于上述的情形,可以为BACKUP ARCHIVELOG适用force选项来强制备份归档日志
        如果启用该策略且配置为APPLIED ON STANDBY子句,则所有强制standby位置被apply后,这些归档日志会被RMAN删除
        如果启用该策略且配置为SHIPPED ON STANDBY子句,则所有强制standby位置被成功传送后,这些归档日志会被RMAN删除
     
     
    ############sample 2
     
    To BottomTo Bottom
     

    Not able to modify the spfile with alter system command.

     SQL> alter system set open_cursors=2000 scope=spfile;
    alter system set open_cursors=2000 scope=spfile
    *
    ERROR at line 1:
    ORA-32000: write to SPFILE requested but SPFILE is not modifiable

    CHANGES

    Created the spfile in $ORACLE_HOME/dbs using below command.

    SQL> create spfile from pfile;

    Where pfile having information about spfile which is there in ASM

    ex:

    Content of the pfile looks like below.

    $ cat $ORACLE_HOME/dbs/init<DB_NAME>.ora 

    SPFILE='+<DGNAME>/<DB_NAME>/spfile<DB_NAME>.ora'

    CAUSE

    If you see the spfile parameter in the database it shows as below.

    ex:

    SQL> show parameter spfile

    NAME                                       TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    spfile                                       string       /u01/app/oracle/product/11.2.0
                                                                 /dbhome_1/dbs/spfile<DB_NAME>.or
                                                                 a

    Content of the spfile looks like below.

    cat /u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfile<DB_NAME>.ora

    SPFILE='+<DGNAME>/<DB_NAME>/spfile<DB_NAME>.ora' 

    SOLUTION

     1. Move the spfile which is there in $ORACLE_HOME/dbs

    ex:

    mv spfile<DB_NAME>.ora spfile<DB_NAME>.ora.bkp


    2. Create the file in $ORACLE_HOME/dbs location with init<SID>.ora name with below content.

    SPFILE='<spfile location which is there in ASM>'

    ex:

    FileName: init<DB_NAME>.ora

    SPFILE='+<DGNAME>/<DB_NAME>/spfile<DB_NAME>.ora'

    3. Then restart the database, it will use the spfile which is there in ASM.

    4. Now you will be able to modify the spfile with below command.

    alter system set open_cursors=2000 scope=spfile;
     
     
     
     
     
    #################sample 3

    SYMPTOMS

     RMAN Backup at standby failed with below:

    Starting backup at 20170524.063028
    RMAN-06820: WARNING: failed to archive current log at primary database
    ORACLE error from target database:
    ORA-17629: Cannot connect to the remote database server
    ORA-17627: ORA-00942: table or view does not exist

    released channel: disk1
    released channel: disk2
    released channel: disk3
    released channel: disk4
    released channel: disk5
    released channel: disk6
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of backup command at 05/24/2017 06:30:29
    ORA-06540: PL/SQL: compilation error
    ORA-06553: PLS-252: reference to the wrong copy of package STANDARD

    CHANGES

    Possibly have run any compilation scripts in primary which pointing to the previous package version at standby.

    CAUSE

    A reference is made to the fixed package version of STANDARD when the database is open, or to the on-disk version when the database is closed.

    Explicit use of a SYS.X$ package name can lead to this.  One might also see this from a compilation that begins while the db is closed but has the bad luck to have another session open the database before compilation is complete.

    Another possible cause is having 'set serveroutput on' through svrmgrl when doing an 'alter database close'.  

    SOLUTION

    Restart the standby database

    or

    Flush shared pool

     

  • 相关阅读:
    linux整理
    C++ 11 多线程--线程管理
    VS2013 配置全局 VC++目录
    visual studio运行时库MT、MTd、MD、MDd的研究
    C++(vs)多线程调试 (转)
    VS工程和Qt工程转换
    Qt 读写XML文件
    win32开发中多字节(ANSI)和宽字符(UNICODE)字符串处理函数参考
    QMenu----QT鼠标右键弹出菜单
    C++ 单例模式析构函数的运用,析构函数的线程安全
  • 原文地址:https://www.cnblogs.com/feiyun8616/p/13674007.html
Copyright © 2011-2022 走看看