ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 一个DBA恢复数据库的实例

一个DBA恢复数据库的实例

原创 Linux操作系统 作者:sunnily 时间:2019-06-13 08:27:06 0 删除 编辑
Wikipedia,自由的百科全书

1、telnet登录小型机,连接数据库,查看数据库状态。

oracle$sqlplus /nolog

SQL*Plus: Release 9.2.0.1.0 - Production on Sun Aug 28 12:58:51 2005

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

SQL> conn / as sysdba Connected. SQL> select status from v$instance;

STATUS


STARTED


2、mount数据库,发现控制文件不一致。

SQL> alter database mount; alter database mount

ERROR at line 1: ORA-00214: controlfile '/oracle/oracle/app/oracle/product/9.2.0.1/dbs/hb030000/control01.ctl' version 99279 inconsistent with file '/oradata/hb030000/control02.ctl' version 99212


SQL> exit Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Producti on With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.1.0 - Production


3、rman连接catalog,恢复控制文件。

oracle$rman target / catalog rman/rman@omsora9

Recovery Manager: Release 9.2.0.1.0 - 64bit Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

connected to target database: hb030000 (not mounted) connected to recovery catalog database

RMAN>

RMAN> restore controlfile;

Starting restore at 28-AUG-05

allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=13 devtype=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: sid=14 devtype=DISK allocated channel: ORA_DISK_3 channel ORA_DISK_3: sid=15 devtype=DISK allocated channel: ORA_DISK_4 channel ORA_DISK_4: sid=16 devtype=DISK channel ORA_DISK_1: starting datafile backupset restore channel ORA_DISK_1: restoring controlfile output filename=/oracle/oracle/app/oracle/product/9.2.0.1/dbs/hb030000/control01 .ctl channel ORA_DISK_1: restored backup piece 1 piece handle=/oradata/rmanbackup/qhdora9_ctl_c-3596129099-20050827-00.bak tag=nu ll params=NULL channel ORA_DISK_1: restore complete replicating controlfile input filename=/oracle/oracle/app/oracle/product/9.2.0.1/dbs/hb030000/control01. ctl output filename=/oradata/hb030000/control02.ctl output filename=/oradata/hb030000/control03.ctl Finished restore at 28-AUG-05

4、控制文件恢复完毕,数据库mount,打开数据库,发现system01文件不一致,需要介质恢复。 RMAN> alter database mount;

database mounted

RMAN> alter database open;

RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of alter db command at 08/28/2005 13:01:13 ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

RMAN> alter database open resetlogs;

RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of alter db command at 08/28/2005 13:01:25 ORA-01194: file 1 needs more recovery to be consistent ORA-01110: data file 1: '/oradata/hb030000/system01.dbf'

5、恢复system01数据文件,打开数据库有问题。


oracle$rman target / catalog rman/rman@omsora9

Recovery Manager: Release 9.2.0.1.0 - 64bit Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

connected to target database: HB030000 (DBID=3596129099) connected to recovery catalog database

RMAN> restore datafile 1;

Starting restore at 28-AUG-05

allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=15 devtype=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: sid=14 devtype=DISK allocated channel: ORA_DISK_3 channel ORA_DISK_3: sid=13 devtype=DISK allocated channel: ORA_DISK_4 channel ORA_DISK_4: sid=11 devtype=DISK channel ORA_DISK_1: starting datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00001 to /oradata/hb030000/system01.dbf

channel ORA_DISK_1: restored backup piece 1 piece handle=/oradata/rmanbackup/df_HB030000_566351414_1298_1.bak tag=TAG2005081 4T235013 params=NULL channel ORA_DISK_1: restore complete Finished restore at 28-AUG-05

RMAN> alter database open resetlogs;

RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of alter db command at 08/28/2005 13:27:26 ORA-01152: file 1 was not restored from a sufficiently old backup ORA-01110: data file 1: '/oradata/hb030000/system01.dbf'

RMAN> recover datafile 1;

Starting recover at 28-AUG-05 using channel ORA_DISK_1 using channel ORA_DISK_2 using channel ORA_DISK_3 using channel ORA_DISK_4 channel ORA_DISK_1: starting incremental datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00001: /oradata/hb030000/system01.dbf channel ORA_DISK_1: restored backup piece 1 piece handle=/oradata/rmanbackup/df_HB030000_567474616_1384_1.bak tag=TAG2005082 7T235015 params=NULL channel ORA_DISK_1: restore complete

RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 08/28/2005 13:29:19 RMAN-06067: RECOVER DATABASE required with a backup or created controlfile

RMAN>


6、查看alert_hb030000.log文件,数据库是在2005/08/28/12:10分正常关闭,不完全恢复数据库。




oracle$rman target / catalog rman/rman@omsora9

Recovery Manager: Release 9.2.0.1.0 - 64bit Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

connected to target database: hb030000 (not mounted) connected to recovery catalog database

RMAN> alter database mount;

database mounted

RMAN> run { 2> set until time="to_date('2005-08-28:12:10:10','yyyy-mm-dd:hh24:mi:ss')"; 3> restore database; 4> }

executing command: SET until clause

Starting restore at 28-AUG-05

allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=13 devtype=DISK allocated channel: ORA_DISK_2 channel ORA_DISK_2: sid=14 devtype=DISK allocated channel: ORA_DISK_3 channel ORA_DISK_3: sid=15 devtype=DISK allocated channel: ORA_DISK_4 channel ORA_DISK_4: sid=16 devtype=DISK channel ORA_DISK_1: starting datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00001 to /oradata/hb030000/system01.dbf restoring datafile 00008 to /oradata/hb030000/tools01.dbf restoring datafile 00011 to /oradata/hb030000/GFB.DBF channel ORA_DISK_2: starting datafile backupset restore channel ORA_DISK_2: specifying datafile(s) to restore from backup set restoring datafile 00002 to /oradata/hb030000/undotbs01.dbf restoring datafile 00004 to /oradata/hb030000/drsys01.dbf restoring datafile 00010 to /oradata/hb030000/xdb01.dbf channel ORA_DISK_3: starting datafile backupset restore channel ORA_DISK_3: specifying datafile(s) to restore from backup set restoring datafile 00003 to /oradata/hb030000/cwmlite01.dbf restoring datafile 00005 to /oradata/hb030000/example01.dbf channel ORA_DISK_4: starting datafile backupset restore channel ORA_DISK_4: specifying datafile(s) to restore from backup set restoring datafile 00006 to /oradata/hb030000/indx01.dbf restoring datafile 00007 to /oradata/hb030000/odm01.dbf restoring datafile 00009 to /oradata/hb030000/users01.dbf

channel ORA_DISK_3: restored backup piece 1 piece handle=/oradata/rmanbackup/df_HB030000_566956214_1340_1.bak tag=TAG20050821T235013 params=NULL channel ORA_DISK_3: restore complete channel ORA_DISK_4: restored backup piece 1 piece handle=/oradata/rmanbackup/df_HB030000_566956214_1342_1.bak tag=TAG20050821T235013 params=NULL channel ORA_DISK_4: restore complete channel ORA_DISK_1: restored backup piece 1 piece handle=/oradata/rmanbackup/df_HB030000_566351414_1298_1.bak tag=TAG20050814T235013 params=NULL channel ORA_DISK_1: restore complete

channel ORA_DISK_2: restored backup piece 1 piece handle=/oradata/rmanbackup/df_HB030000_566956214_1341_1.bak tag=TAG20050821T235013 params=NULL channel ORA_DISK_2: restore complete Finished restore at 28-AUG-05

RMAN>


RMAN> recover database;

Starting recover at 28-AUG-05 using channel ORA_DISK_1 using channel ORA_DISK_2 using channel ORA_DISK_3 using channel ORA_DISK_4 channel ORA_DISK_4: starting incremental datafile backupset restore channel ORA_DISK_4: specifying datafile(s) to restore from backup set destination for restore of datafile 00002: /oradata/hb030000/undotbs01.dbf destination for restore of datafile 00004: /oradata/hb030000/drsys01.dbf destination for restore of datafile 00010: /oradata/hb030000/xdb01.dbf channel ORA_DISK_1: starting incremental datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set destination for restore of datafile 00003: /oradata/hb030000/cwmlite01.dbf destination for restore of datafile 00005: /oradata/hb030000/example01.dbf channel ORA_DISK_2: starting incremental datafile backupset restore channel ORA_DISK_2: specifying datafile(s) to restore from backup set destination for restore of datafile 00006: /oradata/hb030000/indx01.dbf destination for restore of datafile 00007: /oradata/hb030000/odm01.dbf destination for restore of datafile 00009: /oradata/hb030000/users01.dbf channel ORA_DISK_3: starting incremental datafile backupset restore channel ORA_DISK_3: specifying datafile(s) to restore from backup set destination for restore of datafile 00001: /oradata/hb030000/system01.dbf destination for restore of datafile 00008: /oradata/hb030000/tools01.dbf destination for restore of datafile 00011: /oradata/hb030000/GFB.DBF channel ORA_DISK_2: restored backup piece 1 piece handle=/oradata/rmanbackup/df_HB030000_567474616_1383_1.bak tag=TAG20050827T235015 params=NULL channel ORA_DISK_2: restore complete channel ORA_DISK_1: restored backup piece 1 piece handle=/oradata/rmanbackup/df_HB030000_567474616_1381_1.bak tag=TAG20050827T235015 params=NULL channel ORA_DISK_1: restore complete channel ORA_DISK_3: restored backup piece 1 piece handle=/oradata/rmanbackup/df_HB030000_567474616_1384_1.bak tag=TAG20050827T235015 params=NULL channel ORA_DISK_3: restore complete channel ORA_DISK_4: restored backup piece 1 piece handle=/oradata/rmanbackup/df_HB030000_567474616_1382_1.bak tag=TAG20050827T235015 params=NULL channel ORA_DISK_4: restore complete

starting media recovery

archive log thread 1 sequence 1107 is already on disk as file /oradata/hb030000/redo02.log archive log thread 1 sequence 1108 is already on disk as file /oracle/oracle/app/oracle/product/9.2.0.1/dbs/hb030000/redo03.rdo archive log filename=/oradata/hb030000/redo02.log thread=1 sequence=1107 archive log filename=/oracle/oracle/app/oracle/product/9.2.0.1/dbs/hb030000/redo03.rdo thread=1 sequence=1108 media recovery complete Finished recover at 28-AUG-05

RMAN> RMAN> alter database open resetlogs;

database opened new incarnation of database registered in recovery catalog starting full resync of recovery catalog full resync complete

RMAN>


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

请登录后发表评论 登录
全部评论

注册时间:2004-04-19

  • 博文量
    139
  • 访问量
    125829