1.前言
在oracle的运维过程中,时常会遇到一些场景需要重建控制文件,以下是通过复制控制文件到新路径,运行一段时间后,再用老的控制文件启动数据库重现。
2.步骤
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 218106944 bytes Database Buffers 373293056 bytes Redo Buffers 6287360 bytes Database mounted. SQL> alter database backup controlfile to trace; ##这里会生产一个trace文件,该文件中有一些控制文件的创建语句 Database altered. SQL> oradebug setmypid Statement processed. SQL> oradebug tracefile_name /s01/oracle/admin/cxywdb/udump/cxywdb_ora_3983.trc ##这个是trace文件的位置 SQL> shutdown abort ORACLE instance shut down. SQL> startup nomount; ORACLE instance started. Total System Global Area 599785472 bytes Fixed Size 2098112 bytes Variable Size 218106944 bytes Database Buffers 373293056 bytes Redo Buffers 6287360 bytes SQL> @control.sql ##这里应该是上面创建控制语句的sql文件(用vim创建一个控制文件) Control file created. SQL> select status from v$instance; STATUS ------------ MOUNTED SQL> recover database; Media recovery complete. SQL> alter database open; Database altered.
创建控制文件的官方文档:https://docs.oracle.com/cd/B28359_01/server.111/b28310/control003.htm#ADMIN10064