IT开放社区

RMAN备份控制文件故障恢复实验

实验环境:

OS:Centos Linux 7.3

DB:Oracle11g(11.2.0.4)

第一步:RMAN备份控制文件;

[oracle@centos ~]$ mkdir -p control_bak
[oracle@centos ~]$ ls
afiedt.buf   Desktop    Downloads      Music     Public     Videos
control_bak  Documents  itkaifang_bak  Pictures  Templates
[oracle@centos ~]$ 
[oracle@centos ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sat Mar 25 16:45:48 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: CENTOS (DBID=3235228290)
RMAN> backup current controlfile format '/home/oracle/control_bak/con_1.bak';
Starting backup at 25-MAR-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=38 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 25-MAR-17
channel ORA_DISK_1: finished piece 1 at 25-MAR-17
piece handle=/home/oracle/control_bak/con_1.bak tag=TAG20170325T164908 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 25-MAR-17
RMAN> list backup of controlfile;

List of Backup Sets
===================
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
        Full    9.33M      DISK        00:00:02     25-MAR-17      
        BP Key: 8   Status: AVAILABLE  Compressed: NO  Tag: TAG20170325T164908
        Piece Name: /home/oracle/control_bak/con_1.bak
  Control File Included: Ckp SCN: 1202191      Ckp time: 25-MAR-17
RMAN>

第二步:找到控制文件,删除模拟故障;

centos@SYS> select name from v$controlfile;
NAME
----------------------------------------------
/u01/app/oracle/oradata/centos/control01.ctl
/u01/app/oracle/oradata/centos/control02.ctl
centos@SYS> !cd /u01/app/oracle/oradata/centos/
centos@SYS> !ls
control01.ctl  redo01.log  sysaux01.dbf  t2.dbf  users01.dbf
control02.ctl  redo02.log  system01.dbf  temp01.dbf
example01.dbf  redo03.log  t1.dbf  undotbs01.dbf
centos@SYS> !rm control01.ctl
centos@SYS> !ls
control02.ctl  redo01.log  redo03.log  system01.dbf  t2.dbf    undotbs01.dbf
example01.dbf  redo02.log  sysaux01.dbf  t1.dbf        temp01.dbf  users01.dbf
centos@SYS>

 第三步:重启数据库到nomount状态,启动至mount状态时报错,RMAN恢复控制文件,并启动至open状态;

centos@SYS> shutdown immediate
Database closed.
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/u01/app/oracle/oradata/centos/control01.ctl'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3

centos@SYS> shutdown abort
ORACLE instance shut down.
centos@SYS> startup nomount
ORACLE instance started.
Total System Global Area  830930944 bytes
Fixed Size      2257800 bytes
Variable Size    536874104 bytes
Database Buffers   289406976 bytes
Redo Buffers      2392064 bytes
centos@SYS> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-00205: error in identifying control file, check alert log for more info

centos@SYS>

RMAN恢复控制文件;

[oracle@centos ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Sat Mar 25 17:02:53 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: CENTOS (not mounted)
RMAN> restore controlfile from'/home/oracle/control_bak/con_1.bak';  ---->恢复控制文件
Starting restore at 25-MAR-17
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/centos/control01.ctl
output file name=/u01/app/oracle/oradata/centos/control02.ctl
Finished restore at 25-MAR-17
RMAN> alter database mount;   ---->启动数据库到mount状态
database mounted
released channel: ORA_DISK_1
RMAN> recover database;     ---->修复数据一致性
Starting recover at 25-MAR-17
Starting implicit crosscheck backup at 25-MAR-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
Crosschecked 7 objects
Finished implicit crosscheck backup at 25-MAR-17
Starting implicit crosscheck copy at 25-MAR-17
using channel ORA_DISK_1
Finished implicit crosscheck copy at 25-MAR-17
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 2 is already on disk as file /u01/app/oracle/oradata/centos/redo02.log
archived log file name=/u01/app/oracle/oradata/centos/redo02.log thread=1 sequence=2
media recovery complete, elapsed time: 00:00:00
Finished recover at 25-MAR-17
RMAN> alter database open resetlogs;    ---->启动数据库至open状态
database opened
RMAN>

实验完成查看数据库状态。

centos@SYS> select status from v$instance;
STATUS
------------
OPEN
centos@SYS>

 RMAN控制文件自动备份;

[oracle@centos ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Mar 27 14:49:00 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: CENTOS (DBID=3235228290)
RMAN> configure controlfile autobackup on;
using target database control file instead of recovery catalog
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
RMAN>
RMAN> list backup of controlfile;

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1       Full    9.33M      DISK        00:00:01     24-MAR-17      
        BP Key: 1   Status: EXPIRED  Compressed: NO  Tag: TAG20170324T143444
        Piece Name: /home/oracle/bak/con_01rvukk4_1_1.bak
  Control File Included: Ckp SCN: 1153244      Ckp time: 24-MAR-17
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2       Full    9.33M      DISK        00:00:01     24-MAR-17      
        BP Key: 2   Status: EXPIRED  Compressed: NO  Tag: TAG20170324T143645
        Piece Name: /home/oracle/bak/con_1.bak
  Control File Included: Ckp SCN: 1153374      Ckp time: 24-MAR-17
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
5       Full    9.36M      DISK        00:00:01     24-MAR-17      
        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20170324T143752
        Piece Name: /u01/app/oracle/flash/CENTOS/backupset/2017_03_24/o1_mf_ncsnf_TAG20170324T143752_df9hpjdz_.bkp
  Control File Included: Ckp SCN: 1153443      Ckp time: 24-MAR-17
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
7       Full    9.36M      DISK        00:00:01     24-MAR-17      
        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20170324T143944
        Piece Name: /u01/app/oracle/flash/CENTOS/backupset/2017_03_24/o1_mf_ncsnf_TAG20170324T143944_df9hss4z_.bkp
  Control File Included: Ckp SCN: 1153875      Ckp time: 24-MAR-17
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
8       Full    9.33M      DISK        00:00:01     27-MAR-17      
        BP Key: 8   Status: AVAILABLE  Compressed: NO  Tag: TAG20170327T145556
        Piece Name: /home/oracle/control_bak/con_2.bak
  Control File Included: Ckp SCN: 1248112      Ckp time: 27-MAR-17
BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
9       Full    9.36M      DISK        00:00:00     27-MAR-17                      ----->自动备份的控制文件
        BP Key: 9   Status: AVAILABLE  Compressed: NO  Tag: TAG20170327T145558
        Piece Name: /u01/app/oracle/flash/CENTOS/autobackup/2017_03_27/o1_mf_s_939740158_dfkfvyr0_.bkp
  Control File Included: Ckp SCN: 1248119      Ckp time: 27-MAR-17
RMAN>

相关文章

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

网站分类
站点信息
  • 文章总数:119
  • 页面总数:2
  • 分类总数:3
  • 标签总数:12
  • 评论总数:2
  • 浏览总数:116129
友情链接

BlogPowerBy Z-BlogPHP 1.5 Zero ;Theme By 爱墙纸

Copyright © 2020-2030 ITkaifang.COM All Rights Reserved. 京ICP备13044647号.Email:dreamerqin@qq.com