当前位置:网站首页>Oracle control file loss recovery archive mode method
Oracle control file loss recovery archive mode method
2022-07-07 15:18:00 【1024 questions】
One 、 View the path and content of the control file
Two 、 Simulate the loss of control files :
1、 Not all control files are missing
2、 All lost , The control file exists for backup
Rebuild control files from backup files
adopt rman Restore control files
3、 All lost , No backup
3、 ... and 、 Suggest
One 、 View the path and content of the control fileSQL> show parameter control_filesNAME TYPE VALUE------------------------------------ ----------- ------------------------------control_files string /oradata/orcl/control01.ctl, / u01/app/oracle/fast_recovery_a rea/orcl/control02.ctl[[email protected]:/oradata/orcl]$ ll /oradata/orcl/control01.ctl -rw-r----- 1 oracle oinstall 9748480 Apr 15 10:01 /oradata/orcl/control01.ctl[[email protected]:/oradata/orcl]$ ll /u01/app/oracle/fast_recovery_area/orcl/control02.ctl-rw-r----- 1 oracle oinstall 9748480 Apr 15 10:03 /u01/app/oracle/fast_recovery_area/orcl/control02.ctl-- Make sure the archive is turned on SQL> archive log listDatabase log mode No Archive ModeAutomatic archival DisabledArchive destination /archivelogOldest online log sequence 10Current log sequence 12SQL> select distinct dbms_rowid.rowid_block_number(rowid) from props$;DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)------------------------------------ 801-- Control file content -- Generate control file SQL> alter database backup controlfile to trace as '/home/oracle/ctlbak.ctl';Database altered.-- see trace Content [[email protected]:/home/oracle]$ cat ctlbak.ctl -- 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=%t_%s_%r.dbf---- DB_UNIQUE_NAME="orcl"---- LOG_ARCHIVE_CONFIG='SEND, RECEIVE, NODG_CONFIG'-- LOG_ARCHIVE_MAX_PROCESSES=4-- STANDBY_FILE_MANAGEMENT=MANUAL-- STANDBY_ARCHIVE_DEST=?/dbs/arch-- FAL_CLIENT=''-- FAL_SERVER=''---- LOG_ARCHIVE_DEST_1='LOCATION=/archivelog'-- LOG_ARCHIVE_DEST_1='OPTIONAL REOPEN=300 NODELAY'-- LOG_ARCHIVE_DEST_1='ARCH NOAFFIRM NOEXPEDITE NOVERIFY SYNC'-- LOG_ARCHIVE_DEST_1='REGISTER NOALTERNATE 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 NOARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292LOGFILE GROUP 1 '/oradata/orcl/redo01.log' SIZE 120M BLOCKSIZE 512, GROUP 2 '/oradata/orcl/redo02.log' SIZE 120M BLOCKSIZE 512, GROUP 3 '/oradata/orcl/redo03.log' SIZE 120M BLOCKSIZE 512-- STANDBY LOGFILEDATAFILE '/oradata/orcl/system01.dbf', '/oradata/orcl/sysaux01.dbf', '/oradata/orcl/undotbs01.dbf', '/oradata/orcl/users01.dbf', '/oradata/orcl/example01.dbf'CHARACTER SET AL32UTF8;-- 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 '/archivelog/1_1_1069941729.dbf';-- Recovery is required if any of the datafiles are restored backups,-- or if the last shutdown was not normal or immediate.RECOVER DATABASE-- 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 '/oradata/orcl/temp01.dbf' SIZE 30408704 REUSE AUTOEXTEND OFF;-- 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 NOARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292LOGFILE GROUP 1 '/oradata/orcl/redo01.log' SIZE 120M BLOCKSIZE 512, GROUP 2 '/oradata/orcl/redo02.log' SIZE 120M BLOCKSIZE 512, GROUP 3 '/oradata/orcl/redo03.log' SIZE 120M BLOCKSIZE 512-- STANDBY LOGFILEDATAFILE '/oradata/orcl/system01.dbf', '/oradata/orcl/sysaux01.dbf', '/oradata/orcl/undotbs01.dbf', '/oradata/orcl/users01.dbf', '/oradata/orcl/example01.dbf'CHARACTER SET AL32UTF8;-- 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 '/archivelog/1_1_1069941729.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 '/oradata/orcl/temp01.dbf' SIZE 30408704 REUSE AUTOEXTEND OFF;-- End of tempfile additions.--
There are two control files in the current database , Located in the data file path and the fast flashback area path respectively .
Two 、 Simulate the loss of control files :1、 Not all control files are missingDelete the control file in the flash area , Force database shutdown .
[[email protected]:/oradata/orcl]$ rm -rf /u01/app/oracle/fast_recovery_area/orcl/control02.ctl [[email protected]:/oradata/orcl]$ ll /u01/app/oracle/fast_recovery_area/orcl/control02.ctl ls: cannot access /u01/app/oracle/fast_recovery_area/orcl/control02.ctl: No such file or directory-- Open a new session, At this time, the database is in the error reporting state , No matter what operation, an error will be reported , At this point, the database is forced to be closed SQL> select open_mode from v$database;select open_mode from v$database *ERROR at line 1:ORA-00210: cannot open the specified control fileORA-00202: control file:'/u01/app/oracle/fast_recovery_area/orcl/control02.ctl'ORA-27041: unable to open fileLinux-x86_64 Error: 2: No such file or directoryAdditional information: 3SQL> shutdown abortORACLE instance shut down.SQL>
Copy a control file from the data file path to the flash area , Try to close again and check whether there is an error .
-- Copy control file [[email protected]:/u01/app/oracle/fast_recovery_area/orcl]$ cp /oradata/orcl/control01.ctl control02.ctl[[email protected]:/u01/app/oracle/fast_recovery_area/orcl]$ lscontrol02.ctl-- Open database SQL> startupORACLE instance started.Total System Global Area 1603411968 bytesFixed Size 2253664 bytesVariable Size 452988064 bytesDatabase Buffers 1140850688 bytesRedo Buffers 7319552 bytesDatabase mounted.Database opened.
2、 All lost , The control file exists for backup There are two ways :
1、 Rebuild control files from backed up files
2、 adopt rman Restore control files , Need to pass through resetlogs How to open the database
Rebuild control files from backup files-- Get the script to create the control file by backing up the control file CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS NOARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292LOGFILE GROUP 1 '/oradata/orcl/redo01.log' SIZE 120M BLOCKSIZE 512, GROUP 2 '/oradata/orcl/redo02.log' SIZE 120M BLOCKSIZE 512, GROUP 3 '/oradata/orcl/redo03.log' SIZE 120M BLOCKSIZE 512-- STANDBY LOGFILEDATAFILE '/oradata/orcl/system01.dbf', '/oradata/orcl/sysaux01.dbf', '/oradata/orcl/undotbs01.dbf', '/oradata/orcl/users01.dbf', '/oradata/orcl/example01.dbf'CHARACTER SET AL32UTF8;-- Start recovery SQL> startup nomountORACLE instance started.Total System Global Area 1603411968 bytesFixed Size 2253664 bytesVariable Size 452988064 bytesDatabase Buffers 1140850688 bytesRedo Buffers 7319552 bytesSQL> CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS NOARCHIVELOG 2 MAXLOGFILES 16 3 MAXLOGMEMBERS 3 4 MAXDATAFILES 100 5 MAXINSTANCES 8 6 MAXLOGHISTORY 292 7 LOGFILE 8 GROUP 1 '/oradata/orcl/redo01.log' SIZE 120M BLOCKSIZE 512, 9 GROUP 2 '/oradata/orcl/redo02.log' SIZE 120M BLOCKSIZE 512, 10 GROUP 3 '/oradata/orcl/redo03.log' SIZE 120M BLOCKSIZE 512 11 -- STANDBY LOGFILE 12 DATAFILE 13 '/oradata/orcl/system01.dbf', 14 '/oradata/orcl/sysaux01.dbf', 15 '/oradata/orcl/undotbs01.dbf', 16 '/oradata/orcl/users01.dbf', 17 '/oradata/orcl/example01.dbf' 18 CHARACTER SET AL32UTF8;Control file created.SQL> recover database;Media recovery complete.SQL> alter database open;Database altered.SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '/oradata/orcl/temp01.dbf';Tablespace altered.SQL> select open_mode from v$database;OPEN_MODE--------------------READ WRITE
Successfully recovered control file .
adopt rman Restore control filesrman Backup control files
RMAN> backup current controlfile format '/home/oracle/ctrl.ora';Starting backup at 15-APR-21allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=29 device type=DISKchannel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setincluding current control file in backup setchannel ORA_DISK_1: starting piece 1 at 15-APR-21channel ORA_DISK_1: finished piece 1 at 15-APR-21piece handle=/home/oracle/ctrl.ora tag=TAG20210415T104457 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:01Finished backup at 15-APR-21RMAN> list backup of controlfile;List of Backup Sets===================BS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ ---------------1 Full 9.64M DISK 00:00:01 15-APR-21 BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20210415T104457 Piece Name: /home/oracle/ctrl.ora Control File Included: Ckp SCN: 1219869 Ckp time: 15-APR-21
rm Delete all control files , Try adding a data file , Force database shutdown , Try opening to mount state .
[[email protected]:/u01/app/oracle/fast_recovery_area/orcl]$ rm control02.ctl [[email protected]:/u01/app/oracle/fast_recovery_area/orcl]$ rm /oradata/orcl/control01.ctl [[email protected]:/u01/app/oracle/fast_recovery_area/orcl]$ lltotal 0[[email protected]:/u01/app/oracle/fast_recovery_area/orcl]$ ll /oradata/orcl/control01.ctlls: cannot access /oradata/orcl/control01.ctl: No such file or directorySQL> alter tablespace USERS add datafile;alter tablespace USERS add datafile*ERROR at line 1:ORA-00603: ORACLE server session terminated by fatal errorORA-00210: cannot open the specified control fileORA-00202: control file: '/oradata/orcl/control01.ctl'ORA-27041: unable to open fileLinux-x86_64 Error: 2: No such file or directoryAdditional information: 3ORA-00210: cannot open the specified control fileORA-00202: control file: '/oradata/orcl/control01.ctl'ORA-27041: unable to open fileLinux-x86_64 Error: 2: No such file or directoryAdditional information: 3Process ID: 2333Session ID: 1 Serial number: 9SQL> shutdown abort;ORACLE instance shut down.SQL> startup mountORACLE instance started.Total System Global Area 1603411968 bytesFixed Size 2253664 bytesVariable Size 452988064 bytesDatabase Buffers 1140850688 bytesRedo Buffers 7319552 bytesORA-00205: error in identifying control file, check alert log for more info
Open the database to nomount state ,rman Restore control files , Recover database
-- Open to nomount state SQL> startup nomountORACLE instance started.Total System Global Area 1603411968 bytesFixed Size 2253664 bytesVariable Size 452988064 bytesDatabase Buffers 1140850688 bytesRedo Buffers 7319552 bytes--rman Restore control files RMAN> restore controlfile from '/home/oracle/ctrl.ora';Starting restore at 15-APR-21using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=20 device type=DISKchannel ORA_DISK_1: restoring control filechannel ORA_DISK_1: restore complete, elapsed time: 00:00:01output file name=/oradata/orcl/control01.ctloutput file name=/u01/app/oracle/fast_recovery_area/orcl/control02.ctlFinished restore at 15-APR-21-- Open the database to mount state SQL> alter database mount;Database altered.-- Recover database RMAN> recover database;Starting recover at 15-APR-21released channel: ORA_DISK_1Starting implicit crosscheck backup at 15-APR-21allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=20 device type=DISKFinished implicit crosscheck backup at 15-APR-21Starting implicit crosscheck copy at 15-APR-21using channel ORA_DISK_1Finished implicit crosscheck copy at 15-APR-21searching for all files in the recovery areacataloging files...no files catalogedusing channel ORA_DISK_1RMAN-06900: WARNING: unable to generate V$RMAN_STATUS or V$RMAN_OUTPUT rowRMAN-06901: WARNING: disabling update of the V$RMAN_STATUS and V$RMAN_OUTPUT rowsORACLE error from target database: ORA-19922: there is no parent row with id 0 and level 1starting media recoveryarchived log for thread 1 with sequence 12 is already on disk as file /oradata/orcl/redo03.logarchived log file name=/oradata/orcl/redo03.log thread=1 sequence=12media recovery complete, elapsed time: 00:00:00Finished recover at 15-APR-21
adopt resetlogs How to open the database
SQL> alter database open resetlogs;Database altered.
3、 All lost , No backup Delete all control files , And there is no backup control file
SQL> select open_mode from v$database;select open_mode from v$database *ERROR at line 1:ORA-00210: cannot open the specified control fileORA-00202: control file: '/oradata/orcl/control01.ctl'ORA-27041: unable to open fileLinux-x86_64 Error: 2: No such file or directoryAdditional information: 3SQL> shutdown abortORACLE instance shut down.
Create control files manually
-- adopt spfile perhaps pfile File access information --1.db_name[[email protected]:/home/oracle]$ grep "db_name" pfile.ora *.db_name='orcl'--2. Character set ( adopt dd if see system01 Data files )dd if=system01.dbf of=lucifer bs=8192 skip=801--3. Get data file and log file names [[email protected]:/oradata/orcl]$ lltotal 2083264-rw-r-----. 1 oracle oinstall 328343552 Apr 15 15:14 example01.dbf-rw-r-----. 1 oracle oinstall 125829632 Apr 15 15:14 redo01.log-rw-r-----. 1 oracle oinstall 125829632 Apr 15 15:14 redo02.log-rw-r-----. 1 oracle oinstall 125829632 Apr 15 15:17 redo03.log-rw-r-----. 1 oracle oinstall 545267712 Apr 15 15:14 sysaux01.dbf-rw-r-----. 1 oracle oinstall 786440192 Apr 15 15:14 system01.dbf-rw-r-----. 1 oracle oinstall 30416896 Apr 15 15:14 temp01.dbf-rw-r-----. 1 oracle oinstall 89137152 Apr 15 15:14 undotbs01.dbf-rw-r-----. 1 oracle oinstall 5251072 Apr 15 15:14 users01.dbf-- Rebuild control file ( There is no need to add temporary files here , After opening the database, you need to reuse)-- Open the database to nomountSTARTUP NOMOUNT;-- Create control file CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS NOARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292LOGFILE GROUP 1 '/oradata/orcl/redo01.log' SIZE 120M BLOCKSIZE 512, GROUP 2 '/oradata/orcl/redo02.log' SIZE 120M BLOCKSIZE 512, GROUP 3 '/oradata/orcl/redo03.log' SIZE 120M BLOCKSIZE 512-- STANDBY LOGFILEDATAFILE '/oradata/orcl/system01.dbf', '/oradata/orcl/sysaux01.dbf', '/oradata/orcl/undotbs01.dbf', '/oradata/orcl/users01.dbf', '/oradata/orcl/example01.dbf'CHARACTER SET AL32UTF8;-- Recover database RECOVER DATABASE;-- Execution process SQL> CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS NOARCHIVELOG 2 MAXLOGFILES 16 3 MAXLOGMEMBERS 3 4 MAXDATAFILES 100 5 MAXINSTANCES 8 6 MAXLOGHISTORY 292 7 LOGFILE 8 GROUP 1 '/oradata/orcl/redo01.log' SIZE 120M BLOCKSIZE 512, 9 GROUP 2 '/oradata/orcl/redo02.log' SIZE 120M BLOCKSIZE 512, 10 GROUP 3 '/oradata/orcl/redo03.log' SIZE 120M BLOCKSIZE 512 11 -- STANDBY LOGFILE 12 DATAFILE 13 '/oradata/orcl/system01.dbf', 14 '/oradata/orcl/sysaux01.dbf', 15 '/oradata/orcl/undotbs01.dbf', 16 '/oradata/orcl/users01.dbf', 17 '/oradata/orcl/example01.dbf' 18 CHARACTER SET AL32UTF8 19 ;Control file created.SQL> RECOVER DATABASE;Media recovery complete.
Open database , Successfully recovered control file
SQL> ALTER DATABASE OPEN;Database altered.-- Here, you need to reuse the temporary files SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '/oradata/orcl/temp01.dbf' REUSE;Tablespace altered.
3、 ... and 、 Suggest 1、 Create multiple control files , It is recommended to store them in multiple folders , Prevent files from being deleted by mistake or damaged in storage .
2、 Open archive mode .
3、 Save the control file generation script of the current library ( Include important information :dbname, Character set , File path ).
4、 Back up database files regularly , To prevent loss , It is recommended to save the backup on the source side .
That's all Oracle Control the details of file loss recovery Archive Mode , More about Oracle Please pay attention to other relevant articles on software development network for information about the archive mode of controlling file recovery !
边栏推荐
- Yyds dry goods inventory # solve the real problem of famous enterprises: cross line
- Bits and Information & integer notes
- [data mining] visual pattern mining: hog feature + cosine similarity /k-means clustering
- Ctfshow, information collection: web5
- IDA pro逆向工具寻找socket server的IP和port
- 8大模块、40个思维模型,打破思维桎梏,满足你工作不同阶段、场景的思维需求,赶紧收藏慢慢学
- CTFshow,信息搜集:web6
- JSON parsing instance (QT including source code)
- 知否|两大风控最重要指标与客群好坏的关系分析
- MySQL installation configuration 2021 in Windows Environment
猜你喜欢
【深度学习】语义分割实验:Unet网络/MSRC2数据集
Cocoscreator operates spine for animation fusion
Ctfshow, information collection: web4
[deep learning] image hyperspectral experiment: srcnn/fsrcnn
Why do we use UTF-8 encoding?
【搞船日记】【Shapr3D的STL格式转Gcode】
有一头母牛,它每年年初生一头小母牛。每头小母牛从第四个年头开始,每年年初也生一头小母牛。请编程实现在第n年的时候,共有多少头母牛?
How bad can a programmer be? Nima, they are all talents
时空可变形卷积用于压缩视频质量增强(STDF)
【目标检测】YOLOv5跑通VOC2007数据集
随机推荐
Delete a whole page in word
MySQL bit type resolution
CTFshow,信息搜集:web9
Zhiting doesn't use home assistant to connect Xiaomi smart home to homekit
2. 堆排序『较难理解的排序』
[deep learning] semantic segmentation experiment: UNET network /msrc2 dataset
Deformable convolutional dense network for enhancing compressed video quality
Protection strategy of server area based on Firewall
CTFshow,信息搜集:web7
【目标检测】YOLOv5跑通VOC2007数据集
Xiaomi's path of chip self-development
Window环境下配置Mongodb数据库
Niuke real problem programming - day15
众昂矿业:萤石继续引领新能源市场增长
With 8 modules and 40 thinking models, you can break the shackles of thinking and meet the thinking needs of different stages and scenes of your work. Collect it quickly and learn it slowly
居然从408改考自命题!211华北电力大学(北京)
Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System
[data mining] visual pattern mining: hog feature + cosine similarity /k-means clustering
Excerpted words
Ctfshow, information collection: web4