程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> 數據庫數據文件有備份的恢復ORA-01157【續+1】

數據庫數據文件有備份的恢復ORA-01157【續+1】

編輯:Oracle教程

目的:

測試將數據庫關閉狀態下,將數據文件刪除(把數據文件做備份),啟動數據庫報錯, 如何恢復數據文件??

啟動數據庫如何恢復 沒有換路徑的數據文件 和 更換路徑的數據文件

繼續試驗

http://blog.csdn.net/wanghui5767260/article/details/20293807

准備環境:

創建兩個表空間 tyger1 和 tyger2

創建兩個用戶 tu1 默認表空間 tyger1

tu2 默認表空間 tyger2

在每個用戶下創建相應的測試表 tu1 用戶 tu1_t1

tu2 用戶 tu2_t2

[oracle@tyger ORCL]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Mar 3 10:28:36 2014

Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SYS@ORCL>create tablespace tyger1 datafile '/u01/app/oracle/oradata/ORCL/tyger1_01.dbf' size 5m;

Tablespace created.

SYS@ORCL>create tablespace tyger2 datafile '/u01/app/oracle/oradata/ORCL/tyger2_01.dbf' size 5m;

Tablespace created.

SYS@ORCL>create user tu1 identified by tu1 account unlock default tablespace tyger1;

User created.

SYS@ORCL>create user tu2 identified by tu2 account unlock default tablespace tyger2;

User created.

SYS@ORCL>grant connect,resource,select any table to tu1;

Grant succeeded.

SYS@ORCL>grant connect,resource,select any table to tu2;

Grant succeeded.

SYS@ORCL>conn tu1/tu1
Connected.
TU1@ORCL>create table tu1_t1 as select * from scott.emp;

Table created.

TU1@ORCL>select count(*) from tu1_t1;

COUNT(*)
----------
14

TU1@ORCL>conn tu2/tu2
Connected.
TU2@ORCL>create table tu2_t2 as select * from scott.emp;

Table created.

TU2@ORCL>select count(*) from tu2_t2;


COUNT(*)
----------
14


TU2@ORCL>conn / as sysdba
Connected.
SYS@ORCL>col file_name for a50
SYS@ORCL>col tablespace_name for a20
SYS@ORCL>select tablespace_name,file_name from dba_data_files;


TABLESPACE_NAME FILE_NAME
-------------------- --------------------------------------------------
USERS /u01/app/oracle/oradata/ORCL/users01.dbf
SYSAUX /u01/app/oracle/oradata/ORCL/sysaux01.dbf
UNDOTBS1 /u01/app/oracle/oradata/ORCL/undotbs01.dbf
SYSTEM /u01/app/oracle/oradata/ORCL/system01.dbf
EXAMPLE /u01/app/oracle/oradata/ORCL/example01.dbf
TYGER1 /u01/app/oracle/oradata/ORCL/tyger1_01.dbf
TYGER2 /u01/app/oracle/oradata/ORCL/tyger2_01.dbf


7 rows selected.


SYS@ORCL>select tablespace_name,status from dba_tablespaces;


TABLESPACE_NAME STATUS
-------------------- ---------
SYSTEM ONLINE
UNDOTBS1 ONLINE
SYSAUX ONLINE
TEMP ONLINE
USERS ONLINE
EXAMPLE ONLINE
TYGER1 ONLINE
TYGER2 ONLINE


8 rows selected.


SYS@ORCL>!
[oracle@tyger ORCL]$ ls
control01.ctl redo03.log standbylog6b.log tyger1_01.dbf
control02.ctl standbylog4a.log standbylog7a.log tyger2_01.dbf
control03.ctl standbylog4b.log standbylog7b.log undotbs01.dbf
example01.dbf standbylog5a.log sysaux01.dbf users01.dbf
redo01.log standbylog5b.log system01.dbf
redo02.log standbylog6a.log temp01.dbf
[oracle@tyger ORCL]$ mv tyger1_01.dbf tyger1_01.dbf.bak
[oracle@tyger ORCL]$ mv tyger2_01.dbf tyger2_01.dbf.bak
[oracle@tyger ORCL]$ ls
recontrol01.ctl redo03.log standbylog6b.log tyger1_01.dbf.bak
control02.ctl standbylog4a.log standbylog7a.log tyger2_01.dbf.bak
control03.ctl standbylog4b.log standbylog7b.log undotbs01.dbf
example01.dbf standbylog5a.log sysaux01.dbf users01.dbf
redo01.log standbylog5b.log system01.dbf
redo02.log standbylog6a.log temp01.dbf
[oracle@tyger ORCL]$ mv tyger1_01.dbf.bak tyger1_01.dbf
[oracle@tyger ORCL]$ mv tyger2_01.dbf.bak tyger2_01.dbf
[oracle@tyger ORCL]$ exit
exit


SYS@ORCL>shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@ORCL>!
[oracle@tyger ORCL]$ mv tyger1_01.dbf tyger1_01.dbf.bak
[oracle@tyger ORCL]$ mv tyger2_01.dbf tyger2_01.dbf.bak
[oracle@tyger ORCL]$ exit
exit


SYS@ORCL>startup
ORACLE instance started.

Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 150996560 bytes
Database Buffers 130023424 bytes
Redo Buffers 2973696 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
ORA-01110: data file 6: '/u01/app/oracle/oradata/ORCL/tyger1_01.dbf'

SYS@ORCL>alter database datafile 6 offline;


Database altered.


SYS@ORCL>alter database open;
alter database open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
ORA-01110: data file 7: '/u01/app/oracle/oradata/ORCL/tyger2_01.dbf'

SYS@ORCL>alter database datafile 7 offline;


Database altered.


SYS@ORCL>alter database open;


Database altered.


SYS@ORCL>select tablespace_name,status from dba_tablespaces;


TABLESPACE_NAME STATUS
-------------------- ---------
SYSTEM ONLINE
UNDOTBS1 ONLINE
SYSAUX ONLINE
TEMP ONLINE
USERS ONLINE
EXAMPLE ONLINE
TYGER1 ONLINE
TYGER2 ONLINE


8 rows selected.


SYS@ORCL>!
[oracle@tyger ORCL]$ mv tyger1_01.dbf.bak tyger1_01.dbf
[oracle@tyger ORCL]$ mv tyger2_01.dbf.bak ../tyger2_01.dbf
[oracle@tyger ORCL]$ cd ..
[oracle@tyger oradata]$ ls
ORCL tyger2_01.dbf
[oracle@tyger oradata]$ pwd
/u01/app/oracle/oradata
[oracle@tyger oradata]$ exit
exit


SYS@ORCL>alter tablespace tyger1 online;


Tablespace altered.


SYS@ORCL>alter tablespace tyger2 online;
alter tablespace tyger2 online
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
ORA-01110: data file 7: '/u01/app/oracle/oradata/ORCL/tyger2_01.dbf'

SYS@ORCL>alter database rename file '/u01/app/oracle/oradata/ORCL/tyger2_01.dbf' to '/u01/app/oracle/oradata/tyger2_01.dbf';


Database altered.

SYS@ORCL>alter tablespace tyger2 online;


Tablespace altered.


SYS@ORCL>conn tu1/tu1
Connected.
TU1@ORCL>select count(*) from tu1_t1;


COUNT(*)
----------
14


TU1@ORCL>conn tu2/tu2
Connected.
TU2@ORCL>select count(*) from tu2_t2;


COUNT(*)
----------
14

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved