Oracle11g控制檔案丟了怎麼辦?
本文測試控制檔案丟失後的恢復方法。文中沒有提及使用實時(準實時)備份恢復,因為如果擁有實時(準實時)備份,處理方法的本質和前二種情況類似。
前期準備
首先連上資料庫,檢視控制檔案所在路徑
-
[oracle@ora11g ~]$ sqlplus / as sysdba
-
-
SQL*Plus: Release 11.2.0.4.0 Production on Wed Aug 16 18:14:10 2017
-
-
Copyright (c) 1982, 2013, Oracle. All rights reserved.
-
-
Connected to an idle instance.
-
-
SYS@cams>startup;
-
ORACLE instance started.
-
-
Total System Global Area 776646656 bytes
-
Fixed Size 2257272 bytes
-
Variable Size 478154376 bytes
-
Database Buffers 289406976 bytes
-
Redo Buffers 6828032 bytes
-
Database mounted.
-
Database opened.
-
SYS@cams>show parameter control_files;
-
-
NAME TYPE VALUE
-
------------------------------------ ----------- ------------------------------
-
control_files string /u01/app/oracle/oradata/cams/c
-
ontrol01.ctl, /u01/app/oracle/
-
fast_recovery_area/cams/contro
- l02.ctl
然後檢視兩個控制檔案的詳細資訊
-
[oracle@ora11g ~]$ ll /u01/app/oracle/oradata/cams/control01.ctl
-
-rw-r-----. 1 oracle oinstall 9945088 Aug 18 18:17 /u01/app/oracle/oradata/cams/control01.ctl
-
[oracle@ora11g ~]$ ll /u01/app/oracle/fast_recovery_area/cams/control02.ctl
- -rw-r-----. 1 oracle oinstall 9945088 Aug 18 18:18 /u01/app/oracle/fast_recovery_area/cams/control02.ctl
可以看到,兩個資料庫控制檔案的詳細資訊一致,包括大小,使用者組,讀寫許可權等。
第一種情況:資料庫處於啟動狀態,控制檔案有多路複用,部分控制檔案丟失
修改其中一個控制檔案的名字,模擬控制檔案丟失
-
[oracle@ora11g ~]$ cd /u01/app/oracle/oradata/cams
-
[oracle@ora11g cams]$ ls | grep control
-
control01.ctl
-
[oracle@ora11g cams]$ mv control01.ctl control01.ctl.bak
-
[oracle@ora11g cams]$ ls | grep control
- control01.ctl.bak
這裡發現一個有意思的現象,在控制檔案破壞之前已經建立的連線在操作時不受影響,即使是從控制檔案查詢資料庫資訊:
-
SYS@cams>select open_mode from v$database;
-
-
OPEN_MODE
-
--------------------
- READ WRITE
但是,用sqlplus重新建立的連線,操作就直接報錯了:
-
[oracle@ora11g ~]$ sqlplus / as sysdba
-
-
SQL*Plus: Release 11.2.0.4.0 Production on Fri Aug 18 21:06:54 2017
-
-
Copyright (c) 1982, 2013, Oracle. All rights reserved.
-
-
-
Connected to:
-
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
-
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-
-
SYS@cams>select open_mode from v$database;
-
select open_mode from v$database
-
*
-
ERROR at line 1:
-
ORA-00210: cannot open the specified control file
-
ORA-00202: control file: '/u01/app/oracle/oradata/cams/control01.ctl'
-
ORA-27041: unable to open file
-
Linux-x86_64 Error: 2: No such file or directory
- Additional information: 3
當然,資料庫還在提供服務,做一些和控制檔案無關的操作都是可以支援的:
-
SYS@cams>select count(*) from dba_tablespaces;
-
-
COUNT(*)
-
----------
- 8
但是檢視alert日誌,也是可以看到已經有報錯資訊輸出了
-
[oracle@ora11g ~]$ tail -f /u01/app/oracle/diag/rdbms/cams/cams/trace/alert_cams.log
-
Starting background process SMCO
-
Fri Aug 18 20:29:46 2017
-
SMCO started with pid=25, OS id=2586
-
Fri Aug 18 20:35:37 2017
-
Errors in file /u01/app/oracle/diag/rdbms/cams/cams/trace/cams_m001_2653.trc:
-
ORA-00210: cannot open the specified control file
-
ORA-00202: control file: '/u01/app/oracle/oradata/cams/control01.ctl'
-
ORA-27041: unable to open file
-
Linux-x86_64 Error: 2: No such file or directory
-
Additional information: 3
-
Fri Aug 18 20:39:36 2017
-
Errors in file /u01/app/oracle/diag/rdbms/cams/cams/trace/cams_m000_2699.trc:
-
ORA-00210: cannot open the specified control file
-
ORA-00202: control file: '/u01/app/oracle/oradata/cams/control01.ctl'
-
ORA-27041: unable to open file
-
Linux-x86_64 Error: 2: No such file or directory
-
Additional information: 3
-
Fri Aug 18 20:39:37 2017
-
Errors in file /u01/app/oracle/diag/rdbms/cams/cams/trace/cams_m001_2701.trc:
-
ORA-00210: cannot open the specified control file
-
ORA-00202: control file: '/u01/app/oracle/oradata/cams/control01.ctl'
-
ORA-27041: unable to open file
-
Linux-x86_64 Error: 2: No such file or directory
- Additional information: 3
這種控制檔案丟失的情況並不是很嚴重,按照下面操作步驟就能完美恢復控制檔案:
1.關閉資料庫例項
-
SYS@cams>shutdown immediate;
-
ORA-00210: cannot open the specified control file
-
ORA-00202: control file: '/u01/app/oracle/oradata/cams/control01.ctl'
-
ORA-27041: unable to open file
-
Linux-x86_64 Error: 2: No such file or directory
-
Additional information: 3
-
SYS@cams>shutdown abort;
- ORACLE instance shut down.
2.將正常的控制檔案複製至丟失的控制檔案所在位置
-
[oracle@ora11g ~]$ cp /u01/app/oracle/fast_recovery_area/cams/control02.ctl /u01/app/oracle/oradata/cams/control01.ctl
-
[oracle@ora11g ~]$ ll /u01/app/oracle/oradata/cams/control01.ctl
- -rw-r-----. 1 oracle oinstall 9945088 Aug 18 21:26 /u01/app/oracle/oradata/cams/control01.ctl
3.啟動資料庫例項
-
SYS@cams>startup;
-
ORACLE instance started.
-
-
Total System Global Area 776646656 bytes
-
Fixed Size 2257272 bytes
-
Variable Size 478154376 bytes
-
Database Buffers 289406976 bytes
-
Redo Buffers 6828032 bytes
-
Database mounted.
- Database opened.
4.執行語句檢查資料庫是否恢復正常
-
SYS@cams>select open_mode from v$database;
-
-
OPEN_MODE
-
--------------------
- READ WRITE
至此,資料庫恢復正常。如果資料庫做了控制檔案多路複用,然後出現其中部分控制檔案丟失的情況,都可以用該方法進行恢復。簡單的總結,就是在資料庫關閉的情況下,用正常的控制檔案去替換丟失的控制檔案,然後啟動即可。
第二種情況:資料庫處於關閉狀態,控制檔案有多路複用,部分控制檔案丟失
首先關閉資料庫
-
SYS@cams>shutdown immediate;
-
Database closed.
-
Database dismounted.
- ORACLE instance shut down.
然後將其中一個控制檔案重新命名,模擬控制檔案丟失
-
[oracle@ora11g cams]$ ls | grep control
-
control01.ctl
-
control01.ctl.bak
-
[oracle@ora11g cams]$ mv control01.ctl control01.ctl.bak1
-
[oracle@ora11g cams]$ ls | grep control
-
control01.ctl.bak
- control01.ctl.bak1
啟動資料庫,發現報錯
-
SYS@cams>startup;
-
ORACLE instance started.
-
-
Total System Global Area 776646656 bytes
-
Fixed Size 2257272 bytes
-
Variable Size 478154376 bytes
-
Database Buffers 289406976 bytes
-
Redo Buffers 6828032 bytes
- ORA-00205: error in identifying control file, check alert log for more info
檢視trace日誌檔案
-
[oracle@ora11g ~]$ tail -n 20 /u01/app/oracle/diag/rdbms/cams/cams/trace/alert_cams.log
-
SMON started with pid=13, OS id=3162
-
Fri Aug 18 21:31:41 2017
-
RECO started with pid=14, OS id=3164
-
Fri Aug 18 21:31:41 2017
-
MMON started with pid=15, OS id=3166
-
starting up 1 dispatcher(s) for network address '(ADDRESS=(PARTIAL=YES)(PROTOCOL=TCP))'...
-
Fri Aug 18 21:31:41 2017
-
MMNL started with pid=16, OS id=3168
-
starting up 1 shared server(s) ...
-
ORACLE_BASE from environment = /u01/app/oracle
-
Fri Aug 18 21:31:41 2017
-
ALTER DATABASE MOUNT
-
ORA-00210: cannot open the specified control file
-
ORA-00202: control file: '/u01/app/oracle/oradata/cams/control01.ctl'
-
ORA-27037: unable to obtain file status
-
Linux-x86_64 Error: 2: No such file or directory
-
Additional information: 3
-
ORA-205 signalled during: ALTER DATABASE MOUNT...
-
Fri Aug 18 21:31:41 2017
- Checker run found 1 new persistent data failures
然後可以開啟trace日誌檔案,找到資料庫啟動時候的引數資訊:
-
Using parameter settings in server-side spfile /u01/app/oracle/product/11.2.0/db_1/dbs/spfilecams.ora
-
System parameters with non-default values:
-
processes = 150
-
memory_target = 744M
-
control_files = "/u01/app/oracle/oradata/cams/control01.ctl"
-
control_files = "/u01/app/oracle/fast_recovery_area/cams/control02.ctl"
-
db_block_size = 8192
-
compatible = "11.2.0.4.0"
-
db_recovery_file_dest = "/u01/app/oracle/fast_recovery_area"
-
db_recovery_file_dest_size= 4182M
-
undo_tablespace = "UNDOTBS1"
-
remote_login_passwordfile= "EXCLUSIVE"
-
db_domain = ""
-
dispatchers = "(PROTOCOL=TCP) (SERVICE=camsXDB)"
-
job_queue_processes = 1000
-
audit_file_dest = "/u01/app/oracle/admin/cams/adump"
-
audit_trail = "DB"
-
db_name = "cams"
-
open_cursors = 300
- diagnostic_dest = "/u01/app/oracle"
根據資料庫啟動時的引數資訊,可以進行控制檔案恢復。處理故障的方法就和第一種情況類似,先關閉資料庫,然後用正常的控制檔案去替換丟失的控制檔案,然後啟動資料庫後進行驗證即可。
第三種情況:資料庫處於啟動狀態,全部控制檔案丟失
將所有控制檔案都重新命名,模擬全部控制檔案丟失
-
[oracle@ora11g ~]$ mv /u01/app/oracle/oradata/cams/control01.ctl /u01/app/oracle/oradata/cams/control01.ctl.bak2
-
[oracle@ora11g ~]$ ll /u01/app/oracle/oradata/cams | grep control
-
-rw-r-----. 1 oracle oinstall 9945088 Aug 18 21:25 control01.ctl.bak
-
-rw-r-----. 1 oracle oinstall 9945088 Aug 18 21:29 control01.ctl.bak1
-
-rw-r-----. 1 oracle oinstall 9945088 Aug 19 10:44 control01.ctl.bak2
-
[oracle@ora11g ~]$ mv /u01/app/oracle/fast_recovery_area/cams/control02.ctl /u01/app/oracle/fast_recovery_area/cams/control02.ctl.bak
-
[oracle@ora11g ~]$ ll /u01/app/oracle/fast_recovery_area/cams
-
total 9712
- -rw-r-----. 1 oracle oinstall 9945088 Aug 19 10:44 control02.ctl.bak
用sqlplus開啟一個新的連線,從控制檔案檢視資料庫資訊,做一些結構化變更,包括:
l 新增,刪除或重新命名資料檔案
l 新增或刪除表空間,或更改表空間的讀/寫狀態
l 新增或刪除重做日誌檔案或重做日誌組
這裡為了操作簡單,修改表空間的讀/寫狀態:
-
[oracle@ora11g ~]$ sqlplus / as sysdba
-
-
SQL*Plus: Release 11.2.0.4.0 Production on Sat Aug 19 10:46:35 2017
-
-
Copyright (c) 1982, 2013, Oracle. All rights reserved.
-
-
-
Connected to:
-
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
-
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-
-
SYS@cams>select open_mode from v$database;
-
select open_mode from v$database
-
*
-
ERROR at line 1:
-
ORA-00210: cannot open the specified control file
-
ORA-00202: control file: '/u01/app/oracle/oradata/cams/control01.ctl'
-
ORA-27041: unable to open file
-
Linux-x86_64 Error: 2: No such file or directory
-
Additional information: 3
-
-
SYS@cams>select tablespace_name,status from dba_tablespaces;
-
-
TABLESPACE_NAME STATUS
-
------------------------------ ---------
-
SYSTEM ONLINE
-
SYSAUX ONLINE
-
UNDOTBS1 ONLINE
-
TEMP ONLINE
-
USERS ONLINE
-
EXAMPLE ONLINE
-
FINCHINAFCDD ONLINE
-
FINCHINAFCDD_BIGTABLE ONLINE
-
-
8 rows selected.
-
-
SYS@cams>alter tablespace example read only;
-
alter tablespace example read only
-
*
-
ERROR at line 1:
-
ORA-00603: ORACLE server session terminated by fatal error
-
ORA-00210: cannot open the specified control file
-
ORA-00202: control file: '/u01/app/oracle/oradata/cams/control01.ctl'
-
ORA-27041: unable to open file
-
Linux-x86_64 Error: 2: No such file or directory
-
Additional information: 3
-
ORA-00210: cannot open the specified control file
-
ORA-00202: control file: '/u01/app/oracle/oradata/cams/control01.ctl'
-
ORA-27041: unable to open file
-
Linux-x86_64 Error: 2: No such file or directory
-
Additional information: 3
-
Process ID: 2705
-
Session ID: 11 Serial number: 7
-
-
SYS@cams>select tablespace_name,status from dba_tablespaces;
-
ERROR:
- ORA-03114: not connected to ORACLE
在進行結構化變更操作之後,資料庫連線被自行斷開了,不過如果再建立一個連線,還是可以進行資料庫的增刪改查操作的:
-
[oracle@ora11g ~]$ sqlplus / as sysdba
-
-
SQL*Plus: Release 11.2.0.4.0 Production on Sat Aug 19 10:57:55 2017
-
-
Copyright (c) 1982, 2013, Oracle. All rights reserved.
-
-
-
Connected to:
-
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
-
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-
-
SYS@cams>alter user sh identified by sh account unlock;
-
-
User altered.
-
-
SYS@cams>conn sh/sh
-
Connected.
-
SH@cams>create table test (id number,name varchar2(20));
-
-
Table created.
-
-
SH@cams>insert into test values(1,'joe');
-
-
1 row created.
-
-
SH@cams>insert into test values(2,'jeff');
-
-
1 row created.
-
-
SH@cams>update test set name='jack' where id=2;
-
-
1 row updated.
-
-
SH@cams>select * from test where id=2;
-
-
ID NAME
-
---------- --------------------
-
2 jack
-
-
SH@cams>delete from test where id=2;
-
-
1 row deleted.
-
-
SH@cams>select count(*) from test;
-
-
COUNT(*)
-
----------
-
1
-
- SH@cams>
不只是增刪改查操作,只要不要涉及到控制檔案的讀寫,還可以進行其他操作,比如drop table之後從recyclebin恢復刪除的表:
-
SH@cams>drop table test;
-
-
Table dropped.
-
-
SH@cams>select count(*) from test;
-
select count(*) from test
-
*
-
ERROR at line 1:
-
ORA-00942: table or view does not exist
-
-
-
SH@cams>show recycle
-
ORIGINAL NAME RECYCLEBIN NAME OBJECT TYPE DROP TIME
-
---------------- ------------------------------ ------------ -------------------
-
TEST BIN$VxOFH0JXCxjgU4IKqMCSFw==$0 TABLE 2017-08-19:11:05:37
-
SH@cams>flashback table "BIN$VxOFH0JXCxjgU4IKqMCSFw==$0" to before drop rename to test1;
-
-
Flashback complete.
-
-
SH@cams>select * from test1;
-
-
ID NAME
-
---------- --------------------
- 1 joe
Oracle資料庫在控制檔案全部丟失的情況下,還能提供那麼多服務,已經很了不起了。現在,我們最重要的事情就是恢復控制檔案,保證資料庫所有功能都可以正常執行,操作步驟如下:
1.列出資料庫的所有資料檔案和重做日誌檔案。
首先嚐試用資料庫檢視檢視:
-
SYS@cams>SELECT MEMBER FROM V$LOGFILE;
-
SELECT MEMBER FROM V$LOGFILE
-
*
-
ERROR at line 1:
-
ORA-00210: cannot open the specified control file
-
ORA-00202: control file: '/u01/app/oracle/oradata/cams/control01.ctl'
-
ORA-27041: unable to open file
-
Linux-x86_64 Error: 2: No such file or directory
-
Additional information: 3
-
-
SYS@cams>SELECT NAME FROM V$DATAFILE;
-
SELECT NAME FROM V$DATAFILE
-
*
-
ERROR at line 1:
-
ORA-00210: cannot open the specified control file
-
ORA-00202: control file: '/u01/app/oracle/oradata/cams/control01.ctl'
-
ORA-27041: unable to open file
-
Linux-x86_64 Error: 2: No such file or directory
-
Additional information: 3
-
-
-
SYS@cams>SELECT VALUE FROM V$PARAMETER WHERE NAME = 'control_files';
-
-
VALUE
-
--------------------------------------------------------------------------------
-
/u01/app/oracle/oradata/cams/control01.ctl, /u01/app/oracle/fast_recovery_area/c
- ams/control02.ctl
用不了V$LOGFILE和V$DATAFILE檢視,這裡選擇去伺服器上查詢資料庫的所有資料檔案和重做日誌檔案,如果沒有調整過的話,資料檔案和控制檔案在路徑$ORACLE_BASE/oradata/$ORACLE_SID下面:
-
[oracle@ora11g cams]$ cd $ORACLE_BASE/oradata/$ORACLE_SID
-
[oracle@ora11g cams]$ pwd
-
/u01/app/oracle/oradata/cams
-
[oracle@ora11g cams]$ ll
-
total 73973336
-
-rw-r-----. 1 oracle oinstall 9945088 Aug 18 21:25 control01.ctl.bak
-
-rw-r-----. 1 oracle oinstall 9945088 Aug 18 21:29 control01.ctl.bak1
-
-rw-r-----. 1 oracle oinstall 9945088 Aug 19 11:36 control01.ctl.bak2
-
-rw-r-----. 1 oracle oinstall 346038272 Aug 19 10:41 example01.dbf
-
-rw-r-----. 1 oracle oinstall 9042927616 Aug 19 10:41 finchina01.dbf
-
-rw-r-----. 1 oracle oinstall 8413782016 Aug 19 10:41 finchina02.dbf
-
-rw-r-----. 1 oracle oinstall 8623497216 Aug 19 10:41 finchina03.dbf
-
-rw-r-----. 1 oracle oinstall 1073750016 Aug 19 10:41 finchina101.dbf
-
-rw-r-----. 1 oracle oinstall 10737426432 Aug 19 10:41 finchina1.dbf
-
-rw-r-----. 1 oracle oinstall 34359730176 Aug 19 10:41 finchina.dbf
-
-rw-r-----. 1 oracle oinstall 52429312 Aug 19 10:41 redo01.log
-
-rw-r-----. 1 oracle oinstall 52429312 Aug 19 11:36 redo02.log
-
-rw-r-----. 1 oracle oinstall 52429312 Aug 19 10:41 redo03.log
-
-rw-r-----. 1 oracle oinstall 765468672 Aug 19 11:36 sysaux01.dbf
-
-rw-r-----. 1 oracle oinstall 870326272 Aug 19 11:36 system01.dbf
-
-rw-r-----. 1 oracle oinstall 893394944 Aug 19 10:42 temp01.dbf
-
-rw-r-----. 1 oracle oinstall 429924352 Aug 19 11:35 undotbs01.dbf
-
-rw-r-----. 1 oracle oinstall 5251072 Aug 19 11:16 users01.dbf
-
[oracle@ora11g cams]$ du -sm *
-
10 control01.ctl.bak
-
10 control01.ctl.bak1
-
10 control01.ctl.bak2
-
331 example01.dbf
-
8625 finchina01.dbf
-
8025 finchina02.dbf
-
8225 finchina03.dbf
-
1025 finchina101.dbf
-
10241 finchina1.dbf
-
32768 finchina.dbf
-
51 redo01.log
-
51 redo02.log
-
51 redo03.log
-
731 sysaux01.dbf
-
831 system01.dbf
-
853 temp01.dbf
-
411 undotbs01.dbf
- 6 users01.dbf
對於表空間,為了防止落下,先檢視有哪些表空間:
-
SYS@cams>select tablespace_name,status from dba_tablespaces;
-
-
TABLESPACE_NAME STATUS
-
------------------------------ ---------
-
SYSTEM ONLINE
-
SYSAUX ONLINE
-
UNDOTBS1 ONLINE
-
TEMP ONLINE
-
USERS ONLINE
-
EXAMPLE ONLINE
-
FINCHINAFCDD ONLINE
-
FINCHINAFCDD_BIGTABLE ONLINE
-
- 8 rows selected.
將獲取到的資料檔案和重做日誌檔案整理成列表:
編號 |
重做日誌檔案 |
大小(M) |
1 |
/u01/app/oracle/oradata/cams/redo01.log |
51 |
2 |
/u01/app/oracle/oradata/cams/redo02.log |
51 |
3 |
/u01/app/oracle/oradata/cams/redo03.log |
51 |
編號 |
表空間檔案 |
大小(M) |
1 |
/u01/app/oracle/oradata/cams/example01.dbf |
331 |
2 |
/u01/app/oracle/oradata/cams/finchina01.dbf |
8625 |
3 |
/u01/app/oracle/oradata/cams/finchina02.dbf |
8025 |
4 |
/u01/app/oracle/oradata/cams/finchina03.dbf |
8225 |
5 |
/u01/app/oracle/oradata/cams/finchina101.dbf |
1025 |
6 |
/u01/app/oracle/oradata/cams/finchina1.dbf |
10241 |
7 |
/u01/app/oracle/oradata/cams/finchina.dbf |
32768 |
8 |
/u01/app/oracle/oradata/cams/sysaux01.dbf |
731 |
9 |
/u01/app/oracle/oradata/cams/system01.dbf |
831 |
10 |
/u01/app/oracle/oradata/cams/temp01.dbf |
853 |
11 |
/u01/app/oracle/oradata/cams/undotbs01.dbf |
411 |
12 |
/u01/app/oracle/oradata/cams/users01.dbf |
6 |
2.關閉資料庫。
-
SYS@cams>shutdown immediate;
-
ORA-00210: cannot open the specified control file
-
ORA-00202: control file: '/u01/app/oracle/oradata/cams/control01.ctl'
-
ORA-27041: unable to open file
-
Linux-x86_64 Error: 2: No such file or directory
-
Additional information: 3
-
SYS@cams>shutdown abort;
- ORACLE instance shut down.
3.備份資料庫的所有資料檔案和重做日誌檔案。
-
[oracle@ora11g cams]$ tar zcvf cams_backup.tar.gz *
-
control01.ctl.bak
-
control01.ctl.bak1
-
control01.ctl.bak2
-
example01.dbf
-
finchina01.dbf
-
finchina02.dbf
-
finchina03.dbf
-
finchina101.dbf
-
finchina1.dbf
-
finchina.dbf
-
redo01.log
-
redo02.log
-
redo03.log
-
sysaux01.dbf
-
system01.dbf
-
temp01.dbf
-
undotbs01.dbf
-
users01.dbf
-
[oracle@ora11g cams]$ ll
-
total 88069332
-
-rw-r--r--. 1 oracle oinstall 14434295403 Aug 19 18:00 cams_backup.tar.gz
-
-rw-r-----. 1 oracle oinstall 9945088 Aug 18 21:25 control01.ctl.bak
-
-rw-r-----. 1 oracle oinstall 9945088 Aug 18 21:29 control01.ctl.bak1
-
-rw-r-----. 1 oracle oinstall 9945088 Aug 19 13:43 control01.ctl.bak2
-
-rw-r-----. 1 oracle oinstall 346038272 Aug 19 10:41 example01.dbf
-
-rw-r-----. 1 oracle oinstall 9042927616 Aug 19 10:41 finchina01.dbf
-
-rw-r-----. 1 oracle oinstall 8413782016 Aug 19 10:41 finchina02.dbf
-
-rw-r-----. 1 oracle oinstall 8623497216 Aug 19 10:41 finchina03.dbf
-
-rw-r-----. 1 oracle oinstall 1073750016 Aug 19 10:41 finchina101.dbf
-
-rw-r-----. 1 oracle oinstall 10737426432 Aug 19 10:41 finchina1.dbf
-
-rw-r-----. 1 oracle oinstall 34359730176 Aug 19 10:41 finchina.dbf
-
-rw-r-----. 1 oracle oinstall 52429312 Aug 19 10:41 redo01.log
-
-rw-r-----. 1 oracle oinstall 52429312 Aug 19 13:43 redo02.log
-
-rw-r-----. 1 oracle oinstall 52429312 Aug 19 10:41 redo03.log
-
-rw-r-----. 1 oracle oinstall 765468672 Aug 19 13:40 sysaux01.dbf
-
-rw-r-----. 1 oracle oinstall 870326272 Aug 19 13:40 system01.dbf
-
-rw-r-----. 1 oracle oinstall 893394944 Aug 19 10:42 temp01.dbf
-
-rw-r-----. 1 oracle oinstall 429924352 Aug 19 13:42 undotbs01.dbf
- -rw-r-----. 1 oracle oinstall 5251072 Aug 19 11:16 users01.dbf
4.啟動一個新的例項,但不要掛載或開啟資料庫:
-
SYS@cams>startup nomount;
-
ORACLE instance started.
-
-
Total System Global Area 776646656 bytes
-
Fixed Size 2257272 bytes
-
Variable Size 478154376 bytes
-
Database Buffers 289406976 bytes
- Redo Buffers 6828032 bytes
5.使用CREATE CONTROLFILE語句為資料庫建立一個新的控制檔案。
-
CREATE CONTROLFILE
-
REUSE DATABASE cams
-
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/cams/redo01.log'),
-
GROUP 2 ('/u01/app/oracle/oradata/cams/redo02.log'),
-
GROUP 3 ('/u01/app/oracle/oradata/cams/redo03.log')
-
NORESETLOGS
-
DATAFILE '/u01/app/oracle/oradata/cams/example01.dbf',
-
'/u01/app/oracle/oradata/cams/finchina01.dbf',
-
'/u01/app/oracle/oradata/cams/finchina02.dbf',
-
'/u01/app/oracle/oradata/cams/finchina03.dbf',
-
'/u01/app/oracle/oradata/cams/finchina101.dbf',
-
'/u01/app/oracle/oradata/cams/finchina1.dbf',
-
'/u01/app/oracle/oradata/cams/finchina.dbf',
-
'/u01/app/oracle/oradata/cams/sysaux01.dbf',
-
'/u01/app/oracle/oradata/cams/system01.dbf',
-
'/u01/app/oracle/oradata/cams/temp01.dbf',
-
'/u01/app/oracle/oradata/cams/undotbs01.dbf',
-
'/u01/app/oracle/oradata/cams/users01.dbf'
-
MAXLOGFILES 50
-
MAXLOGMEMBERS 3
-
MAXLOGHISTORY 400
-
MAXDATAFILES 200
-
MAXINSTANCES 6
- NOARCHIVELOG
提示錯誤:
-
ERROR at line 1:
-
ORA-01503: CREATE CONTROLFILE failed
-
ORA-01160: file is not a data file
- ORA-01110: data file : '/u01/app/oracle/oradata/cams/temp01.dbf'
這裡去掉CREATE CONTROLFILE語句裡面的臨時表空間
-
CREATE CONTROLFILE
-
REUSE DATABASE cams
-
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/cams/redo01.log'),
-
GROUP 2 ('/u01/app/oracle/oradata/cams/redo02.log'),
-
GROUP 3 ('/u01/app/oracle/oradata/cams/redo03.log')
-
NORESETLOGS
-
DATAFILE '/u01/app/oracle/oradata/cams/example01.dbf',
-
'/u01/app/oracle/oradata/cams/finchina01.dbf',
-
'/u01/app/oracle/oradata/cams/finchina02.dbf',
-
'/u01/app/oracle/oradata/cams/finchina03.dbf',
-
'/u01/app/oracle/oradata/cams/finchina101.dbf',
-
'/u01/app/oracle/oradata/cams/finchina1.dbf',
-
'/u01/app/oracle/oradata/cams/finchina.dbf',
-
'/u01/app/oracle/oradata/cams/sysaux01.dbf',
-
'/u01/app/oracle/oradata/cams/system01.dbf',
-
'/u01/app/oracle/oradata/cams/undotbs01.dbf',
-
'/u01/app/oracle/oradata/cams/users01.dbf'
-
MAXLOGFILES 50
-
MAXLOGMEMBERS 3
-
MAXLOGHISTORY 400
-
MAXDATAFILES 200
-
MAXINSTANCES 6
- NOARCHIVELOG
看到提示“Control file created.”
檢視資料庫的狀態,可以看到資料庫成功切換為mount狀態
-
SYS@cams>select open_mode from v$database;
-
-
OPEN_MODE
-
--------------------
- MOUNTED
5.正常開啟資料庫,必要時進行資料庫恢復,然後再開啟資料庫。
-
SYS@cams>alter database open;
-
alter database open
-
*
-
ERROR at line 1:
-
ORA-01113: file 1 needs media recovery
-
ORA-01110: data file 1: '/u01/app/oracle/oradata/cams/system01.dbf'
-
-
-
SYS@cams>recover database;
-
Media recovery complete.
-
SYS@cams>alter database open;
-
- Database altered.
6.進行簡單的資料庫檢查,修復一些未處理的問題。
檢查trace日誌檔案
-
Sat Aug 19 20:15:42 2017
-
Errors in file /u01/app/oracle/diag/rdbms/cams/cams/trace/cams_m001_4792.trc:
-
ORA-25153: Temporary Tablespace is Empty
-
Sat Aug 19 20:16:39 2017
-
Errors in file /u01/app/oracle/diag/rdbms/cams/cams/trace/cams_j000_4820.trc:
- ORA-25153: Temporary Tablespace is Empty
發現ORA-25153錯誤,檢視臨時表空間檢視:
-
SYS@cams>select * from dba_temp_files;
-
-
no rows selected
-
-
SYS@cams>select * from v$tempfile;
-
- no rows selected
為資料庫新增臨時表空間,檔案已經存在,使用reuse語句複用即可:
-
SYS@cams>alter tablespace temp add tempfile '/u01/app/oracle/oradata/cams/temp01.dbf' size 853m reuse autoextend on;
-
-
Tablespace altered.
-
-
SYS@cams>select * from dba_temp_files;
-
-
FILE_NAME
-
--------------------------------------------------------------------------------
-
FILE_ID TABLESPACE_NAME BYTES BLOCKS STATUS
-
---------- ------------------------------ ---------- ---------- -------
-
RELATIVE_FNO AUT MAXBYTES MAXBLOCKS INCREMENT_BY USER_BYTES USER_BLOCKS
-
------------ --- ---------- ---------- ------------ ---------- -----------
-
/u01/app/oracle/oradata/cams/temp01.dbf
-
1 TEMP 894435328 109184 ONLINE
-
1 YES 3.4360E+10 4194302 1 893386752 109056
-
-
-
SYS@cams>select * from v$tempfile;
-
-
FILE# CREATION_CHANGE# CREATION_ TS# RFILE# STATUS ENABLED
-
---------- ---------------- --------- ---------- ---------- ------- ----------
-
BYTES BLOCKS CREATE_BYTES BLOCK_SIZE
-
---------- ---------- ------------ ----------
-
NAME
-
--------------------------------------------------------------------------------
-
1 84418072 19-AUG-17 3 1 ONLINE READ WRITE
-
894435328 109184 894435328 8192
- /u01/app/oracle/oradata/cams/temp01.dbf
資料庫現已開啟並可用。
第四種情況:資料庫處於關閉狀態,全部控制檔案丟失
這種情況下的處理方法和第三種情況基本一致,只是如果控制檔案沒有恢復好,資料庫是不能對外提供服務的。但是第三種情況下,資料庫還能提供和控制檔案無關的增刪改查等服務。
最後總結
控制檔案的多路複用以及控制檔案的備份是很重要的,使用ALTER DATABASE BACKUP CONTROLFILE語句備份你的控制檔案。你有兩個選擇:
l 使用下列語句將控制檔案備份到二進位制檔案(現有控制檔案的副本):
ALTER DATABASE BACKUP CONTROLFILE TO '/u01/app/oracle/oradata/cams/control.bkp';
l 生成可以用於重新建立控制檔案的SQL語句:
ALTER DATABASE BACKUP CONTROLFILE TO TRACE;
此命令將SQL指令碼寫入trace檔案,可以對其進行抓取和編輯以重現控制檔案。透過檢視告警日誌可以確定跟蹤檔案的名稱和位置。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29734436/viewspace-2144209/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Linux中inittab檔案丟了怎麼辦Linux
- 當機了,Redis資料丟了怎麼辦?Redis
- oracle11g修改控制檔案路徑Oracle
- win10 誤刪檔案怎麼辦_win10系統誤刪檔案怎麼辦Win10
- mac有些檔案搜不到怎麼辦?Mac
- .ibd檔案壞了怎麼辦?
- FTP上傳檔案速度太慢怎麼辦?FTP
- Mac打不開txt檔案怎麼辦Mac
- AirPods丟了怎麼辦?弄丟AirPods的11種方法AI
- 檔案傳輸中斷怎麼辦?對檔案會有什麼影響?
- python檔案無法讀寫怎麼辦Python
- /var檔案系統滿了,該怎麼辦?
- 電腦誤刪除檔案怎麼恢復檔案,不小心刪除了電腦的檔案怎麼辦
- 開啟壓縮檔案提示不能開啟此檔案怎麼辦
- win10 檔案拖不動怎麼辦_win10資料夾裡的檔案拖不動怎麼辦Win10
- 系統檔案丟失怎麼辦 系統檔案損壞的解決辦法
- 不小心刪除/etc/passwd檔案怎麼辦
- Mac檔案共享不起作用時該怎麼辦Mac
- 隨身碟檔案老是被隱藏怎麼辦
- 剪下後的檔案可以恢復嗎?恢復剪下檔案怎麼辦?
- win10找不到gpedit.msc檔案怎麼辦 沒有gpedit.msc怎麼辦Win10
- oracle11g控制檔案自動備份延遲特性Oracle
- 如何檢視Oracle11g控制檔案裡面的內容Oracle
- 【控制檔案】映象控制檔案
- mysql匯入sql檔案過大失敗怎麼辦MySql
- win10刪除檔案特別慢怎麼辦Win10
- EXCEL不可讀怎麼辦,修復EXCEL檔案不可讀Excel
- 【/proc/檔案淺析】另類辦法恢復資料檔案和控制檔案
- oracle11g 新特性 - rman自動備份控制檔案延遲Oracle
- vs code 就單獨寫 js 檔案不提示 怎麼辦JS
- win7中hosts檔案無法儲存怎麼辦?Win7
- 隨身碟中的檔案無法讀取了怎麼辦?
- 電腦突然斷電導致檔案丟失怎麼辦?
- JSP網頁中下載xls檔案亂碼怎麼辦?JS網頁
- win10複製小檔案速度太慢怎麼辦 win10複製檔案速度慢怎麼解決Win10
- html檔案怎麼開啟(手機html檔案怎麼開啟)HTML
- win10不能開啟控制皮膚怎麼辦 win10系統控制皮膚打不開怎麼辦Win10
- 想要提取PDF檔案中的美麗圖片,該怎麼辦?