[原创]ORACLE备份恢复_10g热备份演示_MySQL, Oracle及数据库讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  MySQL, Oracle及数据库讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 2832 | 回复: 0   主题: [原创]ORACLE备份恢复_10g热备份演示        下一篇 
    本主题由 Administrator 于 2014-11-19 9:34:57 移动
tengfei.dong
注册用户
等级:中尉
经验:461
发帖:15
精华:0
注册:1970-1-1
状态:离线
发送短消息息给tengfei.dong 加好友    发送短消息息给tengfei.dong 发消息
发表于: IP:您无权察看 2014-11-17 17:48:45 | [全部帖] [楼主帖] 楼主

SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /oracle/app/oracle/product/10.2/db_1/dbs/arch
Oldest online log sequence 19
Current log sequence 21
SQL> alter system set log_archive_dest_1='location=/oradata/arch' scope=spfile;
System altered.
SQL> alter system set log_archive_format='dbname_%t_%s_%r.arc' scope=spfile;
System altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 599785472 bytes
Fixed Size 2098112 bytes
Variable Size 327158848 bytes
Database Buffers 264241152 bytes
Redo Buffers 6287360 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oradata/arch
Oldest online log sequence 19
Next log sequence to archive 21
Current log sequence 21
SQL> alter database open;
Database altered.
SQL> alter system archive log current;
System altered.
SQL> !
[oracle@localhost ~]$ cd /oradata
[oracle@localhost oradata]$ ls
arch orcl orcl.bak
[oracle@localhost oradata]$ cd arch
[oracle@localhost arch]$ ls
dbname_1_21_854891655.arc


导出将所有表空间置于热备状态的脚本:

SQL> select 'alter tablespace '||tablespace_name||' begin backup;' from dba_tablespaces where contents<>'TEMPORARY';
'ALTERTABLESPACE'||TABLESPACE_NAME||'BEGINBACKUP;'
-------------------------------------------------------------
alter tablespace SYSTEM begin backup;
alter tablespace UNDOTBS1 begin backup;
alter tablespace SYSAUX begin backup;
alter tablespace USERS begin backup;


执行以上脚本:

SQL> alter tablespace SYSTEM begin backup;
alter tablespace UNDOTBS1 begin backup;
alter tablespace SYSAUX begin backup;
alter tablespace USERS begin backup;
Tablespace altered.
SQL>
Tablespace altered.
SQL>
Tablespace altered.
SQL>
Tablespace altered.
SQL>


查看备份状态:

SQL> select status from v$backup;
STATUS
------------------
ACTIVE
ACTIVE
ACTIVE
ACTIVE --这个是备份状态,如果是非备份状态,显示not active
SQL>


查看所有数据文件的位置:

SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
/oradata/orcl/system01.dbf
/oradata/orcl/undotbs01.dbf
/oradata/orcl/sysaux01.dbf
/oradata/orcl/users01.dbf


拷贝所有文件(数据文件、控制文件、日志文件)

SQL> !
[oracle@localhost ~]$ cd /oradata
[oracle@localhost oradata]$ ls
arch orcl
[oracle@localhost oradata]$ cp -r orcl orcl_bak
[oracle@localhost oradata]$ ls
arch orcl orcl_bak
[oracle@localhost oradata]$


重新进入数据库将表空间置于正常状态:

[oracle@localhost oradata]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Mon Sep 15 18:45:40 2014
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select 'alter tablespace '||tablespace_name||' end backup;' from dba_tablespaces where contents<>'TEMPORARY';
'ALTERTABLESPACE'||TABLESPACE_NAME||'ENDBACKUP;'
-----------------------------------------------------------
alter tablespace SYSTEM end backup;
alter tablespace UNDOTBS1 end backup;
alter tablespace SYSAUX end backup;
alter tablespace USERS end backup;
SQL>


执行以上脚本:

SQL>alter tablespace SYSTEM end backup;
alter tablespace UNDOTBS1 end backup;
alter tablespace SYSAUX end backup;
alter tablespace USERS end backup;
Tablespace altered.
SQL>
Tablespace altered.
SQL>
Tablespace altered.
SQL>
Tablespace altered.
SQL>


单独备份控制文件的两种方法

1.单独将控制文件备份到指定地点:

SQL> alter database backup controlfile to '/oradata/ctl.bak';
Database altered.
SQL> !
[oracle@localhost oradata]$ ls
arch ctl.bak orcl orcl_bak


2.将控制文件备份到trace文件中:

SQL> alter database backup controlfile to trace;
Database altered.


找出当天会话的pid:

SQL> select spid from v$process a,v$session b where a.addr=b.paddr and b.sid in (select distinct sid from v$mystat);
SPID
------------
10707


找到相关的trace文件:

SQL> !
[oracle@localhost oradata]$ ps -ef |grep 10707
oracle 10707 10706 0 18:45 ? 00:00:00 oracleorcl (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle 10918 10887 0 19:08 pts/1 00:00:00 grep 10707
[oracle@localhost oradata]$ cd $ORACLE_BASE
[oracle@localhost oracle]$ ls
admin oraInventory product
[oracle@localhost oracle]$ cd admin
[oracle@localhost admin]$ ls
orcl
[oracle@localhost admin]$ cd orcl
[oracle@localhost orcl]$ ls
adump bdump cdump dpdump pfile scripts udump
[oracle@localhost orcl]$ cd udump
[oracle@localhost udump]$ ls *10707*
orcl_ora_10707.trc


找出trace文件中有以下重建控制文件的脚本:

[oracle@localhost udump]$ vi orcl_ora_10707.trc
-- Use this only if the current versions of all online logs are
-- available.
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
-- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/oradata/orcl/redo01.log' SIZE 50M,
GROUP 2 '/oradata/orcl/redo02.log' SIZE 50M,
GROUP 3 '/oradata/orcl/redo03.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'/oradata/orcl/system01.dbf',
'/oradata/orcl/undotbs01.dbf',
'/oradata/orcl/sysaux01.dbf',
'/oradata/orcl/users01.dbf'
CHARACTER SET ZHS16GBK
;
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '/oradata/arch/dbname_1_1_854891655.arc';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
RECOVER DATABASE
-- All logs need archiving and a log switch is needed.
ALTER SYSTEM ARCHIVE LOG ALL;
-- Database can now be opened normally.
ALTER DATABASE OPEN;
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '/oradata/orcl/temp01.dbf'
SIZE 20971520 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
-- End of tempfile additions.
--
-- Set #2. RESETLOGS case
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- The contents of online logs will be lost and all backups will
-- be invalidated. Use this only if online logs are damaged.
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
-- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORCL" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/oradata/orcl/redo01.log' SIZE 50M,
GROUP 2 '/oradata/orcl/redo02.log' SIZE 50M,
GROUP 3 '/oradata/orcl/redo03.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'/oradata/orcl/system01.dbf',
'/oradata/orcl/undotbs01.dbf',
'/oradata/orcl/sysaux01.dbf',
'/oradata/orcl/users01.dbf'
CHARACTER SET ZHS16GBK
;
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '/oradata/arch/dbname_1_1_854891655.arc';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
RECOVER DATABASE USING BACKUP CONTROLFILE
-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '/oradata/orcl/temp01.dbf'
SIZE 20971520 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
-- End of tempfile additions.


将重建控制文件脚本复制出来:

[oracle@localhost udump]$ vi /tmp/ctl.bak
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/oradata/orcl/redo01.log' SIZE 50M,
GROUP 2 '/oradata/orcl/redo02.log' SIZE 50M,
GROUP 3 '/oradata/orcl/redo03.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'/oradata/orcl/system01.dbf',
'/oradata/orcl/undotbs01.dbf',
'/oradata/orcl/sysaux01.dbf',
'/oradata/orcl/users01.dbf'
CHARACTER SET ZHS16GBK
;


控制文件中的两个scn:

SQL> select file#,CHECKPOINT_CHANGE#,LAST_CHANGE# from v$datafile;
FILE# CHECKPOINT_CHANGE# LAST_CHANGE#
---------- ------------------ ------------
1 357205
2 357211
3 357217
4 357223


将某个数据文件offline:

SQL> alter database datafile 4 offline;
Database altered.
SQL> select file#,CHECKPOINT_CHANGE#,LAST_CHANGE# from v$datafile;
FILE# CHECKPOINT_CHANGE# LAST_CHANGE#
---------- ------------------ ------------
1 357205
2 357211
3 357217
4 357223 359932
SQL> alter database datafile 4 online;
alter database datafile 4 online
*
ERROR at line 1:
ORA-01113: file 4 needs media recovery if it was restored from backup, or END
BACKUP if it was not
ORA-01110: data file 4: '/oradata/orcl/users01.dbf'
SQL> recover datafile 4;
Media recovery complete.
SQL> alter database datafile 4 online;
Database altered.
SQL>


非正常关闭数据库:

SQL> shutdown abort;
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 599785472 bytes
Fixed Size 2098112 bytes
Variable Size 327158848 bytes
Database Buffers 264241152 bytes
Redo Buffers 6287360 bytes
Database mounted.
SQL> select file#,CHECKPOINT_CHANGE#,LAST_CHANGE# from v$datafile;
FILE# CHECKPOINT_CHANGE# LAST_CHANGE#
---------- ------------------ ------------
1 357205
2 357211
3 357217
4 360045
SQL> recover database;
Media recovery complete.
SQL> select file#,CHECKPOINT_CHANGE#,LAST_CHANGE# from v$datafile;
FILE# CHECKPOINT_CHANGE# LAST_CHANGE#
---------- ------------------ ------------
1 360154 360154
2 360154 360154
3 360154 360154
4 360154 360154


查看数据文件头的scn:

SQL> select CHECKPOINT_CHANGE# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
360154
360154
360154
360154


查看归档文件的scn:

SQL> select name,FIRST_CHANGE#,NEXT_CHANGE# from v$archived_log;
NAME
--------------------------------------------------------------------------------
FIRST_CHANGE# NEXT_CHANGE#
------------- ------------
/oradata/arch/dbname_1_21_854891655.arc
339596 354822


以上数据库已经备份,以下模拟集中常见的故障恢复:

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

1.system数据文件的损坏恢复

SQL> shutdown abort
ORACLE instance shut down.
SQL> !
[oracle@localhost oradata]$ cd orcl
[oracle@localhost orcl]$ ls
control01.ctl control03.ctl redo02.log sysaux01.dbf temp01.dbf users01.dbf
control02.ctl redo01.log redo03.log system01.dbf undotbs01.dbf
[oracle@localhost orcl]$ rm -rf system01.dbf
[oracle@localhost orcl]$ exit
exit
SQL> startup
ORACLE instance started.
Total System Global Area 599785472 bytes
Fixed Size 2098112 bytes
Variable Size 327158848 bytes
Database Buffers 264241152 bytes
Redo Buffers 6287360 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/oradata/orcl/system01.dbf'
SQL>
SQL> !
[oracle@localhost oradata]$ ls
arch ctl.bak orcl orcl_bak
[oracle@localhost oradata]$ cd orcl_bak
[oracle@localhost orcl_bak]$ ls
control01.ctl control03.ctl redo02.log sysaux01.dbf temp01.dbf users01.dbf
control02.ctl redo01.log redo03.log system01.dbf undotbs01.dbf
[oracle@localhost orcl_bak]$ cp system01.dbf ../orcl/
[oracle@localhost orcl_bak]$ cd ..
[oracle@localhost oradata]$ ls
arch ctl.bak orcl orcl_bak
[oracle@localhost oradata]$ cd orcl
[oracle@localhost orcl]$ ls
control01.ctl control03.ctl redo02.log sysaux01.dbf temp01.dbf users01.dbf
control02.ctl redo01.log redo03.log system01.dbf undotbs01.dbf
[oracle@localhost orcl]$ exit
exit
SQL>
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01113: file 1 needs media recovery if it was restored from backup, or END
BACKUP if it was not
ORA-01110: data file 1: '/oradata/orcl/system01.dbf'
SQL> select file#,CHECKPOINT_CHANGE#,LAST_CHANGE#,status from v$datafile;
FILE# CHECKPOINT_CHANGE# LAST_CHANGE# STATUS
---------- ------------------ ------------ -------
1 360154 360154 SYSTEM
2 360154 360154 ONLINE
3 360154 360154 ONLINE
4 360154 360154 ONLINE
SQL> select CHECKPOINT_CHANGE# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
357205
360154
360154
360154
SQL> recover database;
Media recovery complete.
SQL> select CHECKPOINT_CHANGE# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
360154
360154
360154
360154
SQL> alter database open;
Database altered.
SQL>


2.普通数据文件损坏的恢复

[oracle@localhost orcl]$ ls
control01.ctl control03.ctl redo02.log sysaux01.dbf temp01.dbf users01.dbf
control02.ctl redo01.log redo03.log system01.dbf undotbs01.dbf
[oracle@localhost orcl]$ rm users01.dbf
[oracle@localhost orcl]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Tue Sep 16 16:53:34 2014
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 599785472 bytes
Fixed Size 2098112 bytes
Variable Size 327158848 bytes
Database Buffers 264241152 bytes
Redo Buffers 6287360 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/oradata/orcl/users01.dbf'
SQL>


生产环境遇到这种情况先想办法打开库让库跑起来:

SQL> alter database datafile 4 offline;
Database altered.
SQL> alter database open;
Database altered.
SQL>
SQL> !
[oracle@localhost orcl]$ cp ../orcl_bak/users01.dbf .
[oracle@localhost orcl]$ exit
exit
SQL>
SQL> alter database datafile 4 online;
alter database datafile 4 online
*
ERROR at line 1:
ORA-01113: file 4 needs media recovery if it was restored from backup, or END
BACKUP if it was not
ORA-01110: data file 4: '/oradata/orcl/users01.dbf'
SQL>
SQL> select CHECKPOINT_CHANGE# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
380467
380467
380467
357223
SQL> select file#,CHECKPOINT_CHANGE#,LAST_CHANGE#,status from v$datafile;
FILE# CHECKPOINT_CHANGE# LAST_CHANGE# STATUS
---------- ------------------ ------------ -------
1 380467 SYSTEM
2 380467 ONLINE
3 380467 ONLINE
4 380464 380464 OFFLINE --注意11g这里显示recover
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
CORE 10.2.0.5.0 Production
TNS for Linux: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production
SQL> recover datafile 4;
Media recovery complete.
SQL> select file#,CHECKPOINT_CHANGE#,LAST_CHANGE#,status from v$datafile;
FILE# CHECKPOINT_CHANGE# LAST_CHANGE# STATUS
---------- ------------------ ------------ -------
1 380467 SYSTEM
2 380467 ONLINE
3 380467 ONLINE
4 380464 380464 OFFLINE
SQL> select CHECKPOINT_CHANGE# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
380467
380467
380467
380464
SQL> alter database datafile 4 online;
Database altered.
SQL> select file#,CHECKPOINT_CHANGE#,LAST_CHANGE#,status from v$datafile;
FILE# CHECKPOINT_CHANGE# LAST_CHANGE# STATUS
---------- ------------------ ------------ -------
1 380467 SYSTEM
2 380467 ONLINE
3 380467 ONLINE
4 381509 ONLINE
SQL> select CHECKPOINT_CHANGE# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
380467
380467
380467
381509
SQL>


3.控制文件丢失的恢复

SQL> alter database backup controlfile to trace noresetlogs;
Database altered.
SQL> alter database backup controlfile to trace resetlogs;
Database altered.
SQL> !
[oracle@localhost tmp]$ cd /oradata
[oracle@localhost oradata]$ cd orcl
[oracle@localhost orcl]$ ls
control01.ctl control03.ctl redo02.log sysaux01.dbf temp01.dbf users01.dbf
control02.ctl redo01.log redo03.log system01.dbf undotbs01.dbf
[oracle@localhost orcl]$ rm con*
[oracle@localhost orcl]$ ls
redo01.log redo02.log redo03.log sysaux01.dbf system01.dbf temp01.dbf undotbs01.dbf users01.dbf
[oracle@localhost orcl]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Tue Sep 16 17:29:22 2014
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> startup
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 599785472 bytes
Fixed Size 2098112 bytes
Variable Size 327158848 bytes
Database Buffers 264241152 bytes
Redo Buffers 6287360 bytes
ORA-00205: error in identifying control file, check alert log for more info
SQL>
SQL> @/tmp/ctl.bak
Control file created.
SQL>
SQL> select file#,CHECKPOINT_CHANGE#,LAST_CHANGE#,status from v$datafile;
FILE# CHECKPOINT_CHANGE# LAST_CHANGE# STATUS
---------- ------------------ ------------ -------
1 380467 SYSTEM
2 380467 RECOVER
3 380467 RECOVER
4 381509 RECOVER
SQL> recover database;
Media recovery complete.
SQL> alter database open;
Database altered.
SQL>


4.控制文件版本过旧(使用以前备份的控制文件)的恢复

SQL> shutdown abort
ORACLE instance shut down.
SQL> !
[oracle@localhost orcl]$ ls
control01.ctl control03.ctl redo02.log sysaux01.dbf temp01.dbf users01.dbf
control02.ctl redo01.log redo03.log system01.dbf undotbs01.dbf
[oracle@localhost orcl]$ ll
total 852492
-rw-r----- 1 oracle oinstall 7389184 Sep 16 18:37 control01.ctl
-rw-r----- 1 oracle oinstall 7389184 Sep 16 18:37 control02.ctl
-rw-r----- 1 oracle oinstall 7389184 Sep 16 18:37 control03.ctl
-rw-r----- 1 oracle oinstall 52429312 Sep 16 18:32 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Sep 16 18:32 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Sep 16 18:32 redo03.log
-rw-r----- 1 oracle oinstall 125837312 Sep 16 18:32 sysaux01.dbf
-rw-r----- 1 oracle oinstall 314580992 Sep 16 18:32 system01.dbf
-rw-r----- 1 oracle oinstall 20979712 Aug 8 17:10 temp01.dbf
-rw-r----- 1 oracle oinstall 246423552 Sep 16 18:32 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 Sep 16 18:32 users01.dbf
--将以前备份的控制文件拷过来覆盖了
SQL> shutdown abort;
ORACLE instance shut down.
SQL> !
[oracle@localhost orcl]$ cd ..
[oracle@localhost oradata]$ cd orcl_bak
[oracle@localhost orcl_bak]$ ls
control01.ctl control03.ctl redo02.log sysaux01.dbf temp01.dbf users01.dbf
control02.ctl redo01.log redo03.log system01.dbf undotbs01.dbf
[oracle@localhost orcl_bak]$ cp control01.ctl ../orcl/control01.ctl
[oracle@localhost orcl_bak]$ cp control01.ctl ../orcl/control02.ctl
[oracle@localhost orcl_bak]$ cp control01.ctl ../orcl/control03.ctl
[oracle@localhost orcl_bak]$
[oracle@localhost orcl_bak]$
[oracle@localhost orcl_bak]$ exit
exit
SQL> startup
ORACLE instance started.
Total System Global Area 599785472 bytes
Fixed Size 2098112 bytes
Variable Size 327158848 bytes
Database Buffers 264241152 bytes
Redo Buffers 6287360 bytes
Database mounted.
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '/oradata/orcl/system01.dbf'
ORA-01207: file is more recent than control file - old control file
SQL>
SQL> select file#,CHECKPOINT_CHANGE#,LAST_CHANGE# from v$datafile;
FILE# CHECKPOINT_CHANGE# LAST_CHANGE#
---------- ------------------ ------------
1 377911
2 377917
3 377923
4 377929
SQL> select CHECKPOINT_CHANGE# from v$datafile_header;
CHECKPOINT_CHANGE#
------------------
378265
378265
378265
378265
SQL>
SQL> select group#,sequence#,members,archived,status,first_change# from v$log;
GROUP# SEQUENCE# MEMBERS ARC STATUS FIRST_CHANGE#
---------- ---------- ---------- --- ---------------- -------------
1 22 1 YES INACTIVE 354822
3 21 1 YES INACTIVE 339596
2 23 1 NO CURRENT 377332
SQL> recover database until cancel using backup controlfile;
ORA-00279: change 378262 generated at 09/16/2014 19:34:07 needed for thread 1
ORA-00289: suggestion : /oradata/arch/dbname_1_24_854891655.arc
ORA-00280: change 378262 for thread 1 is in sequence #24
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/oradata/orcl/redo03.log
Log applied.
Media recovery complete.
SQL> recover database until cancel using backup controlfile;
ORA-00279: change 378266 generated at 09/16/2014 19:34:17 needed for thread 1
ORA-00289: suggestion : /oradata/arch/dbname_1_24_854891655.arc
ORA-00280: change 378266 for thread 1 is in sequence #24
Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/oradata/orcl/redo01.log
ORA-00310: archived log contains sequence 22; sequence 24 required
ORA-00334: archived log: '/oradata/orcl/redo01.log'
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlogs;
Database altered.
SQL>


恢复好了。

该贴由system转至本版2014-11-19 9:34:57




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论