zoukankan      html  css  js  c++  java
  • oracle数据库灾难恢复

    环境:oracle12c

    执行恢复
    数据库打开条件
    1)所有控制文件存在并且一致性
    2)所有数据文件(ONLINE状态)存在并且一致性
    3)每个重做日志组至少有一个成员是存在

    DRA Data Recovery Advisor   列出故障、提供修复的建议、执行修复

    常见的故障恢复

    1、loss of password file   --密码文件丢失

    rman的不备份的password file
    [oracle@12c dbs]$ ll $ORACLE_HOME/dbs/orapworcl    --密码文件路径
    -rw-r-----. 1 oracle oinstall 4096 Jul  6 15:46 /u01/app/oracle/product/12.2.0.1/db_1/dbs/orapworcl
    [oracle@12c dbs]$ file orapworcl 
    orapworcl: data
    [oracle@12c dbs]$ rm -vf orapworcl     --删除密码文件
    [oracle@12c dbs]$ sqlplus / as sysdba  --使用os系统认证可以登录OK
    [oracle@12c dbs]$ sqlplus hr/hr@192.168.95.150:1521/orcl.oracle.com  --OK
    --故障提现,下面方式不能登录
    [oracle@12c dbs]$ sqlplus sys/oracle@orcl as sysdba  TNS方式
    [oracle@12c dbs]$ sqlplus sys/oracle@192.168.95.150:1521/orcl.oracle.com as sysdba  ---EZConnection方式
    SQL> grant sysdba to hr;
    grant sysdba to hr
    *
    ERROR at line 1:
    ORA-01994: GRANT failed: password file missing or disabled
    通过工具orapwd工具来重新创建密码文件
    [oracle@12c dbs]$ which orapwd
    /u01/app/oracle/product/12.2.0.1/db_1/bin/orapwd
    [oracle@12c dbs]$ orapwd --help
    
    [oracle@12c dbs]$ orapwd file=$ORACLE_HOME/dbs/orapworcl password=yinhe  format=12  --format指定12c 用户要多几个比以前版本
    [oracle@12c dbs]$ ll orapworcl 
    -rw-r-----. 1 oracle oinstall 2048 Jul 13 16:10 orapworcl
    
    [oracle@12c dbs]$ sqlplus sys/yinhe@orcl as sysdba
    [oracle@12c dbs]$ sqlplus sys/yinhe@192.168.95.150:1521/orcl.oracle.com  as sysdba
    SQL> grant sysdba to hr;

    2、loss of a control file  --控制文件丢失

    控制文件保存在文件系统或者ASM磁盘中
    show parameter control_files
    NAME          TYPE   VALUE                                                                                        
    ------------- ------ -------------------------------------------------------------------------------------------- 
    control_files string /u01/app/oracle/oradata/orcl/control01.ctl, /u02/app/oracle/fast_recovery/ORCL/control02.ctl 
    
    SELECT value FROM v$parameter2
    WHERE name='control_files';
    /u01/app/oracle/oradata/orcl/control01.ctl
    /u02/app/oracle/fast_recovery/ORCL/control02.ctl
    模拟丢失一个控制文件
    [oracle@12c ORCL]$ rm -vf control02.ctl 
    SQL> shutdown immediate;
    ORA-00210: cannot open the specified control file
    ORA-00202: control file: '/u02/app/oracle/fast_recovery/ORCL/control02.ctl'
    ORA-27041: unable to open file
    Linux-x86_64 Error: 2: No such file or directory
    Additional information: 3
    SQL> shutdown abort;
    
    [oracle@12c dbs]$ sqlplus  / as sysdba
    SQL> startup nomount;
    SQL> ALTER DATABASE MOUNT;
    ALTER DATABASE MOUNT
    *
    ERROR at line 1:
    ORA-00205: error in identifying control file, check alert log for more info
    SQL> SELECT status FROM v$instance;   --当前数据库实例处于nomount状态
    STATUS
    ------------
    STARTED
    
    [oracle@12c trace]$ tail -f alert_orcl.log 
    Linux-x86_64 Error: 2: No such file or directory
    Additional information: 7
    ORA-205 signalled during: ALTER DATABASE MOUNT...
    2020-07-13T16:22:48.827023+08:00
    Errors in file /u01/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_m000_21661.trc:
    ORA-00202: control file: '/u02/app/oracle/fast_recovery/ORCL/control02.ctl'
    ORA-27037: unable to obtain file status
    Linux-x86_64 Error: 2: No such file or directory
    [oracle@12c dbs]$ cp /u01/app/oracle/oradata/orcl/control01.ctl /u02/app/oracle/fast_recovery/ORCL/control02.ctl --控制文件多路复用,直接拷贝可用,不用再做恢复
    SQL> ALTER DATABASE MOUNT;
    Database altered.
    SQL> ALTER DATABASE OPEN;
    Database altered.
    
    
    [oracle@12c ORCL]$ export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
    [oracle@12c ORCL]$ echo $NLS_DATE_FORMAT
    
    3)loss of all control file
    SQL> shutdown abort;
    sql> startup nomount;
    RMAN> restore controlfile from '/u02/app/oracle/fast_recovery/ORCL/autobackup/2020_07_13/o1_mf_s_1045667839_hjr2mzpr_.bkp'; --还原以前的文件,和数据库记录不一致,需要recover
    Starting restore at 2020-07-13 16:35:59
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=37 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/orcl/control01.ctl
    output file name=/u02/app/oracle/fast_recovery/ORCL/control02.ctl
    Finished restore at 2020-07-13 16:36:01
    RMAN> ALTER DATABASE MOUNT;
    RMAN> recover database;
    RMAN> alter database open resetlogs;

    4)loss of a redo log file
    5)loss of all redo log group file
    6)loss of temporary datafile
    7)loss of a datafile in noarchivelog mode
    8)loss of a noncritical data file in archivelog mode
    9)loss of a system-critical data file in archivelog mode
    10)loss of a spifle

    做一个决定,并不难,难的是付诸行动,并且坚持到底。
  • 相关阅读:
    汇编指令
    汇编指令
    汇编指令
    字在寄存器中的存储
    汇编指令
    字在寄存器中的存储
    汇编指令
    8086CPU的8位寄存器数据存储情况
    [转载]使用嵌入式 Tomcat 简化程序调试
    [转载]Java语法总结
  • 原文地址:https://www.cnblogs.com/wukc/p/13289005.html
Copyright © 2011-2022 走看看