zoukankan      html  css  js  c++  java
  • (Les16 执行数据库恢复)-控制文件恢复

    测试丢失所有控制文件恢复[20180517]
     
     
    rman target /
     
    show all;
     
    configure channel 1 device type disk format '/u01/backup/rman_backup_%U.bak';
     
    backup current controlfile;
     
     
    连接到RMAN
    [oracle@t-xi-oracle01 archive]$ rman target /
     
    为磁盘备份设定路径和命名规则
    RMAN> configure channel 1 device type disk format '/u01/backup/rman_backup_%U.bak';
     
    new RMAN configuration parameters:
    CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT   '/u01/backup/rman_backup_%U.bak';
    new RMAN configuration parameters are successfully stored
     
    查看当前所有的配置
    RMAN> show all;
     
    using target database control file instead of recovery catalog
    RMAN configuration parameters for database with db_unique_name XIOCPT0 are:
    CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
    CONFIGURE BACKUP OPTIMIZATION OFF; # default
    CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
    CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
    CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
    CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
    CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
    CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
    CONFIGURE MAXSETSIZE TO UNLIMITED; # default
    CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
    CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
    CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
    CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
    CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_xiocpt0.f'; # default
     
    备份当前控制文件
    RMAN> backup current controlfile;
     
    Starting backup at 17-MAY-18
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=41 device type=DISK
    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 17-MAY-18
    channel ORA_DISK_1: finished piece 1 at 17-MAY-18
    piece handle=/u01/backup/rman_backup_01t34led_1_1.bak tag=TAG20180517T155453 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 17-MAY-18
     
    查看备份
    RMAN> list backup; 或 list backup of controlfile;
     
     
     
    List of Backup Sets
    ===================
     
     
    BS Key  Type LV Size       Device Type Elapsed Time Completion Time
    ------- ---- -- ---------- ----------- ------------ ---------------
    1       Full    9.64M      DISK        00:00:01     17-MAY-18
            BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20180517T155453
            Piece Name: /u01/backup/rman_backup_01t34led_1_1.bak
      Control File Included: Ckp SCN: 990446       Ckp time: 17-MAY-18
     
     
    select * from v$controfile;
     
    手动删除控制文件
    SQL> !rm -rf /u01/app/oracle/oradata/xiocpt0/control01.ctl /u01/app/oracle/fast_recovery_area/xiocpt0/control02.ctl
     
    Errors in file /u01/app/oracle/diag/rdbms/xiocpt0/xiocpt0/trace/xiocpt0_m001_1649.trc:
    ORA-00210: cannot open the specified control file
    ORA-00202: control file: '/u01/app/oracle/oradata/xiocpt0/control01.ctl'
    ORA-27041: unable to open file
    Linux-x86_64 Error: 2: No such file or directory
    Additional information: 3
     
    数据库关闭
    shutdown abort
     
    启动到nomount状态,从备份档中恢复控制文件,注意此时控制文件不是最新的
        

    [oracle@t-xi-oracle01 archive]$ rman target /

    RMAN>restore controlfile from  '/u01/backup/rman_backup_01t34led_1_1.bak';

    Starting restore at 17-MAY-18
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=20 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/xiocpt0/control01.ctl
    output file name=/u01/app/oracle/fast_recovery_area/xiocpt0/control02.ctl
    Finished restore at 17-MAY-18

     
    数据库启动MOUNT状态
    alter database mount;
     
    创建控制文件到trace文件中
    alter database backup controlfile to trace as '/u01/backup_controlfile.ctl';
     
    再次关闭数据库,手动恢复控制文件,数据库完整恢复。
    shutdown immedaite
     
    注意使用NORESETLOGS 
     
    STARTUP NOMOUNT
    CREATE CONTROLFILE REUSE DATABASE "XIOCPT0" NORESETLOGS  ARCHIVELOG
        MAXLOGFILES 16
        MAXLOGMEMBERS 3
        MAXDATAFILES 100
        MAXINSTANCES 8
        MAXLOGHISTORY 292
    LOGFILE
      GROUP 1 '/u01/app/oracle/oradata/xiocpt0/redo01.log'  SIZE 50M BLOCKSIZE 512,
      GROUP 2 '/u01/app/oracle/oradata/xiocpt0/redo02.log'  SIZE 50M BLOCKSIZE 512,
      GROUP 3 '/u01/app/oracle/oradata/xiocpt0/redo03.log'  SIZE 50M BLOCKSIZE 512
    -- STANDBY LOGFILE
    DATAFILE
      '/u01/app/oracle/oradata/xiocpt0/system01.dbf',
      '/u01/app/oracle/oradata/xiocpt0/sysaux01.dbf',
      '/u01/app/oracle/oradata/xiocpt0/undotbs01.dbf',
      '/u01/app/oracle/oradata/xiocpt0/users01.dbf'
    CHARACTER SET AL32UTF8
    ;
     
     
     
    RECOVER DATABASE
     
     
    ALTER SYSTEM ARCHIVE LOG ALL;
     
     
    ALTER DATABASE OPEN;
     
     
    ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/app/oracle/oradata/xiocpt0/temp01.dbf' REUSE;
     
     
  • 相关阅读:
    P1312 [NOIP2011 提高组] Mayan 游戏
    Codeforces Round 736
    CF487E Tourists
    荏苒
    数论
    [NOI2009] 二叉查找树 题解
    元素
    线性基
    杂录
    SQL中关于Join、Inner Join、Left Join、Right Join、Full Join、On、 Where区别
  • 原文地址:https://www.cnblogs.com/also-brook/p/9052028.html
Copyright © 2011-2022 走看看