- SQL> select name from v$controlfile;
-
- NAME
- --------------------------------------------------------------------------------
- /u01/app/oracle/oradata/orcl/control01.ctl
- /u01/app/oracle/fast_recovery_area/orcl/control02.ctl
spfile多路复用控制文件
- SQL> alter system set
- control_files='/u01/app/oracle/oradata/orcl/control02.ctl',
- '/u01/app/oracle/oradata/orcl/control03.ctl',
- '/u01/app/oracle/oradata/orcl/control05.ctl'
- scope=spfile;
- SQL> shutdown immediate;
- Database closed.
- Database dismounted.
- ORACLE instance shut down
- [oracle@cz ~]$ cp /u01/app/oracle/oradata/orcl/control01.ctl /u01/app/oracle/oradata/orcl/control02.ctl
- [oracle@cz ~]$ cp /u01/app/oracle/oradata/orcl/control01.ctl /u01/app/oracle/oradata/orcl/control03.ctl
- [oracle@cz ~]$ cp /u01/app/oracle/oradata/orcl/control01.ctl /u01/app/oracle/oradata/orcl/control05.ctl
[oracle@cz ~]$ sqlplus / as sysdba
- SQL> startup;
- ORACLE instance started.
-
- Total System Global Area 1169149952 bytes
- Fixed Size 2252624 bytes
- Variable Size 738197680 bytes
- Database Buffers 419430400 bytes
- Redo Buffers 9269248 bytes
- Database mounted.
- Database opened.
- SQL> select name from v$controlfile;
-
- NAME
- --------------------------------------------------------------------------------
- /u01/app/oracle/oradata/orcl/control02.ctl
- /u01/app/oracle/oradata/orcl/control03.ctl
- /u01/app/oracle/oradata/orcl/control05.ctl
- 关闭数据库
- SQL> shutdown immediate;
- 模拟单个控制文件损坏
- SQL> !rm -rf /u01/app/oracle/oradata/orcl/control05.ctl
- SQL> startup;
- ORACLE instance started.
-
- Total System Global Area 1169149952 bytes
- Fixed Size 2252624 bytes
- Variable Size 738197680 bytes
- Database Buffers 419430400 bytes
- Redo Buffers 9269248 bytes
- ORA-00205: error in identifying control file, check alert log for more info
SQL> !cp /u01/app/oracle/oradata/orcl/control02.ctl /u01/app/oracle/oradata/orcl/control05.ctl
- SQL> startup
- ORACLE instance started.
-
- Total System Global Area 1169149952 bytes
- Fixed Size 2252624 bytes
- Variable Size 738197680 bytes
- Database Buffers 419430400 bytes
- Redo Buffers 9269248 bytes
- Database mounted.
- Database opened.
- SQL> select name from v$controlfile;
-
- NAME
- --------------------------------------------------------------------------------
- /u01/app/oracle/oradata/orcl/control02.ctl
- /u01/app/oracle/oradata/orcl/control03.ctl
- /u01/app/oracle/oradata/orcl/control05.ctl
实例状态
- SQL> select status from v$instance;
-
- STATUS
- ------------
- OPEN
- SQL> alter database backup controlfile to trace as '/u01/app/oracle/oradata/orcl/controfiles.bak';
-
- Database altered.
- SQL> !rm -rf /u01/app/oracle/oradata/orcl/control02.ctl
-
- SQL> !rm -rf /u01/app/oracle/oradata/orcl/control03.ctl
-
- SQL> !rm -rf /u01/app/oracle/oradata/orcl/control05.ctl
-
- SQL> startup
- ORACLE instance started.
-
- Total System Global Area 1169149952 bytes
- Fixed Size 2252624 bytes
- Variable Size 738197680 bytes
- Database Buffers 419430400 bytes
- Redo Buffers 9269248 bytes
- ORA-00205: error in identifying control file, check alert log for more info
-
启动报错
- QL> startup
- ORACLE instance started.
-
- Total System Global Area 1169149952 bytes
- Fixed Size 2252624 bytes
- Variable Size 738197680 bytes
- Database Buffers 419430400 bytes
- Redo Buffers 9269248 bytes
- Database mounted.
- ORA-01122: database file 1 failed verification check
- ORA-01110: data file 1: '/u01/app/oracle/oradata/orcl/system01.dbf'
- ORA-01207: file is more recent than control file - old control file
把下面方框中的sql编辑成脚本并执行
创建脚本文件
[oracle@cz orcl]$ vim control.sql
把上面的sql粘贴进去作为脚本
执行脚本
- SQL> @control.sql
- SP2-0734: unknown command beginning "TARTUP NOM..." - rest of line ignored.
-
- Control file created.
-
查看实例状态数据库恢复正常
- SQL> select status from v$instance;
-
- STATUS
- ------------
- OPEN
- 这时,控制文件里面的 SCN 号就追平了数据文件头部的 SCN 号了。
- SQL> select file#,checkpoint_change# from v$datafile;
- SQL> select file#,checkpoint_change# from v$datafile_header;
- SQL> select * from v$tempfile;
-
- no rows selected
- SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/app/oracle/oradata/orcl/temp01.dbf' SIZE 30408704 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
-
- Tablespace altered.
- SQL> select name from v$tempfile;
-
- NAME
- --------------------------------------------------------------------------------
- /u01/app/oracle/oradata/orcl/temp01.dbf