1、控制文件概述
1.1 概念
1.2 控制文件的内容包括
2、查看控制文件的个数、名称和位置
2.1 使用 show parameter 命令
SQL> show parameter control_filesNAME TYPE VALUE------------------------------------ ----------- ------------------------------control_files string app/oracle/oradata/ORCL/control01.ctl, /app/oracle/oradata/ORCL/control02.ctl
2.2 查看 v$controlfile 视图
SQL> desc v$controlfileName Type Nullable Default Comments--------------------- ------------- -------- ------- --------STATUS VARCHAR2(7) YNAME VARCHAR2(513) YIS_RECOVERY_DEST_FILE VARCHAR2(3) YBLOCK_SIZE NUMBER YFILE_SIZE_BLKS NUMBER YCON_ID NUMBER YSQL> select * from v$controlfile;STATUS NAME IS_RECOVERY_DEST_FILE BLOCK_SIZE FILE_SIZE_BLKS CON_ID------- -------------------------------------------------------------------------------- --------------------- ---------- -------------- ----------/app/oracle/oradata/ORCL/control01.ctl NO 16384 646 0/app/oracle/oradata/ORCL/control02.ctl NO 16384 646 0
3、查看控制文件的内容
3.1 将控制文件转出为文本文件
SQL> alter database backup controlfile to trace as '/home/oracle/ctl001.txt';Database altered.
3.2 查看文件的内容
[oracle@rac1 ~]$ cat ctl001.txt-- The following are current System-scope REDO Log Archival related-- parameters and can be included in the database initialization file.---- LOG_ARCHIVE_DEST=''-- LOG_ARCHIVE_DUPLEX_DEST=''---- LOG_ARCHIVE_FORMAT=orcl_%d_%S_%t_%r.dbf---- DB_UNIQUE_NAME="orcl"---- LOG_ARCHIVE_CONFIG='SEND, RECEIVE, NODG_CONFIG'-- LOG_ARCHIVE_MAX_PROCESSES=4-- STANDBY_FILE_MANAGEMENT=MANUAL-- FAL_CLIENT=''-- FAL_SERVER=''---- LOG_ARCHIVE_DEST_1='LOCATION=/app/archive'-- LOG_ARCHIVE_DEST_1='OPTIONAL REOPEN=300 NODELAY'-- LOG_ARCHIVE_DEST_1='ARCH NOAFFIRM NOVERIFY SYNC'-- LOG_ARCHIVE_DEST_1='REGISTER'-- LOG_ARCHIVE_DEST_1='NOALTERNATE'-- LOG_ARCHIVE_DEST_1='NODEPENDENCY'-- LOG_ARCHIVE_DEST_1='NOMAX_FAILURE NOQUOTA_SIZE NOQUOTA_USED NODB_UNIQUE_NAME'-- LOG_ARCHIVE_DEST_1='VALID_FOR=(PRIMARY_ROLE,ONLINE_LOGFILES)'-- LOG_ARCHIVE_DEST_STATE_1=ENABLE---- Below are two sets of SQL statements, each of which creates a new-- control file and uses it to open the database. The first set opens-- the database with the NORESETLOGS option and should be used only if-- the current versions of all online logs are available. The second-- set opens the database with the RESETLOGS option and should be used-- if online logs are unavailable.-- The appropriate set of statements can be copied from the trace into-- a script file, edited as necessary, and executed when there is a-- need to re-create the control file.---- Set #1. NORESETLOGS case---- The following commands will create a new control file and use it-- to open the database.-- Data used by Recovery Manager will be lost.-- Additional logs may be required for media recovery of offline-- Use this only if the current versions of all online logs are-- available.-- After mounting the created controlfile, the following SQL-- statement will place the database in the appropriate-- protection mode:-- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCESTARTUP NOMOUNTCREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS ARCHIVELOGMAXLOGFILES 16MAXLOGMEMBERS 3MAXDATAFILES 100MAXINSTANCES 8MAXLOGHISTORY 292LOGFILEGROUP 1 '/app/oracle/oradata/ORCL/redo01.log' SIZE 200M BLOCKSIZE 512,GROUP 2 '/app/oracle/oradata/ORCL/redo02.log' SIZE 200M BLOCKSIZE 512,GROUP 3 '/app/oracle/oradata/ORCL/redo03.log' SIZE 200M BLOCKSIZE 512-- STANDBY LOGFILEDATAFILE'/app/oracle/oradata/ORCL/system01.dbf','/app/oracle/oradata/ORCL/test01.DBF','/app/oracle/oradata/ORCL/sysaux01.dbf','/app/oracle/oradata/ORCL/undotbs01.dbf','/app/oracle/oradata/ORCL/wms01.DBF','/app/oracle/oradata/ORCL/users01.dbf'CHARACTER SET ZHS16GBK;-- Commands to re-create incarnation table-- Below log names MUST be changed to existing filenames on-- disk. Any one log file from each branch can be used to-- re-create incarnation records.-- ALTER DATABASE REGISTER LOGFILE '/app/archive/orcl_62725153_0000000001_1_1005785759.dbf';-- ALTER DATABASE REGISTER LOGFILE '/app/archive/orcl_62725153_0000000001_1_1123878365.dbf';-- Recovery is required if any of the datafiles are restored backups,-- or if the last shutdown was not normal or immediate.RECOVER DATABASE-- All logs need archiving and a log switch is needed.ALTER SYSTEM ARCHIVE LOG ALL;-- Database can now be opened normally.ALTER DATABASE OPEN;-- Commands to add tempfiles to temporary tablespaces.-- Online tempfiles have complete space information.-- Other tempfiles may require adjustment.ALTER TABLESPACE TEMP ADD TEMPFILE '/app/oracle/oradata/ORCL/temp01.dbf'SIZE 33554432 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;-- End of tempfile additions.---- Set #2. RESETLOGS case---- The following commands will create a new control file and use it-- to open the database.-- Data used by Recovery Manager will be lost.-- The contents of online logs will be lost and all backups will-- be invalidated. Use this only if online logs are damaged.-- After mounting the created controlfile, the following SQL-- statement will place the database in the appropriate-- protection mode:-- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCESTARTUP NOMOUNTCREATE CONTROLFILE REUSE DATABASE "ORCL" RESETLOGS ARCHIVELOGMAXLOGFILES 16MAXLOGMEMBERS 3MAXDATAFILES 100MAXINSTANCES 8MAXLOGHISTORY 292LOGFILEGROUP 1 '/app/oracle/oradata/ORCL/redo01.log' SIZE 200M BLOCKSIZE 512,GROUP 2 '/app/oracle/oradata/ORCL/redo02.log' SIZE 200M BLOCKSIZE 512,GROUP 3 '/app/oracle/oradata/ORCL/redo03.log' SIZE 200M BLOCKSIZE 512-- STANDBY LOGFILEDATAFILE'/app/oracle/oradata/ORCL/system01.dbf','/app/oracle/oradata/ORCL/test01.DBF','/app/oracle/oradata/ORCL/sysaux01.dbf','/app/oracle/oradata/ORCL/undotbs01.dbf','/app/oracle/oradata/ORCL/wms01.DBF','/app/oracle/oradata/ORCL/users01.dbf'CHARACTER SET ZHS16GBK;-- Commands to re-create incarnation table-- Below log names MUST be changed to existing filenames on-- disk. Any one log file from each branch can be used to-- re-create incarnation records.-- ALTER DATABASE REGISTER LOGFILE '/app/archive/orcl_62725153_0000000001_1_1005785759.dbf';-- ALTER DATABASE REGISTER LOGFILE '/app/archive/orcl_62725153_0000000001_1_1123878365.dbf';-- Recovery is required if any of the datafiles are restored backups,-- or if the last shutdown was not normal or immediate.RECOVER DATABASE USING BACKUP CONTROLFILE-- Database can now be opened zeroing the online logs.ALTER DATABASE OPEN RESETLOGS;-- Commands to add tempfiles to temporary tablespaces.-- Online tempfiles have complete space information.-- Other tempfiles may require adjustment.ALTER TABLESPACE TEMP ADD TEMPFILE '/app/oracle/oradata/ORCL/temp01.dbf'SIZE 33554432 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;-- End of tempfile additions.--
3.3 使用 strings 命令直接查看控制文件
SQL> select * from v$controlfile;STATUS NAME IS_RECOVERY_DEST_FILE BLOCK_SIZE FILE_SIZE_BLKS CON_ID------- -------------------------------------------------------------------------------- --------------------- ---------- -------------- ----------/app/oracle/oradata/ORCL/control01.ctl NO 16384 646 0/app/oracle/oradata/ORCL/control02.ctl NO 16384 646 0SQL> host cp /app/oracle/oradata/ORCL/control01.ctl /home/oracle/control01.ctl.bakSQL> host ls -l总用量 10360-rw-r----- 1 oracle oinstall 10600448 1月 12 13:40 control01.ctl.bak-rw-r--r-- 1 oracle oinstall 5849 1月 11 16:09 ctl001.txtdrwxr-xr-x 2 oracle oinstall 6 12月 19 20:19 公共drwxr-xr-x 2 oracle oinstall 6 12月 19 20:19 模板drwxr-xr-x 2 oracle oinstall 6 12月 19 20:19 视频drwxr-xr-x 2 oracle oinstall 6 12月 19 20:19 图片drwxr-xr-x 2 oracle oinstall 6 12月 19 20:19 文档drwxr-xr-x 2 oracle oinstall 6 12月 19 20:19 下载drwxr-xr-x 2 oracle oinstall 6 12月 19 20:19 音乐drwxr-xr-x 2 oracle oinstall 6 12月 19 20:19 桌面[oracle@node1 ~]$ strings control01.ctl.bak
3.4 查看控制文件包含的记录片段
SQL> select type,record_size,records_total,records_used from v$controlfile_record_section;
4、控制文件的多路复用
4.1 查看当前使用的控制文件
SQL> show parameter control_fileNAME TYPE VALUE------------------------------------ ----------- ------------------------------control_file_record_keep_time integer 7control_files string /app/oracle/oradata/ORCL/control01.ctl, /app/oracle/oradata/ORCL/control02.ctl
4.2 修改参数文件
[oracle@node1 controlfile]$ mkdir /app/oracle/controlfileSQL> alter system set control_files = '/app/oracle/oradata/ORCL/control01.ctl','/app/oracle/oradata/ORCL/control02.ctl','/app/oracle/controlfile/contrl03.ctl' scope = spfile sid = '*';System altered
4.3 重启数据库到 nomount 状态,复制所需的控制文件
SQL> startup force nomount;ORACLE instance started.Total System Global Area 8002730448 bytesFixed Size 8915408 bytesVariable Size 1308622848 bytesDatabase Buffers 6677331968 bytesRedo Buffers 7860224 bytesSQL> show parameter control_file;NAME TYPE VALUE------------------------------------ ----------- ------------------------------control_file_record_keep_time integer 7control_files string /app/oracle/oradata/ORCL/control01.ctl, /app/oracle/oradata/ORCL/control02.ctl, /app/oracle/controlfile/contrl03.ctlSQL> host cp /app/oracle/oradata/ORCL/control02.ctl /app/oracle/controlfile/contrl03.ctlSQL> alter database mount;Database altered.SQL> alter database open;Database altered.
5、控制文件丢失的解决办法
5.1 控制文件部分丢失
5.2 模拟控制文件丢失
5.2.1 查看控制文件信息
SQL> show parameter control_file;NAME TYPE VALUE------------------------------------ ----------- ------------------------------control_file_record_keep_time integer 7control_files string /app/oracle/oradata/ORCL/control01.ctl, /app/oracle/oradata/ORCL/control02.ctl, /app/oracle/controlfile/contrl03.ctl
5.2.2 删除控制文件
SQL> host rm -rf /app/oracle/controlfile/contrl03.ctl
5.2.3 重启数据库
SQL> startup force;ORACLE instance started.Total System Global Area 8002730448 bytesFixed Size 8915408 bytesVariable Size 1308622848 bytesDatabase Buffers 6677331968 bytesRedo Buffers 7860224 bytesORA-00205: error in identifying control file, check alert log for more info
5.2.4 查看 alert 文件信息
SQL> SELECT * FROM v$diag_info;INST_ID NAME VALUE CON_ID---------- ---------------------------------------------------------------- -------------------------------------------------------------------------------- ----------1 Diag Enabled TRUE 01 ADR Base /app/oracle 01 ADR Home /app/oracle/diag/rdbms/orcl/orcl 01 Diag Trace /app/oracle/diag/rdbms/orcl/orcl/trace 01 Diag Alert /app/oracle/diag/rdbms/orcl/orcl/alert 01 Diag Incident /app/oracle/diag/rdbms/orcl/orcl/incident 01 Diag Cdump /app/oracle/diag/rdbms/orcl/orcl/cdump 01 Health Monitor /app/oracle/diag/rdbms/orcl/orcl/hm 01 Default Trace File /app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_2861.trc 01 Active Problem Count 4 01 Active Incident Count 75 01 ORACLE_HOME /app/oracle/product/19.3.0/db 012 rows selected[oracle@node1 trace]$ cd /app/oracle/diag/rdbms/orcl/orcl/trace[oracle@node1 trace]$ tail 300 alert_orcl.logtail: 无法打开"300" 读取数据: 没有那个文件或目录==> alert_orcl.log <==ORA-205 signalled during: ALTER DATABASE MOUNT...2023-01-12T14:21:46.156054+08:00Errors in file /app/oracle/diag/rdbms/orcl/orcl/trace/orcl_mz00_2581.trc:ORA-00202: ????: ''/app/oracle/controlfile/contrl03.ctl''ORA-27037: ????????Linux-x86_64 Error: 2: No such file or directoryAdditional information: 7Checker run found 1 new persistent data failures2023-01-12T14:21:48.271581+08:00Using default pga_aggregate_limit of 5088 MB
5.3 控制文件丢失处理
5.3.1 将已经存在的控制文件复制到目的路径并更改为正确的控制文件名称
SQL> host cp /app/oracle/oradata/ORCL/control02.ctl /app/oracle/controlfile/contrl03.ctlSQL> alter database mount;Database altered.SQL> alter database open;Database altered.
5.3.2 修改 control_files参数,将丢失的控制文件去掉
SQL> show parameter control_file;NAME TYPE VALUE------------------------------------ ----------- ------------------------------control_file_record_keep_time integer 7control_files string /app/oracle/oradata/ORCL/control01.ctl, /app/oracle/oradata/ORCL/control02.ctl, /app/oracle/controlfile/contrl03.ctlSQL> alter system set control_files = '/app/oracle/oradata/ORCL/control01.ctl','/app/oracle/oradata/ORCL/control02.ctl' scope = spfile sid = '*';System altered.SQL> startup force nomountORACLE instance started.Total System Global Area 8002730448 bytesFixed Size 8915408 bytesVariable Size 1308622848 bytesDatabase Buffers 6677331968 bytesRedo Buffers 7860224 bytesSQL> alter database mount;Database altered.SQL> alter database open;Database altered.
6、控制文件版本不一致
6.1 模拟控制文件版本不一致问题:
6.1.1 查看数据库控制文件信息
SQL> show parameter control_fileNAME TYPE VALUE------------------------------------ ----------- ------------------------------control_file_record_keep_time integer 7control_files string /app/oracle/oradata/ORCL/control01.ctl, /app/oracle/oradata/ORCL/control02.ctl
6.1.2 修改参数文件,只保留第一个控制文件
SQL> alter system set control_files = '/app/oracle/oradata/ORCL/control01.ctl','/app/oracle/oradata/ORCL/control02.ctl' scope = spfile sid = '*';System altered.SQL> alter system set control_files = '/app/oracle/oradata/ORCL/control01.ctl' scope=spfile sid = '*';System altered.SQL> startup forceORACLE instance started.Total System Global Area 8002730448 bytesFixed Size 8915408 bytesVariable Size 1308622848 bytesDatabase Buffers 6677331968 bytesRedo Buffers 7860224 bytesDatabase mounted.Database opened.
6.1.3 创建一张表
SQL> create table hr.STUDENT_INFO_01 as select * from hr.STUDENT_INFO;Table created.
6.2 修改参数文件,添加两个控制文件
SQL> alter system set control_files = '/app/oracle/oradata/ORCL/control01.ctl','/app/oracle/oradata/ORCL/control02.ctl' scope=spfile sid = '*';System altered.
6.3 重启数据库,提示版本错误
SQL> startup forceORACLE instance started.Total System Global Area 8002730448 bytesFixed Size 8915408 bytesVariable Size 1308622848 bytesDatabase Buffers 6677331968 bytesRedo Buffers 7860224 bytesORA-00214: control file '/app/oracle/oradata/ORCL/control01.ctl' version 36188inconsistent with file '/app/oracle/oradata/ORCL/control02.ctl' version 36173
6.4 解决方法:利用最新版本的控制文件替换旧的控制文件
SQL> host cp /app/oracle/oradata/ORCL/control01.ctl /app/oracle/oradata/ORCL/control02.ctlSQL> startup forceORACLE instance started.Total System Global Area 8002730448 bytesFixed Size 8915408 bytesVariable Size 1308622848 bytesDatabase Buffers 6677331968 bytesRedo Buffers 7860224 bytesDatabase mounted.Database opened.
7、控制文件的备份
7.1 使用 alter database backup controlfile 备份
7.1.1 语法
alter database backup controlfile to '<dir>';
7.1.2 备份控制文件
7.1.3 查看控制文件的备份
SQL> host ls -l /home/oracle总用量 20712-rw-r----- 1 oracle oinstall 10600448 1月 12 13:40 control01.ctl.bak-rw-r----- 1 oracle oinstall 10600448 1月 12 15:13 controlfile.bak-rw-r--r-- 1 oracle oinstall 5849 1月 11 16:09 ctl001.txtdrwxr-xr-x 2 oracle oinstall 6 12月 19 20:19 公共drwxr-xr-x 2 oracle oinstall 6 12月 19 20:19 模板drwxr-xr-x 2 oracle oinstall 6 12月 19 20:19 视频drwxr-xr-x 2 oracle oinstall 6 12月 19 20:19 图片drwxr-xr-x 2 oracle oinstall 6 12月 19 20:19 文档drwxr-xr-x 2 oracle oinstall 6 12月 19 20:19 下载drwxr-xr-x 2 oracle oinstall 6 12月 19 20:19 音乐drwxr-xr-x 2 oracle oinstall 6 12月 19 20:19 桌面SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SQL> exitDisconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - ProductionVersion 19.3.0.0.0
7.1.4 恢复控制文件
[oracle@node1 ~]$ rm -rf /app/oracle/oradata/ORCL/control01.ctl[oracle@node1 ~]$ rm -rf /app/oracle/oradata/ORCL/control02.ctl[oracle@node1 ~]$ cp /home/oracle/controlfile.bak /app/oracle/oradata/ORCL/control01.ctl[oracle@node1 ~]$ cp /home/oracle/controlfile.bak /app/oracle/oradata/ORCL/control02.ctl[oracle@node1 ~]$ sasSQL> startupORACLE instance started.Total System Global Area 8002730448 bytesFixed Size 8915408 bytesVariable Size 1308622848 bytesDatabase Buffers 6677331968 bytesRedo Buffers 7860224 bytesDatabase mounted.ORA-01589: must use RESETLOGS or NORESETLOGS option for database openSQL> recover database using backup controlfile;ORA-00279: change 7636324 generated at 01/12/2023 15:37:27 needed for thread 1ORA-00289: suggestion : /app/archive/orcl_62725153_0000000001_1_1125934647.dbfORA-00280: change 7636324 for thread 1 is in sequence #1Specify log: {<RET>=suggested | filename | AUTO | CANCEL}/app/oracle/oradata/ORCL/redo01.logLog applied.Media recovery complete.SQL> alter database open resetlogs;Database altered.
7.2 使用 rman 备份(推荐)
7.2.1 查看数据库的归档状态
SQL> archive log listDatabase log mode Archive ModeAutomatic archival EnabledArchive destination /app/archiveOldest online log sequence 49Next log sequence to archive 51Current log sequence 51
7.2.2 备份控制文件
7.2.3 查看控制文件的备份信息
RMAN> list backup of controlfile;
7.2.4 使用 rman 恢复控制文件
SQL> show parameter control_fileNAME TYPE VALUE------------------------------------ ----------- ------------------------------control_file_record_keep_time integer 7control_files string /app/oracle/oradata/ORCL/control01.ctl, /app/oracle/oradata/ORCL/control02.ctlSQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.[oracle@node1 ~]$ rm -rf /app/oracle/oradata/ORCL/control01.ctl[oracle@node1 ~]$ rm -rf /app/oracle/oradata/ORCL/control02.ctl
7.2.5 启动数据库,出现错误
SQL> startupORACLE instance started.Total System Global Area 8002730448 bytesFixed Size 8915408 bytesVariable Size 1308622848 bytesDatabase Buffers 6677331968 bytesRedo Buffers 7860224 bytesORA-00205: error in identifying control file, check alert log for more info
7.2.6 数据库启动到 nomount 状态
SQL> select status from v$instance;STATUSSTARTED
7.2.7 使用 RMAN 还原控制文件
RMAN> restore controlfile from '/app/rmanbak/control_2023_01_12.bak';Starting restore at 12-JAN-23using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=1709 device type=DISKchannel ORA_DISK_1: restoring control filechannel ORA_DISK_1: restore complete, elapsed time: 00:00:01output file name=/app/oracle/oradata/ORCL/control01.ctloutput file name=/app/oracle/oradata/ORCL/control02.ctlFinished restore at 12-JAN-23
7.2.8 启动数据库到 mount 状态
RMAN> alter database mount;released channel: ORA_DISK_1Statement processed
7.2.9 恢复数据库
RMAN> recover database;Starting recover at 12-JAN-23allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=1709 device type=DISKstarting media recoveryarchived log for thread 1 with sequence 51 is already on disk as file /app/oracle/oradata/ORCL/redo03.logarchived log file name=/app/oracle/oradata/ORCL/redo03.log thread=1 sequence=51media recovery complete, elapsed time: 00:00:01Finished recover at 12-JAN-23
7.2.10 打开数据库
RMAN> alter database open resetlogs;Statement processed
7.3 生成创建控制文件的脚本
7.3.1 语法
alter database backup controlfile to trace as '<dir>'
7.3.2 生成创建控制文件的脚本
7.3.3 查看文件 /home/oracle/ctl002.txt 的内容:
[oracle@node1 ~]$ cat ctl002.txt-- The following are current System-scope REDO Log Archival related-- parameters and can be included in the database initialization file.---- LOG_ARCHIVE_DEST=''-- LOG_ARCHIVE_DUPLEX_DEST=''---- LOG_ARCHIVE_FORMAT=orcl_%d_%S_%t_%r.dbf---- DB_UNIQUE_NAME="orcl"---- LOG_ARCHIVE_CONFIG='SEND, RECEIVE, NODG_CONFIG'-- LOG_ARCHIVE_MAX_PROCESSES=4-- STANDBY_FILE_MANAGEMENT=MANUAL-- FAL_CLIENT=''-- FAL_SERVER=''---- LOG_ARCHIVE_DEST_1='LOCATION=/app/archive'-- LOG_ARCHIVE_DEST_1='OPTIONAL REOPEN=300 NODELAY'-- LOG_ARCHIVE_DEST_1='ARCH NOAFFIRM NOVERIFY SYNC'-- LOG_ARCHIVE_DEST_1='REGISTER'-- LOG_ARCHIVE_DEST_1='NOALTERNATE'-- LOG_ARCHIVE_DEST_1='NODEPENDENCY'-- LOG_ARCHIVE_DEST_1='NOMAX_FAILURE NOQUOTA_SIZE NOQUOTA_USED NODB_UNIQUE_NAME'-- LOG_ARCHIVE_DEST_1='VALID_FOR=(PRIMARY_ROLE,ONLINE_LOGFILES)'-- LOG_ARCHIVE_DEST_STATE_1=ENABLE---- Below are two sets of SQL statements, each of which creates a new-- control file and uses it to open the database. The first set opens-- the database with the NORESETLOGS option and should be used only if-- the current versions of all online logs are available. The second-- set opens the database with the RESETLOGS option and should be used-- if online logs are unavailable.-- The appropriate set of statements can be copied from the trace into-- a script file, edited as necessary, and executed when there is a-- need to re-create the control file.---- Set #1. NORESETLOGS case---- The following commands will create a new control file and use it-- to open the database.-- Data used by Recovery Manager will be lost.-- Additional logs may be required for media recovery of offline-- Use this only if the current versions of all online logs are-- available.-- After mounting the created controlfile, the following SQL-- statement will place the database in the appropriate-- protection mode:-- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCESTARTUP NOMOUNTCREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS ARCHIVELOGMAXLOGFILES 16MAXLOGMEMBERS 3MAXDATAFILES 100MAXINSTANCES 8MAXLOGHISTORY 292LOGFILEGROUP 1 '/app/oracle/oradata/ORCL/redo01.log' SIZE 200M BLOCKSIZE 512,GROUP 2 '/app/oracle/oradata/ORCL/redo02.log' SIZE 200M BLOCKSIZE 512,GROUP 3 '/app/oracle/oradata/ORCL/redo03.log' SIZE 200M BLOCKSIZE 512-- STANDBY LOGFILEDATAFILE'/app/oracle/oradata/ORCL/system01.dbf','/app/oracle/oradata/ORCL/test01.DBF','/app/oracle/oradata/ORCL/sysaux01.dbf','/app/oracle/oradata/ORCL/undotbs01.dbf','/app/oracle/oradata/ORCL/wms01.DBF','/app/oracle/oradata/ORCL/users01.dbf'CHARACTER SET ZHS16GBK;-- Commands to re-create incarnation table-- Below log names MUST be changed to existing filenames on-- disk. Any one log file from each branch can be used to-- re-create incarnation records.-- ALTER DATABASE REGISTER LOGFILE '/app/archive/orcl_62725153_0000000001_1_1005785759.dbf';-- ALTER DATABASE REGISTER LOGFILE '/app/archive/orcl_62725153_0000000001_1_1123878365.dbf';-- Recovery is required if any of the datafiles are restored backups,-- or if the last shutdown was not normal or immediate.RECOVER DATABASE-- All logs need archiving and a log switch is needed.ALTER SYSTEM ARCHIVE LOG ALL;-- Database can now be opened normally.ALTER DATABASE OPEN;-- Commands to add tempfiles to temporary tablespaces.-- Online tempfiles have complete space information.-- Other tempfiles may require adjustment.ALTER TABLESPACE TEMP ADD TEMPFILE '/app/oracle/oradata/ORCL/temp01.dbf'SIZE 33554432 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;-- End of tempfile additions.---- Set #2. RESETLOGS case---- The following commands will create a new control file and use it-- to open the database.-- Data used by Recovery Manager will be lost.-- The contents of online logs will be lost and all backups will-- be invalidated. Use this only if online logs are damaged.-- After mounting the created controlfile, the following SQL-- statement will place the database in the appropriate-- protection mode:-- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCESTARTUP NOMOUNTCREATE CONTROLFILE REUSE DATABASE "ORCL" RESETLOGS ARCHIVELOGMAXLOGFILES 16MAXLOGMEMBERS 3MAXDATAFILES 100MAXINSTANCES 8MAXLOGHISTORY 292LOGFILEGROUP 1 '/app/oracle/oradata/ORCL/redo01.log' SIZE 200M BLOCKSIZE 512,GROUP 2 '/app/oracle/oradata/ORCL/redo02.log' SIZE 200M BLOCKSIZE 512,GROUP 3 '/app/oracle/oradata/ORCL/redo03.log' SIZE 200M BLOCKSIZE 512-- STANDBY LOGFILEDATAFILE'/app/oracle/oradata/ORCL/system01.dbf','/app/oracle/oradata/ORCL/test01.DBF','/app/oracle/oradata/ORCL/sysaux01.dbf','/app/oracle/oradata/ORCL/undotbs01.dbf','/app/oracle/oradata/ORCL/wms01.DBF','/app/oracle/oradata/ORCL/users01.dbf'CHARACTER SET ZHS16GBK;-- Commands to re-create incarnation table-- Below log names MUST be changed to existing filenames on-- disk. Any one log file from each branch can be used to-- re-create incarnation records.-- ALTER DATABASE REGISTER LOGFILE '/app/archive/orcl_62725153_0000000001_1_1005785759.dbf';-- ALTER DATABASE REGISTER LOGFILE '/app/archive/orcl_62725153_0000000001_1_1123878365.dbf';-- Recovery is required if any of the datafiles are restored backups,-- or if the last shutdown was not normal or immediate.RECOVER DATABASE USING BACKUP CONTROLFILE-- Database can now be opened zeroing the online logs.ALTER DATABASE OPEN RESETLOGS;-- Commands to add tempfiles to temporary tablespaces.-- Online tempfiles have complete space information.-- Other tempfiles may require adjustment.ALTER TABLESPACE TEMP ADD TEMPFILE '/app/oracle/oradata/ORCL/temp01.dbf'SIZE 33554432 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;-- End of tempfile additions.--
7.3.4 日志可用的情况下重建控制文件
SQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.[oracle@node1 ~]$ rm -rf /app/oracle/oradata/ORCL/control01.ctl[oracle@node1 ~]$ rm -rf /app/oracle/oradata/ORCL/control02.ctlSQL> startup nomountORACLE instance started.Total System Global Area 8002730448 bytesFixed Size 8915408 bytesVariable Size 1308622848 bytesDatabase Buffers 6677331968 bytesRedo Buffers 7860224 bytesSQL> CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS ARCHIVELOGMAXLOGFILES 16MAXLOGMEMBERS 3MAXDATAFILES 100MAXINSTANCES 8MAXLOGHISTORY 292LOGFILEGROUP 1 '/app/oracle/oradata/ORCL/redo01.log' SIZE 200M BLOCKSIZE 512,GROUP 2 '/app/oracle/oradata/ORCL/redo02.log' SIZE 200M BLOCKSIZE 512,GROUP 3 '/app/oracle/oradata/ORCL/redo03.log' SIZE 200M BLOCKSIZE 512-- STANDBY LOGFILEDATAFILE'/app/oracle/oradata/ORCL/system01.dbf','/app/oracle/oradata/ORCL/test01.DBF','/app/oracle/oradata/ORCL/sysaux01.dbf','/app/oracle/oradata/ORCL/undotbs01.dbf','/app/oracle/oradata/ORCL/wms01.DBF','/app/oracle/oradata/ORCL/users01.dbf'CHARACTER SET ZHS16GBK20 ;SQL> ALTER DATABASE OPEN;Database altered.SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '/app/oracle/oradata/ORCL/temp01.dbf'SIZE 33554432 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;Tablespace altered.
7.3.5 日志不可用的情况下重建控制文件
SQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.[oracle@node1 ~]$ rm -rf /app/oracle/oradata/ORCL/control01.ctl[oracle@node1 ~]$ rm -rf /app/oracle/oradata/ORCL/control02.ctlSQL> startup nomountORACLE instance started.Total System Global Area 8002730448 bytesFixed Size 8915408 bytesVariable Size 1308622848 bytesDatabase Buffers 6677331968 bytesRedo Buffers 7860224 bytesSQL> CREATE CONTROLFILE REUSE DATABASE "ORCL" RESETLOGS ARCHIVELOGMAXLOGFILES 16MAXLOGMEMBERS 3MAXDATAFILES 100MAXINSTANCES 8MAXLOGHISTORY 292LOGFILEGROUP 1 '/app/oracle/oradata/ORCL/redo01.log' SIZE 200M BLOCKSIZE 512,GROUP 2 '/app/oracle/oradata/ORCL/redo02.log' SIZE 200M BLOCKSIZE 512,GROUP 3 '/app/oracle/oradata/ORCL/redo03.log' SIZE 200M BLOCKSIZE 512-- STANDBY LOGFILEDATAFILE'/app/oracle/oradata/ORCL/system01.dbf','/app/oracle/oradata/ORCL/test01.DBF','/app/oracle/oradata/ORCL/sysaux01.dbf','/app/oracle/oradata/ORCL/undotbs01.dbf','/app/oracle/oradata/ORCL/wms01.DBF','/app/oracle/oradata/ORCL/users01.dbf'CHARACTER SET ZHS16GBK20 ;Control file created.SQL> RECOVER DATABASE USING BACKUP CONTROLFILEORA-00279: change 7647399 generated at 01/12/2023 19:00:06 needed for thread 1ORA-00289: suggestion : /app/archive/orcl_62725153_0000000002_1_1125935795.dbfORA-00280: change 7647399 for thread 1 is in sequence #2Specify log: {<RET>=suggested | filename | AUTO | CANCEL}/app/oracle/oradata/ORCL/redo01.logORA-00310: ���������������� 1; �������� 2 ORA-00334: ��������:'/app/oracle/oradata/ORCL/redo01.log'SQL> RECOVER DATABASE USING BACKUP CONTROLFILEORA-00279: change 7647399 generated at 01/12/2023 19:00:06 needed for thread 1ORA-00289: suggestion : /app/archive/orcl_62725153_0000000002_1_1125935795.dbfORA-00280: change 7647399 for thread 1 is in sequence #2Specify log: {<RET>=suggested | filename | AUTO | CANCEL}/app/oracle/oradata/ORCL/redo02.logLog applied.Media recovery complete.}SQL> ALTER DATABASE OPEN RESETLOGS;Database altered.SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '/app/oracle/oradata/ORCL/temp01.dbf'SIZE 33554432 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;Tablespace altered.

版权声明:本文内容始发于CSDN>作者:multis,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。始发链接:https://blog.csdn.net/liang921119/article/details/128664993在此特别鸣谢原作者的创作。此篇文章的所有版权归原作者所有,商业转载建议请联系原作者,非商业转载请注明出处。
文章转载自巴韭特锁螺丝,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




