精华内容
下载资源
问答
  • ORACLE 11G 利用泠备份恢复standby库

    万次阅读 2019-07-06 08:51:22
    利用泠备份恢复standby数据库 1 开始在备库上进行泠备份 先查好控制文件、redo、undo文件、数据文件的路径 1.1 先关闭主库的归档日志传输 SQL> ALTER system SETlog_archive_dest_state_2 ='DEFER';...

    利用泠备份恢复standby数据库

     

    1 开始在备库上进行泠备份

    先查好控制文件、redo、undo文件、数据文件的路径

     

    1.1 先关闭主库的归档日志传输

    SQL> ALTER system SETlog_archive_dest_state_2 ='DEFER';                                                                                                                                     

                                                                                                                                                                                                  

    System altered.

     

    SQL> 

     

     

    1.2 先关闭standby库

    SQL> shutdown immediate;                                                                                                                                                                      

    Database closed.                                                                                                                                                                              

    Database dismounted.                                                                                                                                                                          

    ORACLE instance shut down.                                                                                                                                                                    

    SQL>                                                                                                                                                                                          

    SQL>    

     

     

    <版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!> 
    原博客地址:   http://blog.csdn.net/mchdba/article/details/46622839
    原作者:黄杉 (mchdba)

     

     

    1.3 开始进行泠备份

    #建立一个泠备份目录

    mkdir /data/oracle_cold/

    开始泠备份控制文件

    cp /data/oracle_cold/

    cp /home/oradata/orcl/control01.ctlcontrol01.ctl

    cp /oracle/app/oracle/flash_recovery_area/orcl/control02.ctlcontrol02.ctl

    开始泠备份redo、undo文件

    mkdir orcl_2

    cp -r /home/oradata/orcl/*.log orcl_2

    开始泠备份数据文件

    cp -r /home/oradata/orcl/*.dbf orcl_2

     

     

     

    2开始使用泠备份进行db恢复

    2.1,停止掉standby库

    SQL> shutdown immediate;                                                                                                                                                                      

    Database closed.                                                                                                                                                                              

    Database dismounted.                                                                                                                                                                          

    ORACLE instance shut down.                                                                                                                                                                    

    SQL>                                                                                                                                                                                          

    SQL>    

     

     

    2.2,将泠备中的控制文件覆盖当前的控制文件

    查看原来的控制文件目录

    [oracle@localhost oracle_cold]$ morecontrolfile.log

    SQL> SELECT name FROMv$controlfile;                                                                                                                                                          

     

    NAME

    --------------------------------------------------------------------------------

    /home/oradata/orcl/control01.ctl

    /oracle/app/oracle/flash_recovery_area/orcl/control02.ctl

     

    SQL> 

    开始复制覆盖

    [oracle@localhost oracle_cold]$ cpcontrol02.ctl /oracle/app/oracle/flash_recovery_area/orcl/control02.ctl

    [oracle@localhost oracle_cold]$ cpcontrol01.ctl /home/oradata/orcl/control01.ctl

    [oracle@localhost oracle_cold]$

     

    2.3,将泠备中的redo、undo文件覆盖到以前的目录中

    查看以前的redo、undo文件路径

    [oracle@localhost oracle_cold]$ morelogfile.log

    SQL> select member from v$logfile;                                                                                                                                                            

     

    MEMBER

    --------------------------------------------------------------------------------

    /home/oradata/orcl/redo03.log

    /home/oradata/orcl/redo02.log

    /home/oradata/orcl/redo01.log

    /home/oradata/orcl/redo_dg_01.log

    /home/oradata/orcl/redo_dg_02.log

    /home/oradata/orcl/redo_dg_03.log

     

    6 rows selected.

     

    SQL> 

     

    开始覆盖redo、undo文件

    [oracle@localhost oracle_cold]$ cp orcl_2/*.log/home/oradata/orcl/

    [oracle@localhost oracle_cold]$

     

    2.4,将泠备中的数据文件覆盖到以前的目录中

    查看以前的数据文件目录

    [oracle@localhost oracle_cold]$ moredatafile.log

    SELECT name FROM v$datafile;

    1       /home/oradata/orcl/system01.dbf

    2       /home/oradata/orcl/sysaux01.dbf

    3       /home/oradata/orcl/undotbs01.dbf

    4       /home/oradata/orcl/users01.dbf

    5       /home/oradata/orcl/orclk01.dbf

    6       /home/oradata/orcl/plas01.dbf

    7       /home/oradata/orcl/pl01.dbf

    8       /home/oradata/orcl/help01.dbf

    9       /home/oradata/orcl/adobelc01.dbf

    10     /home/oradata/orcl/sms01.dbf

    11     /home/oradata/orcl/plcrm01.dbf

     

    [oracle@localhost oracle_cold]$

     

    开始覆盖以前的数据文件目录

    [oracle@localhost oracle_cold]$ cp orcl_2/*.dbf/home/oradata/orcl/

    [oracle@localhost oracle_cold]$

     

    2.5 启动数据库

    SQL> startup                                                                                                                                                                                  

    ORACLE instance started.                                                                                                                                                                      

     

    Total System Global Area 5344731136 bytes

    Fixed Size              2213136 bytes

    Variable Size              3355446000 bytes

    Database Buffers    1946157056 bytes

    Redo Buffers                40914944 bytes

    Database mounted.                                                                                                                                                                              

    Database opened.                                                                                                                                                                              

    SQL>

     

     

    2.6 去主库上开启归档日志传输

    SQL> ALTER system SET log_archive_dest_state_2='enable';                                                                                                                                     

                                                                                                                                                                                                  

    System altered.

     

    SQL> 

     

    2.7 然后备库启动应用

    select sequence#,applied fromv$archived_log order by sequence# asc;

     

    SQL> alter database recovermanagedstandby database disconnect from session;                                                                                                                

                                                                                                                                                                                                 

    Database altered.

     

    SQL>

    SQL> select open_modefromv$database;                                                                                                                                                       

    OPEN_MODE

    --------------------

    READ ONLY WITH APPLY

     

    SQL>

     

    展开全文
  • 云平台网络异常使用增量备份恢复Oracle DG备库 在云平台由于虚拟机网络故障导致主库网络瘫痪,主库实例恢复后,备库通过增量备份恢复案例。 1、查看备库告警日志 备库告警日志中最后要写的的是日志序列为63616的SRL...

    云平台网络异常使用增量备份恢复Oracle DG备库

    在云平台由于虚拟机网络故障导致主库网络瘫痪,主库实例恢复后,备库通过增量备份恢复案例。
    1、查看备库告警日志
    在这里插入图片描述
    备库告警日志中最后要写的的是日志序列为63616的SRL日志,可以看到redo log在写入时有错误,checksum是检验文件的校验码,此时oracle给予的提示是可能网络连接无法连接主库。

    看了下备库日志归档日志如下,自9.11号22:08之后就再无归档日志
    在这里插入图片描述

    备注:后面已经排查清楚,是由于主库sys密码改了,然而主库密码文件没有覆盖到备库上,导致备库一直没有归档日志。如下
    在这里插入图片描述

    2、主库日志序列
    在这里插入图片描述

    3、备库日志序列
    在这里插入图片描述
    自9.11到当前11月份为止所产生的归档日志已有400多g,直接用MOS上增量备份恢复方法肯定比注册归档日志要合适。
    参考

    Steps to perform for Rolling Forward a Physical Standby Database using
    RMAN Incremental Backup. (文档 ID 836986.1)

    在这里插入图片描述

    4、备库上查询gap情况

    SQL> select * from V$ARCHIVE_GAP;
    no rows selected
    

    备库无gap

    5、停止备库的日志应用

    SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
    

    5、查看备库最小的scn

    col MIN(CHECKPOINT_CHANGE#) for 999999999999999999
    col CURRENT_SCN for 99999999999999999
    

    (1)

    查看备库数据文件头部最小的scn
    SQL> select min(checkpoint_change#) from v$datafile_header;
    
    MIN(CHECKPOINT_CHANGE#)
    -----------------------
    541057243        
    

    (2)

    X$KCVFH是GV$DATAFILE_HEADER的内部视图,检查下最小的检查点scn
    SQL>  select min(fhscn) from x$kcvfh;
    
    MIN(FHSCN)
    ------------------------------------------------
    541057243
    

    (3)
    查看下当前的scn

    SQL>  SELECT CURRENT_SCN FROM V$DATABASE;
    
           CURRENT_SCN
    ------------------
               541067278
    

    6、确定主库是否添加数据文件

    select FILE#,name from v$datafile where CREATION_CHANGE#> =541057243;
    FILE# NAME
    ----- -----
    no rows selected
    

    主库没有在备库最小scn之后产生新的数据文件,所以不需要做RMAN数据文件备份

    7、主库做增量备份

    #!/bin/bash
    export ORACLE_SID=orcl
    export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
    export ORACLE_BASE=/u01/app/oracle
    export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
    backtime=`date +"20%y%m%d%H%M%S"`
    $ORACLE_HOME/bin/rman target / log=/u01/rman/db_$backtime.log <<EOF
    run{
    allocate channel c1 device type disk;
    allocate channel c2 device type disk;
    allocate channel c3 device type disk;
    allocate channel c4 device type disk;
    backup as compressed backupset INCREMENTAL from scn 541057243 database format '/u01/rman/zengliang_%u.bak' tag 'zengliang';-->那上面查到的最小scn为起点
    release channel c1;
    release channel c2;
    release channel c3;
    release channel c4;
    }
    exit
    EOF
    

    再生成备库的控制文件

    alter database create standby controlfile as '/u01/rman/cf_file.ctl';
    

    8、在备库恢复
    拷贝备份和控制文件到备库

    RMAN> shutdown;
    RMAN> startup nomount;
    RMAN> restore standby controlfile from '/u01/rman/cf_file.ctl';
    RMAN> alter database mount;
    RMAN> CATALOG START WITH '/u01/rman';
    RMAN> recover database noredo;
    

    备库输出日志过程

    RMAN> recover database noredo;
    Starting recover at 25-NOV-19
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=576 device type=DISK
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    destination for restore of datafile 00005: /u01/app/oradata/standby/xcgov.dbf
    destination for restore of datafile 00058: /oracle_nas/wangzhanqun116/standby/xc_ylx_01.dbf
    destination for restore of datafile 00063: /oracle_nas/wangzhanqun116/standby/cgs_test01.dbf
    channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2ouhokf9.bak
    channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2ouhokf9.bak tag=ZENGLIANG
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    destination for restore of datafile 00014: /u01/app/oradata/standby/XC_DCQ.dbf
    destination for restore of datafile 00026: /u01/app/oradata/standby/XC_RFB.dbf
    destination for restore of datafile 00039: /u01/app/oradata/standby/XC_HBJ.dbf
    destination for restore of datafile 00049: /u01/app/oradata/standby/xc_cgs.dbf
    destination for restore of datafile 00074: /oracle_nas/wangzhanqun116/standby/XC_DCQ01.dbf
    destination for restore of datafile 00075: /oracle_nas/wangzhanqun116/standby/XC_DCQ02.dbf
    channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2nuhokf9.bak
    channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2nuhokf9.bak tag=ZENGLIANG
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    destination for restore of datafile 00002: /u01/app/oradata/standby/sysaux01.dbf
    destination for restore of datafile 00027: /u01/app/oradata/standby/XC_JTJ.dbf
    destination for restore of datafile 00028: /u01/app/oradata/standby/XC_GTJ.dbf
    destination for restore of datafile 00066: /oracle_nas/wangzhanqun116/standby/system01.dbf
    destination for restore of datafile 00067: /oracle_nas/wangzhanqun116/standby/system02.dbf
    channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2muhokf9.bak
    channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2muhokf9.bak tag=ZENGLIANG
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:03:15
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    destination for restore of datafile 00019: /u01/app/oradata/standby/xcgov2.dbf
    destination for restore of datafile 00064: /oracle_nas/wangzhanqun116/standby/cgs_test02.dbf
    destination for restore of datafile 00065: /oracle_nas/wangzhanqun116/standby/sysaux01.dbf
    channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2puhokjh.bak
    channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2puhokjh.bak tag=ZENGLIANG
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    destination for restore of datafile 00001: /u01/app/oradata/standby/system01.dbf
    destination for restore of datafile 00016: /u01/app/oradata/standby/XC_LYJ.dbf
    destination for restore of datafile 00046: /u01/app/oradata/standby/XC_WDQ.dbf
    destination for restore of datafile 00070: /oracle_nas/wangzhanqun116/standby/xc_cgj01.dbf
    destination for restore of datafile 00071: /oracle_nas/wangzhanqun116/standby/xc_cgj02.dbf
    channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2quhokno.bak
    channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2quhokno.bak tag=ZENGLIANG
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    destination for restore of datafile 00009: /u01/app/oradata/standby/swj.dbf
    destination for restore of datafile 00022: /u01/app/oradata/standby/XC_NYJ.dbf
    destination for restore of datafile 00047: /u01/app/oradata/standby/xc_jaq.dbf
    destination for restore of datafile 00050: /u01/app/oradata/standby/xc_xcx.dbf
    destination for restore of datafile 00076: /oracle_nas/wangzhanqun116/standby/XC_GHJ01.dbf
    destination for restore of datafile 00077: /oracle_nas/wangzhanqun116/standby/XC_GHJ02.dbf
    channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2ruhokou.bak
    channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2ruhokou.bak tag=ZENGLIANG
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    destination for restore of datafile 00030: /u01/app/oradata/standby/XC_GAJ.dbf
    destination for restore of datafile 00037: /u01/app/oradata/standby/XC_GHJ.dbf
    destination for restore of datafile 00048: /u01/app/oradata/standby/xc_yzs.dbf
    destination for restore of datafile 00072: /oracle_nas/wangzhanqun116/standby/XC_CGS01.dbf
    destination for restore of datafile 00073: /oracle_nas/wangzhanqun116/standby/XC_CGS02.dbf
    channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2suhokou.bak
    channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2suhokou.bak tag=ZENGLIANG
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    destination for restore of datafile 00006: /u01/app/oradata/standby/XCZF_ZZ.dbf
    destination for restore of datafile 00007: /u01/app/oradata/standby/njj.dbf
    destination for restore of datafile 00008: /u01/app/oradata/standby/gxw.dbf
    destination for restore of datafile 00051: /u01/app/oradata/standby/xc_ylx.dbf
    destination for restore of datafile 00078: /oracle_nas/wangzhanqun116/standby/XC_GLJ01.dbf
    destination for restore of datafile 00079: /oracle_nas/wangzhanqun116/standby/XC_GLJ02.dbf
    channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2tuhokv1.bak
    channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2tuhokv1.bak tag=ZENGLIANG
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    destination for restore of datafile 00045: /u01/app/oradata/standby/sjj.dbf
    destination for restore of datafile 00052: /u01/app/oradata/standby/XC_SJJnew.dbf
    destination for restore of datafile 00054: /u01/app/oradata/standby/CZJNEW.dbf
    destination for restore of datafile 00055: /u01/app/oradata/standby/CGS_TEST.dbf
    destination for restore of datafile 00085: /oracle_nas/wangzhanqun116/standby/XC_NYJ02.dbf
    destination for restore of datafile 00086: /oracle_nas/wangzhanqun116/standby/XC_RSJ01.dbf
    channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2uuhol13.bak
    channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2uuhol13.bak tag=ZENGLIANG
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    destination for restore of datafile 00010: /u01/app/oradata/standby/sgj.dbf
    destination for restore of datafile 00011: /u01/app/oradata/standby/XC_SFJ.dbf
    destination for restore of datafile 00012: /u01/app/oradata/standby/XC_SFQ.dbf
    destination for restore of datafile 00013: /u01/app/oradata/standby/XC_KFQ.dbf
    destination for restore of datafile 00015: /u01/app/oradata/standby/XC_FGW.dbf
    destination for restore of datafile 00080: /oracle_nas/wangzhanqun116/standby/XC_JYJ01.dbf
    channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_30uhol55.bak
    channel ORA_DISK_1: piece handle=/u01/rman/zengliang_30uhol55.bak tag=ZENGLIANG
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    destination for restore of datafile 00017: /u01/app/oradata/standby/XC_KJJ.dbf
    destination for restore of datafile 00018: /u01/app/oradata/standby/XC_AJJ.dbf
    destination for restore of datafile 00020: /u01/app/oradata/standby/XC_LSJ.dbf
    destination for restore of datafile 00021: /u01/app/oradata/standby/XC_MZJ.dbf
    destination for restore of datafile 00023: /u01/app/oradata/standby/XC_CZJ.dbf
    destination for restore of datafile 00081: /oracle_nas/wangzhanqun116/standby/XC_JYJ02.dbf
    channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_31uhol84.bak
    channel ORA_DISK_1: piece handle=/u01/rman/zengliang_31uhol84.bak tag=ZENGLIANG
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    destination for restore of datafile 00056: /u01/app/oradata/standby/XCGOV_20180919.dbf
    destination for restore of datafile 00057: /oracle_nas/wangzhanqun116/standby/xc_zjj_01.dbf
    channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2vuhol18.bak
    channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2vuhol18.bak tag=ZENGLIANG
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:04:35
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    destination for restore of datafile 00024: /u01/app/oradata/standby/XC_TYJ.dbf
    destination for restore of datafile 00025: /u01/app/oradata/standby/XC_GLJ.dbf
    destination for restore of datafile 00029: /u01/app/oradata/standby/XC_WGXJ.dbf
    destination for restore of datafile 00031: /u01/app/oradata/standby/XC_SWJ.dbf
    destination for restore of datafile 00032: /u01/app/oradata/standby/XC_DZJ.dbf
    destination for restore of datafile 00082: /oracle_nas/wangzhanqun116/standby/XC_KFQ02.dbf
    channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_32uholcb.bak
    channel ORA_DISK_1: piece handle=/u01/rman/zengliang_32uholcb.bak tag=ZENGLIANG
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    destination for restore of datafile 00033: /u01/app/oradata/standby/XC_SYJ.dbf
    destination for restore of datafile 00034: /u01/app/oradata/standby/XC_GSJ.dbf
    destination for restore of datafile 00035: /u01/app/oradata/standby/XC_SJJ.dbf
    destination for restore of datafile 00036: /u01/app/oradata/standby/XC_RSJ.dbf
    destination for restore of datafile 00038: /u01/app/oradata/standby/XC_WJW.dbf
    destination for restore of datafile 00083: /oracle_nas/wangzhanqun116/standby/XC_KFQ01.dbf
    channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_33uholfa.bak
    channel ORA_DISK_1: piece handle=/u01/rman/zengliang_33uholfa.bak tag=ZENGLIANG
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    destination for restore of datafile 00059: /oracle_nas/wangzhanqun116/standby/xc_zjj_02.dbf
    destination for restore of datafile 00061: /oracle_nas/wangzhanqun116/standby/xc_ylx_02.dbf
    destination for restore of datafile 00087: /oracle_nas/wangzhanqun116/standby/XC_RSJ02.dbf
    channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_35uholjn.bak
    channel ORA_DISK_1: piece handle=/u01/rman/zengliang_35uholjn.bak tag=ZENGLIANG
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    destination for restore of datafile 00040: /u01/app/oradata/standby/XC_JIAOTJ.dbf
    destination for restore of datafile 00041: /u01/app/oradata/standby/XC_ZJJ.dbf
    destination for restore of datafile 00042: /u01/app/oradata/standby/XC_CGJ.dbf
    destination for restore of datafile 00043: /u01/app/oradata/standby/XC_GJJ.dbf
    destination for restore of datafile 00044: /u01/app/oradata/standby/XC_XMJ.dbf
    destination for restore of datafile 00084: /oracle_nas/wangzhanqun116/standby/XC_NYJ01.dbf
    channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_34uholge.bak
    channel ORA_DISK_1: piece handle=/u01/rman/zengliang_34uholge.bak tag=ZENGLIANG
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    destination for restore of datafile 00003: /u01/app/oradata/standby/undotbs01.dbf
    destination for restore of datafile 00060: /oracle_nas/wangzhanqun116/standby/testnas.dbf
    destination for restore of datafile 00062: /oracle_nas/wangzhanqun116/standby/cs.dbf
    channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_36uholm2.bak
    channel ORA_DISK_1: piece handle=/u01/rman/zengliang_36uholm2.bak tag=ZENGLIANG
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
    channel ORA_DISK_1: starting incremental datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    destination for restore of datafile 00004: /u01/app/oradata/standby/users01.dbf
    destination for restore of datafile 00053: /u01/app/oradata/standby/xcgov_test.dbf
    destination for restore of datafile 00068: /oracle_nas/wangzhanqun116/standby/xcgov01.dbf
    destination for restore of datafile 00069: /oracle_nas/wangzhanqun116/standby/xcgov02.dbf
    channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2luhokf9.bak
    channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2luhokf9.bak tag=ZENGLIANG
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:53:05
    
    Finished recover at 25-NOV-19
    
    RMAN> 
    
    

    9、恢复中备库的日志

    adrci> show alert -tail -f
    2019-11-25 15:57:00.837000 +08:00
    Incremental restore complete of datafile 84 /oracle_nas/wangzhanqun116/standby/XC_NYJ01.dbf
      checkpoint is 595658251
    2019-11-25 15:57:09.833000 +08:00
    Incremental restore complete of datafile 62 /oracle_nas/wangzhanqun116/standby/cs.dbf
      checkpoint is 595658895
    2019-11-25 15:57:11.995000 +08:00
    Incremental restore complete of datafile 60 /oracle_nas/wangzhanqun116/standby/testnas.dbf
      checkpoint is 595658895
    2019-11-25 15:57:38.240000 +08:00
    Incremental restore complete of datafile 3 /u01/app/oradata/standby/undotbs01.dbf
      checkpoint is 595658895
    2019-11-25 15:58:25.986000 +08:00
    Incremental restore complete of datafile 4 /u01/app/oradata/standby/users01.dbf
      checkpoint is 595651669
    2019-11-25 16:50:20.382000 +08:00
    Incremental restore complete of datafile 53 /u01/app/oradata/standby/xcgov_test.dbf
      checkpoint is 595651669
    2019-11-25 16:50:48.643000 +08:00
    Incremental restore complete of datafile 69 /oracle_nas/wangzhanqun116/standby/xcgov02.dbf
      checkpoint is 595651669
    Incremental restore complete of datafile 68 /oracle_nas/wangzhanqun116/standby/xcgov01.dbf
      checkpoint is 595651669
    

    增量恢复备库完毕

    10、让备库开启mrp,把主库的redo刷到备库

    这一步比较重要,如果跳过这步直接open,数据库会提示

    ORA-10458: standby database requires recovery
    ORA-01152: file 1 was not restored from a sufficiently old backup 
    ORA-01110: data file 1: '/u01/app/oradata/standby/system01.dbf'
    

    下面是通过mrp把主库日志写到备库再同步。

    SQL> alter database recover managed standby database using current logfile disconnect;
    

    这期间备库日志
    在这里插入图片描述

    开启mrp后,备库缺少的日志,主库会自动去写

    11、在主库切几回日志,看下主库备库日志序列
    主库

    alter system switch logfile;
    SQL> archive log list
    Database log mode              Archive Mode
    Automatic archival             Enabled
    Archive destination            /u01/app/archlog/
    Oldest online log sequence     78077
    Next log sequence to archive   0
    Current log sequence           78079
    

    备库

    SQL> archive log list
    Database log mode              Archive Mode
    Automatic archival             Enabled
    Archive destination            /u01/app/archlog/
    Oldest online log sequence     78077
    Next log sequence to archive   0
    Current log sequence           78079
    

    主库备库日志序列已同步

    12、open备库

    刚才已经在备库用mrp同步日志了,为了open先cancel
    SQL> alter database recover managed standby database cancel;
    
    Database altered.
    
    SQL> alter database open;
    
    Database altered.
    再次开启mrp
    SQL> alter database recover managed standby database using current logfile disconnect;
    
    Database altered.
    
    SQL> select database_role,open_mode from v$database;
    
    DATABASE_ROLE    OPEN_MODE
    ---------------- --------------------
    PHYSICAL STANDBY READ ONLY WITH APPLY
    
    
    SQL> archive log list;
    Database log mode              Archive Mode
    Automatic archival             Enabled
    Archive destination            /u01/app/archlog/
    Oldest online log sequence     78077
    Next log sequence to archive   0
    Current log sequence           78079
    

    备库已开启mrp实时同步,并且日志序列与主库同步

    13、手动验证
    后面主库与备库手动验证数据一致性,没问题

    在这里插入图片描述
    在这里插入图片描述

    展开全文
  • 关于Oracle10g Data Gurad的搭建,虽然官方和网上有很多资料,但是基于物理冷备份后复制到备库的搭建方式。在生产环境中我们可能更多要关注主库的可用性,这是Rman的高级备份恢复功能完全胜任这些需求。 主库服务器...

    关于Oracle10g Data Gurad的搭建,虽然官方和网上有很多资料,但是基于物理冷备份后复制到备库的搭建方式。在生产环境中我们可能更多要关注主库的可用性,这是Rman的高级备份恢复功能完全胜任这些需求。

    主库服务器名:dbserv ip:192.168.2.3 主库DB_UNIQUE_NAME='testdb'

    备库服务器名:dbservdg ip:192.168.2.4 备库db_unique_name='testdbDG'

    数据库名:testdb

    DG安装过成大致分为如下几个重要步骤:

    1、备库安装数据库软件(仅安装软件,不必创建数据库)

    2、主库通过Rman进行全备份,备份脚本如下:

    run{

    DELETE NOPROMPT expired archivelog ALL;

    allocate channel d1 TYPE disk maxpiecesize=30G;

    allocate channel d2 TYPE disk maxpiecesize=30G;

    backup DATABASE include CURRENT controlfile for standby format '/backup/rman_full/data_%d_%T_%s_%p' plus archivelog format '/backup/rman_full/arch_%d_%T_%s' DELETE ALL INPUT;

    release channel d1;

    release channel d2;

    crosscheck backup;

    DELETE noprompt obsolete REDUNDANCY 2;

    }

    [@more@]

    3、将主库Rman全备份的迁移至备库服务器对应的目录(在备库执行)。

    scp oracle@192.168.2.3:/backup/rman_full/* /backup/rman_full/

    为了Rman恢复顺利进行,主库将全备份最好传输到相同目录结构。加入主库存储目录为/backup/rman_full,则在备库也要建立目录相同的目录并给于相应权限。

    如果无法建立相同目录,则可以通过建立OS连接命令来处理,如下假如将备份传到备库/backup/rman/full目录的具体配置过程:

    在备库:

    mkdir –p /backup/rman_full

    chown –R oracle:oinstall /backup/rman_full

    ln –s /backup/rman/full/* /backup/rman_full

    4、确认主库处于归档模式,如果不是改为归档模式

    SQL> archive log list

    5、 设置主库强制logging

    SQL> alter database force logging;

    6、配置主备库监听和TNS配置文件

    主库监听和TNS配置:

    [oracle@dbserv admin]$ pwd

    /opt/oracle/product/10.2.0/db_1/network/admin

    [oracle@dbserv admin]$ more listener.ora

    # listener.ora Network Configuration File: /opt/oracle/product/10.2.0/db_1/network/admin/listener.ora

    # Generated by Oracle configuration tools.

    SID_LIST_LISTENER =

    (SID_LIST =

    (SID_DESC =

    (SID_NAME = PLSExtProc)

    (ORACLE_HOME = /opt/oracle/product/10.2.0/db_1)

    (PROGRAM = extproc)

    )

    (SID_DESC =

    (GLOBAL_DBANAME = testdb)

    (ORACLE_HOME = /opt/oracle/product/10.2.0/db_1)

    (SID_NAME = testdb)

    )

    )

    LISTENER =

    (DESCRIPTION_LIST =

    (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dbserv)(PORT = 1521))

    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

    )

    )

    [oracle@dbserv admin]$

    [oracle@dbserv admin]$ more tnsnames.ora

    # tnsnames.ora Network Configuration File: /opt/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora

    # Generated by Oracle configuration tools.

    testdb =

    (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dbserv)(PORT = 1521))

    (CONNECT_DATA =

    (SERVER = DEDICATED)

    (SERVICE_NAME = testdb)

    )

    )

    testdb.STD =

    (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.4)(PORT = 1521))

    (CONNECT_DATA =

    (SERVER = DEDICATED)

    (SERVICE_NAME = testdb)

    )

    )

    EXTPROC_CONNECTION_DATA =

    (DESCRIPTION =

    (ADDRESS_LIST =

    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

    )

    (CONNECT_DATA =

    (SID = PLSExtProc)

    (PRESENTATION = RO)

    )

    )

    [oracle@dbserv admin]$

    备库监听和TNS配置:

    [oracle@dbservdg admin]$ pwd

    /opt/oracle/product/10.2.0/db_1/network/admin

    [oracle@dbservdg admin]$ more listener.ora

    # listener.ora Network Configuration File: /opt/oracle/product/10.2.0/db_1/network/admin/listener.ora

    # Generated by Oracle configuration tools.

    SID_LIST_LISTENER =

    (SID_LIST =

    (SID_DESC =

    (SID_NAME = PLSExtProc)

    (ORACLE_HOME = /opt/oracle/product/10.2.0/db_1)

    (PROGRAM = extproc)

    )

    (SID_DESC =

    (GLOBAL_DBANAME = testdb)

    (ORACLE_HOME = /opt/oracle/product/10.2.0/db_1)

    (SID_NAME = testdb)

    )

    )

    LISTENER =

    (DESCRIPTION_LIST =

    (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dbservdg)(PORT = 1521))

    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

    )

    )

    [oracle@dbservdg admin]$

    [oracle@dbservdg admin]$ more tnsnames.ora

    # tnsnames.ora Network Configuration File: /opt/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora

    # Generated by Oracle configuration tools.

    testdb =

    (DESCRIPTION =

    (ADDRESS_LIST =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.3)(PORT = 1521))

    )

    (CONNECT_DATA =

    (SERVICE_NAME = testdb)

    )

    )

    testdb.STD =

    (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.4)(PORT = 1521))

    (CONNECT_DATA =

    (SERVER = DEDICATED)

    (SERVICE_NAME = testdb)

    )

    )

    EXTPROC_CONNECTION_DATA =

    (DESCRIPTION =

    (ADDRESS_LIST =

    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

    )

    (CONNECT_DATA =

    (SID = PLSExtProc)

    (PRESENTATION = RO)

    )

    )

    [oracle@dbservdg admin]$

    7、 复制密码文件到Standby端

    scp oracle@192.168.2.3:/opt/oracle/product/10.2.0/db_1/dbs/orapwtestdb /opt/oracle/product/10.2.0/db_1/dbs/orapwtestdb

    8、 在Standby端创建目录结构

    su – root

    mkdir -p /opt/oracle/admin/testdb/adump

    mkdir -p /opt/oracle/admin/testdb/bdump

    mkdir -p /opt/oracle/admin/testdb/cdump

    mkdir -p /opt/oracle/admin/testdb/udump

    mkdir -p /oradata/testdb/

    mkdir–p /bakup/archive/

    chown –R oracle:oinstall /opt/oracle/admin/testdb/

    chown –R oracle:oinstall /oradata/testdb/

    chown –R oracle:oinstall /bakup/archive/

    9、 手工创建并配置备库初始化参数文件

    主库初始化文件的导出并修改,以便用于备库初始化个文件:

    [oracle@dbserv ~]$ cd /opt/oracle/product/10.2.0/db_1/dbs/

    [oracle@dbserv dbs]$ ls

    alert_testdb.log hc_testdb.dat initdw.ora inittestdb.ora0717.bak orapwtestdb spfiletestdb.ora

    init.ora inittestdb.ora lktestdb snapcf_testdb.f spfiletestdb_bak.ora

    [oracle@dbserv dbs]$ sqlplus / as sysdba

    SQL> create pfile='/tmp/inittestdb.ora' from spfile;

    File created.

    scp oracle@192.168.2.3:/tmp/inittestdb.ora /opt/oracle/product/10.2.0/db_1/dbs/

    修改从主库传过来的初始化文件,将其符合备库初始化文件的要求:

    [oracle@dbservdg dbs] cd /opt/oracle/product/10.2.0/db_1/dbs/

    [oracle@dbservdg dbs]$ vi inittestdb.ora

    testdb.__db_cache_size=2952790016

    testdb.__java_pool_size=50331648

    testdb.__large_pool_size=16777216

    testdb.__shared_pool_size=704643072

    testdb.__streams_pool_size=0

    *.audit_file_dest='/opt/oracle/admin/testdb/adump'

    *.background_dump_dest='/opt/oracle/admin/testdb/bdump'

    *.compatible='10.2.0.5.0'

    *.control_files='/oradata/testdb/control01.ctl','/oradata/testdb/control02.ctl','/oradata/testdb/control03.ctl'#Restore Controlfile

    *.core_dump_dest='/opt/oracle/admin/testdb/cdump'

    *.db_block_size=8192

    *.db_domain=''

    *.db_file_multiblock_read_count=16

    *.db_file_name_convert='/oradata/testdb','/oradata/testdb'

    *.db_name='testdb'

    *.db_recovery_file_dest='/bakup/flash_recovery_area'

    *.db_recovery_file_dest_size=2147483648

    *.db_unique_name='testdbDG'

    *.dispatchers='(PROTOCOL=TCP) (SERVICE=testdbXDB)'

    *.fal_client='testdb.STD'

    *.fal_server='testdb'

    *.job_queue_processes=10

    *.log_archive_config='dg_config=(testdb,testdbDG)'

    *.log_archive_dest_1='location=/bakup/archive LGWR VALID_FOR=(ALL_LOGFILES,ALL_ROLES) db_unique_name=testdbDG'

    *.log_archive_dest_2='SERVICE=testdb VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=testdb'

    *.log_archive_dest_state_1='ENABLE'

    *.log_archive_dest_state_2='ENABLE'

    *.log_file_name_convert='/oradata/testdb','/oradata/testdb','/bakup/archive','/bakup/archive'

    *.open_cursors=300

    *.pga_aggregate_target=1244659712

    *.processes=600

    *.remote_login_passwordfile='EXCLUSIVE'

    *.sessions=665

    *.sga_target=3735027712

    *.standby_archive_dest='/bakup/archive'

    *.standby_file_management='auto'

    *.undo_management='AUTO'

    *.undo_tablespace='UNDOTBS1'

    *.user_dump_dest='/opt/oracle/admin/testdb/udump'

    sqlplus / as sysdba

    SQL> create spfile from pfile;

    SQL> startup nomount;

    10、 使用rman duplicate 恢复standby数据库

    (在备库上执行)

    rman target sys/abc123@testdb auxiliary /

    rman> duplicate target database for standby;

    11、如果要实现real time apply 需要在备库创建STANDBY LOGFILE,否则可以忽略此步骤

    在单节点主库环境下,如果主库有四组日志文件组,因此备库应添加(4+1)*1=5组standby日志文件组

    TANDBY LOGFILE的大小必须(不能小于)等于主库日志文件大小。

    SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 11

    '/oradata/testdb/standby_redo01.log' size 524288000;

    SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 12

    '/oradata/testdb/standby_redo02.log' size 524288000;

    SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 13

    '/oradata/testdb/standby_redo03.log' size 524288000;

    SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 14

    '/oradata/testdb/standby_redo04.log' size 524288000;

    SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 15

    '/oradata/testdb/standby_redo05.log' size 524288000;

    SQL> SELECT * FROM V$STANDBY_LOG;

    12、 启动Standby

    SQL>ALTER DATABASE recover managed standby database disconnect from session;

    如果用real time apply则(可选)

    SQL>ALTER DATABASE recover managed standby database using current logfile disconnect;

    SQL>alter system set log_archive_dest_2='SERVICE=testdb.STD LGWR ASYNC NOAFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=testdbDG';

    13、配置Primary,通过spfile文件动态修改方法可以保证主库可用性并业务不受影响

    SQL>alter system set log_archive_config='DG_CONFIG=(testdb,testdbDG)';

    SQL>alter system set log_archive_dest_1='location=/bakup/archive VALID_FOR=(ALL_LOGFILES,ALL_ROLES) db_unique_name=testdb';

    SQL>alter system set log_archive_dest_2='SERVICE=testdb.STD VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=testdbDG';

    SQL>alter system set db_file_name_convert=''/oradata/testdb','/oradata/testdb' ;

    SQL>alter system set log_file_name_convert='/oradata/testdb','/oradata/testdb','/bakup/archive','/bakup/archive';

    SQL>alter system set standby_file_management=auto;

    SQL>alter system set fal_server='testdb.STD';

    SQL>alter system set fal_client='testdb';

    SQL>alter system set log_archive_dest_state_1='ENABLE';

    SQL>alter system set log_archive_dest_state_2='ENABLE';

    查看主库完整初始化文件:

    [oracle@dbserv dbs]$ sqlplus / as sysdba

    SQL> create pfile='/tmp/inittestdb.ora' from spfile;

    File created.

    [oracle@dbserv ~]$ cd /tmp

    [oracle@dbserv tmp]$ more inittestdb.ora

    testdb.__db_cache_size=6492782592

    testdb.__java_pool_size=16777216

    testdb.__large_pool_size=16777216

    testdb.__shared_pool_size=973078528

    testdb.__streams_pool_size=0

    *.audit_file_dest='/opt/oracle/admin/testdb/adump'

    *.background_dump_dest='/opt/oracle/admin/testdb/bdump'

    *.compatible='10.2.0.5.0'

    *.control_files='/oradata/testdb/control01.ctl','/oradata/testdb/control02.ctl','/oradata/testdb/control03.ctl'

    *.core_dump_dest='/opt/oracle/admin/testdb/cdump'

    *.db_block_size=8192

    *.db_domain=''

    *.db_file_multiblock_read_count=16

    *.db_file_name_convert='/oradata/testdb','/oradata/testdb'

    *.db_name='testdb'

    *.db_recovery_file_dest='/bakup/flash_recovery_area'

    *.db_recovery_file_dest_size=2147483648

    *.DB_UNIQUE_NAME='testdb'

    *.dispatchers='(PROTOCOL=TCP) (SERVICE=testdbXDB)'

    *.FAL_CLIENT='testdb'

    *.FAL_SERVER='testdb.STD'

    *.job_queue_processes=10

    *.log_archive_config='DG_CONFIG=(testdb,testdbDG)'

    *.log_archive_dest_1='location=/bakup/archive VALID_FOR=(ALL_LOGFILES,ALL_ROLES) db_unique_name=testdb'

    *.log_archive_dest_2='SERVICE=testdb.STD VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=testdbDG'

    *.log_archive_dest_state_1='ENABLE'

    *.log_archive_dest_state_2='ENABLE'

    *.log_file_name_convert='/oradata/testdb','/oradata/testdb','/bakup/archive','/bakup/archive'

    *.open_cursors=1000

    *.pga_aggregate_target=2503999488

    *.processes=600

    *.remote_login_passwordfile='EXCLUSIVE'

    *.sessions=665

    *.sga_target=7514095616

    *.standby_archive_dest='/bakup/archive'

    *.standby_file_management='AUTO'

    *.undo_management='AUTO'

    *.undo_tablespace='UNDOTBS1'

    *.user_dump_dest='/opt/oracle/admin/testdb/udump'

    [oracle@dbserv tmp]$

    14、检查备库状态

    SQL>SELECT DATABASE_ROLE, PROTECTION_MODE, SWITCHOVER_STATUS, FLASHBACK_ON FROM v$database;

    SQL>SELECT PROCESS, CLIENT_PROCESS, SEQUENCE#, STATUS FROM V$MANAGED_STANDBY;

    SQL>SELECT DEST_ID,ARCHIVED_THREAD#, ARCHIVED_SEQ#, APPLIED_THREAD#, APPLIED_SEQ# FROM V$ARCHIVE_DEST_STATUS;

    SQL>Select max(SEQUENCE#) from v$archived_log al,v$database db

    2>where al.RESETLOGS_CHANGE#=db.RESETLOGS_CHANGE#

    2>and al.APPLIED='YES';

    15验证

    Standby端:

    select sequence#, thread#, applied from v$archived_log order by sequence#;

    Primary端:

    SQL>alter database set standby database to maximize AVAILABILITY;

    SQL>conn system/onewave

    SQL>create table t tablespace users as select * from dba_objects;

    SQL>alter system archive log current;

    Standby端:

    select sequence#, thread#, applied from v$archived_log order by sequence#;

    ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

    ALTER DATABASE OPEN;

    select count(*) from system.t;

    表中有记录,说明备库已应用日志。

    来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/18841027/viewspace-1059101/,如需转载,请注明出处,否则将追究法律责任。

    转载于:http://blog.itpub.net/18841027/viewspace-1059101/

    展开全文
  • 这里记录一下流程,有我和同事问心进行测试 dataguard主库和物理备库主要是controlfile文件有区别,用restore可以查看含有primary,standby关键字 RMAN> restore ; ...
    这里记录一下流程,有我和同事问心进行测试

    dataguard主库和物理备库主要是controlfile文件有区别,用restore可以查看含有primary,standby关键字
    RMAN> restore ;


    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-00558: error encountered while parsing input commands
    RMAN-01009: syntax error: found ";": expecting one of: "archivelog, channel, check, controlfile, database, datafile, device, force, from, high, preview, primary, skip readonly, spfile, standby, tablespace, to restore point, until restore point, until, validate, ("
    RMAN-01007: at line 1 column 9 file: standard input




    RMAN> restore primary;


    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-00558: error encountered while parsing input commands
    RMAN-01009: syntax error: found ";": expecting one of: "controlfile"
    RMAN-01007: at line 1 column 16 file: standard input






    利用物理备库rman备份文件恢复过程:


    SQL> startup nomount;
    ORACLE instance started.


    Total System Global Area 1043886080 bytes
    Fixed Size                  2259840 bytes
    Variable Size             775947392 bytes
    Database Buffers          260046848 bytes
    Redo Buffers                5632000 bytes


    [oracle@std]$ rman target/


    Recovery Manager: Release 11.2.0.4.0 - Production on Mon Sep 26 15:09:14 2016


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


    connected to target database: DG (not mounted)


    RMAN> restore primary controlfile from '/u01/app/oracle/product/11.2.0/dbhome1/dbs/c-1832575162-20160926-01';


    Starting restore at 26-SEP-16
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=10 device type=DISK


    channel ORA_DISK_1: restoring control file
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
    output file name=/u01/app/oracle/oradata/dg/control01.ctl
    output file name=/u01/app/oracle/oradata/dg/control02.ctl
    Finished restore at 26-SEP-16


    RMAN> sql 'alter database mount';


    sql statement: alter database mount
    released channel: ORA_DISK_1


    SQL> select open_mode,database_role from v$database;


    OPEN_MODE                                                    DATABASE_ROLE
    ------------------------------------------------------------ ------------------------------------------------
    MOUNTED                                                      PRIMARY




    RMAN> restore database;


    Starting restore at 26-SEP-16
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=10 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 /u01/app/oracle/oradata/dg/system01.dbf
    channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/dg/sysaux01.dbf
    channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/dg/undotbs01.dbf
    channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/dg/users01.dbf
    channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/dg/example01.dbf
    channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/dg/lieb01.dbf
    channel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/11.2.0/dbhome1/dbs/19rgpgsu_1_1
    channel ORA_DISK_1: piece handle=/u01/app/oracle/product/11.2.0/dbhome1/dbs/19rgpgsu_1_1 tag=TAG20160926T145629
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:01:56
    Finished restore at 26-SEP-16




    RMAN> recover database;


    Starting recover at 26-SEP-16
    using channel ORA_DISK_1


    starting media recovery


    archived log for thread 1 with sequence 0 is already on disk as file /u01/app/oracle/oradata/dg/redo03.log
    channel ORA_DISK_1: starting archived log restore to default destination
    channel ORA_DISK_1: restoring archived log
    archived log thread=1 sequence=19
    channel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/11.2.0/dbhome1/dbs/18rgpgss_1_1
    channel ORA_DISK_1: piece handle=/u01/app/oracle/product/11.2.0/dbhome1/dbs/18rgpgss_1_1 tag=TAG20160926T145628
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
    archived log file name=/home/oracle/archivelog/DG/1_19_922121441.dbf thread=1 sequence=19
    channel ORA_DISK_1: starting archived log restore to default destination
    channel ORA_DISK_1: restoring archived log
    archived log thread=1 sequence=20
    channel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/11.2.0/dbhome1/dbs/1argph09_1_1
    channel ORA_DISK_1: piece handle=/u01/app/oracle/product/11.2.0/dbhome1/dbs/1argph09_1_1 tag=TAG20160926T145817
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
    archived log file name=/home/oracle/archivelog/DG/1_20_922121441.dbf thread=1 sequence=20
    unable to find archived log
    archived log thread=1 sequence=21
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of recover command at 09/26/2016 15:20:49
    RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 21 and starting SCN of 1402274








    SQL> alter database open resetlogs;


    Database altered.


    SQL> select open_mode,database_role from v$database;


    OPEN_MODE            DATABASE_ROLE
    -------------------- ----------------
    READ WRITE           PRIMARY

    作者微信:

                   

    来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7728585/viewspace-2138061/,如需转载,请注明出处,否则将追究法律责任。

    转载于:http://blog.itpub.net/7728585/viewspace-2138061/

    展开全文
  • 公司Oracle备份策略是10G采用DG主库每天Rman一全备份+expdp备份,11g采用的是DG从每天rman一全备份。最近在做恢复演练测试,在从库备份恢复时,由于控制文件是standby类型,无法直接打开数据库,也...
  • oracle dg备库恢复

    2020-06-22 21:08:48
    standbystandby状态下的备份方式如下,生成一个控制文件备份control_1,一个数据文件备份full_data RMAN> backup database format '/iso/backup/XX_%U'; primary的备份方式如下,并拷贝到standby的对应目录 ...
  • DG环境强制read write打开备库为主库,想要从主库重新拷贝控制文件给备库,进而再将其恢复备库状态。 操作流程: 1.从主库拷贝了一份控制文件 alter database create standby controlfile as '/home/oracle/...
  • standby库归档日志断档,故standby库不能利用恢复归档日志和生产保持同步,因生产有1T多,重拉数据将非常耗时,遂利用RMAN对生产进行增量备份,将增量备份集合成到standby库,利用此方法就跨过了被删除的归档...
  • 昨天凌晨磁盘空间突然暴涨导致oracle备库异常,报警,后了过来清理掉磁盘的备份文件,去了之后,归档日志能同步过来了,但是启动备库standby发现mrp没有启动,后台报错如下,google了,说这种情况要重新再做备库(不...
  • Oracle DG 备库恢复--gap

    2018-12-13 18:33:24
    数据库服务的过程中,经常有客户因备库服务器宕机导致备库无法...很明显,上面客户归档日志随着备份完成而清理,导致备库无法自动恢复。 下面模拟该场景的故障恢复。(一)测试环境主备 # 主、备库版本 SQL> s...
  • Oracle数据库日常运维中往往会碰到这种情况:DataGuard主库归档删了,备库由于缺少归档从而GAP报错,此时经常的做法是重新拉数据,如果数据量小还好,数据量TB级别了在加之网络带宽有限,这明显不是一个很好的解决...
  • 线上oracle datagard备库由于断电以及误删除从库的归档日志文件,所以导致,备库主库数据不一致,备库需要紧急恢复,下面是大概恢复过程1,从主库上面备份控制文件 [oracle@localhost rman_recover]$ rman target / ...
  • Oracle11g冷备份恢复

    2010-08-05 16:36:40
    Oracle11g冷备份恢复这两天恢复Oracle着实头疼了一把,我的环境是Cenos5.3+Oracle11g,正式服务器的数据库实例路径是:/app/oracle/oradata/databar,当初只备份了此目录下的文件:control01.ctlredo01.logredo02.log...
  • 一 实验目的此实验是建立在oracle DG架构基础之上。rman备份standby数据库。将现有standbyrman备份文件(在包含控制文件,参数文件...
  • Oracle Dataguard备库重建 1、添加oracle目录 mkdir /ora_data_1 mkdir /ora_data_2 mkdir /ora_data_3 2、修改目录权限 chown oracl...
  • 2017­8­4 文档836986.1 https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl­state=17m667jbn3_67&id=836986.1 1/7 StepstoperformforRollingForwardaPhysicalStandbyDatabaseusingRMA...
  • oracle standby

    千次阅读 2005-10-11 15:17:00
    首页PL/SQL数据库结构备份恢复性能优化OCP认证数据库理论其它数据库UNIX基础常用软件电子书籍<!--// var today = new Date(); var strDate = "" + (today.getYear() + "" + "年" + "" + (today.getMonth() + 1) + ...
  • Oracle10g备份恢复之物理备份--Rman备份 Recovery Manager(RMAN)是一种用于备份(backup)、还原(restore)和恢复(recover)数据库的 Oracle 工具。RMAN只能用于ORACLE8或更高的版本中。它能够备份整个数据库或...
  • Oracle Standby Database 实现方案 From: http://wanow.blog.hexun.com/4672755_d.html 字号:大 中 小 版本:V20060328.01.01 Standby Database的工作原理 1. Oracle 与 High Availability, Disaster ...
  • oracle standby数据库

    2013-12-24 14:32:23
    从设计原理上来讲,standby database 是为 primary database 建立的备份,因此具有 redundance data,也是相对于 database 来说的 high availability; standby database 为 primary database 做的备份,是通过 ...
  • 1. 在主库上,关闭archive log传送:SQL> alter system set log_archive_dest_2='; 2. 在备库上,用sys用户登陆,停止日志的应用:SQL> alter data...
  • 背景描述:Oraclestandby库后台alert报错,如下: ORA-00354: corrupt redo log block header ORA-00353: log corruption near block 10240change 11125950022 time 05/08/2015 22:00:41 ORA-00334: archived...
  • Oracle Standby教程

    千次阅读 2010-10-11 13:59:00
    ORACLE双机教程1. 双机热备的概念 双机热备这一概念包括了广义与狭义两种意义。 从广义上讲,双机热备(双机容错)就是对于重要的服务,使用两台服务器,互相备份,共同执行同一服务。当一台服务器...
  • Oracle数据库的备份恢复Oracle数据库的使用过程中,备份恢复是经常遇到的操作。Oracle中的备份分为两大类:逻辑备份和物理备份。其中物理备份又分为两类:冷备份和热备份。本节将简要讲述如何利用各种备份...
  • 在某些情况下,主服务器可能损坏一个或两个数据文件,如果从主数据库上的备份恢复,理论上也是可以的, 但是可能会因为需要应用到太多的日志,实际耗时太大,这个时候, 我们可以考虑从备份服务器上恢复该数据文件,...
  • 然后从主库,备库1 都能用SYS用户登陆到备库2 表示通道是联通有效的.02: 从主库生成个最新的INIT.ORA文件,复制到备库2 修改参数文件的参数.然后 启动 并且生成SPFILE文件再启动 dg2: startup nomount pfile='/home/...
  • 使用基于scn的增量备份恢复DG备库

    千次阅读 2018-04-29 15:15:35
    场景:主库定时清理归档任务失败,报错备库仍需要这些归档来应用不可删除,以下是报错信息: RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process 查看备库alert...
  • Oracle 版本 10.2.0.5.0。 因为要重建逻辑备库,所以准备先建个物理备库。...同时已经有了一个物理备库,并有一个物理备库的全备份: 尝试了下面两种方式,都报ORA-19764,有如下疑问: 物理备库的控制文件...
  • 常用的在线备库搭建有Rman auxiliary 和Rman备份恢复两种方式。(一)在环境配置OK的问题下,使用一条Rman命令就可以完成备库初始化同步,比较简单。#登陆rmantargetsys/Oracle123@orcl_priauxiliarysys/Oracle123...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 8,107
精华内容 3,242
关键字:

oraclestandby备库备份恢复