[原创]用RESETLOGS方式打开数据库之前恢复只读表空间的备份_MySQL, Oracle及数据库讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  MySQL, Oracle及数据库讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 3621 | 回复: 0   主题: [原创]用RESETLOGS方式打开数据库之前恢复只读表空间的备份        下一篇 
大红薯
注册用户
等级:少校
经验:1440
发帖:159
精华:0
注册:2011-7-21
状态:离线
发送短消息息给大红薯 加好友    发送短消息息给大红薯 发消息
发表于: IP:您无权察看 2011-8-29 11:06:40 | [全部帖] [楼主帖] 楼主

用RESETLOGS方式打开数据库之前恢复只读表空间的备份

如何在RESETLOGS方式打开数据库之前恢复只读表空间的备份

信息:

*在一个表空间处于只读模式之后备份它。

(只有当它在RESETLOGS之前不是读写模式)

这是一个内训测试方案

这是步骤:

步骤

——
SQL> select name,status,checkpoint_change# from v$datafile;
NAME STATUS CHECKPOINT_CHANGE#
---------------------------------------- ------- ------------------
D:\ORACLE\ORADATA\AMAR\SYSTEM01.DBF SYSTEM 766796
D:\ORACLE\ORADATA\AMAR\RBS01.DBF ONLINE 766796
D:\ORACLE\ORADATA\AMAR\USERS01.DBF ONLINE 766796
D:\ORACLE\ORADATA\AMAR\TEMP01.DBF ONLINE 766796
D:\ORACLE\ORADATA\AMAR\TOOLS01.DBF ONLINE 766796
D:\ORACLE\ORADATA\AMAR\INDX01.DBF ONLINE 766796
D:\ORACLE\ORADATA\AMAR\DR01.DBF ONLINE 766796
D:\ORACLE\ORADATA\AMAR\TEST01.DBF ONLINE 423736 --> THIS IS THE READ ONLY TABLESPACE
D:\ORACLE\ORADATA\AMAR\JAGU01.DBF ONLINE 766864
9 rows selected.
SQL> select tablespace_name,status from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
RBS ONLINE
USERS ONLINE
TEMP ONLINE
TOOLS ONLINE
INDX ONLINE
DRSYS ONLINE
TEST READ ONLY
JAGU ONLINE
9 rows selected.
SQL> shutdown abort
ORACLE instance shut down.


——假设有一个数据库崩溃-

在这种情况下的一些假设

————

++ 已经恢复了所有的数据文件除了只读文件

++ 没有恢复只读表空间

++ 试着去执行不完全恢复

SQL> startup mount
ORACLE instance started.
Total System Global Area 187987996 bytes
Fixed Size 75804 bytes
Variable Size 67436544 bytes
Database Buffers 120397824 bytes
Redo Buffers 77824 bytes
Database mounted.
SQL> recover database until cancel ;
ORA-00283: recovery session canceled due to errors
ORA-01157: cannot identify/lock data file 8 - see DBWR trace file
ORA-01110: data file 8: 'D:\ORACLE\ORADATA\AMAR\TEST01.DBF'


错误的原因

————

++ 因为该文件已经丢失

++ 所以我们不得不 RESTORE FROM BACKUP 或 OFFLINE DROP THIS FILE

++ 现在已经丢弃了datafile 8

SQL> alter database datafile 8 offline drop;
Database altered.
SQL> select name,status from v$datafile_header;
NAME STATUS
---------------------------------------- -------
D:\ORACLE\ORADATA\AMAR\SYSTEM01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\RBS01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\USERS01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\TEMP01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\TOOLS01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\INDX01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\DR01.DBF ONLINE
OFFLINE - in datafile header entry is there
D:\ORACLE\ORADATA\AMAR\JAGU01.DBF ONLINE
9 rows selected.
SQL> select FILE# from v$recover_file;
FILE#
——————
8 FILE NEEDS ReCOVERY
+++ DONE a INCOMPLETE Recovery
SQL> recover database until cancel
cancel
SQL> alter database open resetlogs;
Database altered.
SQL> select name,to_char(RESETLOGS_TIME,'DD-MON-YYYY HH:MI::SS') from v$database
2 ;
NAME TO_CHAR(RESETLOGS_TIM
---------------------------------------- ---------------------
AMAR 01-MAR-2004 01:07::18
SQL> select name,to_char(RESETLOGS_TIME,'DD-MON-YYYY HH:MI::SS')
2 from v$datafile_header;
NAME TO_CHAR(RESETLOGS_TIM
---------------------------------------- ---------------------
D:\ORACLE\ORADATA\AMAR\SYSTEM01.DBF 01-MAR-2004 01:07::18
D:\ORACLE\ORADATA\AMAR\RBS01.DBF 01-MAR-2004 01:07::18
D:\ORACLE\ORADATA\AMAR\USERS01.DBF 01-MAR-2004 01:07::18
D:\ORACLE\ORADATA\AMAR\TEMP01.DBF 01-MAR-2004 01:07::18
D:\ORACLE\ORADATA\AMAR\TOOLS01.DBF 01-MAR-2004 01:07::18
D:\ORACLE\ORADATA\AMAR\INDX01.DBF 01-MAR-2004 01:07::18
D:\ORACLE\ORADATA\AMAR\DR01.DBF 01-MAR-2004 01:07::18
MISSING FOR DATAFILE 8
D:\ORACLE\ORADATA\AMAR\JAGU01.DBF 01-MAR-2004 01:07::18

9 rows selected.

SQL> select file# from v$recover_file;
FILE#
----------
8 — 仍旧显示需要在 RESETLOGS之后恢复

++ 如果该文件在崩溃中丢失我们将需要恢复一样的文件从备份中在它被改成 READ ONLY

之后

SQL> recover datafile 8;
ORA-00283: recovery session canceled due to errors
ORA-00264: no recovery required

看到错误的原因

——————

++ 因为这是一个只读表空间,它不需要被介质恢复

++ 我们可以让数据文件直接在线

SQL> alter database datafile 8 online;
alter database datafile 8 online
*
ERROR at line 1:
ORA-01190: controlfile or data file 8 is from before the last RESETLOGS
ORA-01110: data file 8: 'D:\ORACLE\ORADATA\AMAR\TEST01.DBF'

SQL> select tablespace_name,status from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
RBS ONLINE
USERS ONLINE
TEMP ONLINE
TOOLS ONLINE
INDX ONLINE
DRSYS ONLINE
TEST READ ONLY -READONLY After RESETLOGS
JAGU ONLINE

9 rows selected.

SQL> select name,status from v$datafile;
clsNAME STATUS
---------------------------------------- -------
D:\ORACLE\ORADATA\AMAR\SYSTEM01.DBF SYSTEM
D:\ORACLE\ORADATA\AMAR\RBS01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\USERS01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\TEMP01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\TOOLS01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\INDX01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\DR01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\TEST01.DBF OFFLINE -- as we have offline drop this file
D:\ORACLE\ORADATA\AMAR\JAGU01.DBF ONLINE

9 rows selected.

SQL> select name,status from v$datafile_header;
clsNAME STATUS
---------------------------------------- -------
D:\ORACLE\ORADATA\AMAR\SYSTEM01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\RBS01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\USERS01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\TEMP01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\TOOLS01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\INDX01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\DR01.DBF ONLINE
OFFLINE -- as we have offline drop this file
D:\ORACLE\ORADATA\AMAR\JAGU01.DBF ONLINE

9 rows selected.

++ 试着使只读表空间在线

SQL> alter tablespace test online;

Tablespace altered.

SQL> select name,status from v$datafile;
NAME STATUS
---------------------------------------- -------
D:\ORACLE\ORADATA\AMAR\SYSTEM01.DBF SYSTEM
D:\ORACLE\ORADATA\AMAR\RBS01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\USERS01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\TEMP01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\TOOLS01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\INDX01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\DR01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\TEST01.DBF ONLINE -File is online
D:\ORACLE\ORADATA\AMAR\JAGU01.DBF ONLINE

9 rows selected.

SQL> select name,status from v$datafile_header;
NAME STATUS
---------------------------------------- -------
D:\ORACLE\ORADATA\AMAR\SYSTEM01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\RBS01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\USERS01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\TEMP01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\TOOLS01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\INDX01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\DR01.DBF ONLINE
D:\ORACLE\ORADATA\AMAR\TEST01.DBF ONLINE - FIle is online
D:\ORACLE\ORADATA\AMAR\JAGU01.DBF ONLINE

9 rows selected.

SQL> select tablespace_name,status from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
RBS ONLINE
USERS ONLINE
TEMP ONLINE
TOOLS ONLINE
INDX ONLINE
DRSYS ONLINE
TEST READ ONLY -- Still in Read only after resetlogs and is accessible in the database.
JAGU ONLINE

9 rows selected.

SQL> select name,checkpoint_change# from v$datafile_header;
NAME CHECKPOINT_CHANGE#
---------------------------------------- ------------------
D:\ORACLE\ORADATA\AMAR\SYSTEM01.DBF 766872
D:\ORACLE\ORADATA\AMAR\RBS01.DBF 766872
D:\ORACLE\ORADATA\AMAR\USERS01.DBF 766872
D:\ORACLE\ORADATA\AMAR\TEMP01.DBF 766872
D:\ORACLE\ORADATA\AMAR\TOOLS01.DBF 766872
D:\ORACLE\ORADATA\AMAR\INDX01.DBF 766872
D:\ORACLE\ORADATA\AMAR\DR01.DBF 766872
D:\ORACLE\ORADATA\AMAR\TEST01.DBF 423736 -- its the same SCN as we started with
D:\ORACLE\ORADATA\AMAR\JAGU01.DBF 766872

9 rows selected.

SQL> select name,to_char(RESETLOGS_TIME,'DD-MON-YYYY HH:MI::SS')
2 from v$datafile_header;
NAME TO_CHAR(RESETLOGS_TIM
---------------------------------------- ---------------------
D:\ORACLE\ORADATA\AMAR\SYSTEM01.DBF 01-MAR-2004 01:07::18
D:\ORACLE\ORADATA\AMAR\RBS01.DBF 01-MAR-2004 01:07::18
D:\ORACLE\ORADATA\AMAR\USERS01.DBF 01-MAR-2004 01:07::18
D:\ORACLE\ORADATA\AMAR\TEMP01.DBF 01-MAR-2004 01:07::18
D:\ORACLE\ORADATA\AMAR\TOOLS01.DBF 01-MAR-2004 01:07::18
D:\ORACLE\ORADATA\AMAR\INDX01.DBF 01-MAR-2004 01:07::18
D:\ORACLE\ORADATA\AMAR\DR01.DBF 01-MAR-2004 01:07::18
D:\ORACLE\ORADATA\AMAR\TEST01.DBF 10-NOV-2003 01:12::26 -- Showing the LAST RESETLOGS date
D:\ORACLE\ORADATA\AMAR\JAGU01.DBF 01-MAR-2004 01:07::18
9 rows selected.
SQL> alter tablespace test read write;
Tablespace altered.
SQL> select name,checkpoint_change# from v$datafile_header;
NAME CHECKPOINT_CHANGE#
---------------------------------------- ------------------
D:\ORACLE\ORADATA\AMAR\SYSTEM01.DBF 766872
D:\ORACLE\ORADATA\AMAR\RBS01.DBF 766872
D:\ORACLE\ORADATA\AMAR\USERS01.DBF 766872
D:\ORACLE\ORADATA\AMAR\TEMP01.DBF 766872
D:\ORACLE\ORADATA\AMAR\TOOLS01.DBF 766872
D:\ORACLE\ORADATA\AMAR\INDX01.DBF 766872
D:\ORACLE\ORADATA\AMAR\DR01.DBF 766872
D:\ORACLE\ORADATA\AMAR\TEST01.DBF 766928 -Sync with the other files
D:\ORACLE\ORADATA\AMAR\JAGU01.DBF 766872
9 rows selected.


在它具体成为数据库的一部分之前使表空间处于只读状态




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