Oracle lost all the redo log groups 

  1. Oracle did not open the archive, close the database consistency
  2. Oracle did not open the archive, non-uniform close the database
  3. Oracle open archive, close the database consistency
  4. Oracle Open Archive, a non-closed database consistency

A: Oracle did not open the archive, close the database consistency

I have done experiments in the process have a strange situation, I first redo files are deleted from the operating system level, but normal database to create a table, insert the data, I understand that when you commit, it will trigger the process from redo lgwr rinse in new redo log buffer to redo file, but redo the file has been deleted, it will error, but he was not given:

[root@testdb59 /data/u01/app/oracle/oradata/stdb59]# ll

total 13697796

-rw-r----- 1 oracle oinstall 144916480 Apr 5 22:30 control01.ctl

-rw-r----- 1 oracle oinstall 2147491840 Apr 5 22:26 liuwenhe.dbf

-rw-r----- 1 oracle oinstall 52429312 Apr 5 22:26 redo01.log

-rw-r----- 1 oracle oinstall 52429312 Apr 5 22:29 redo03.log

-rw-r----- 1 oracle oinstall 4938801152 Apr 5 22:26 soe3.dbf

-rw-r----- 1 oracle oinstall 2469404672 Apr 5 22:26 soe.dbf

-rw-r----- 1 oracle oinstall 2705334272 Apr 5 22:26 sysaux01.dbf

-rw-r----- 1 oracle oinstall 786440192 Apr 5 22:26 system01.dbf

-rw-r----- 1 oracle oinstall 30416896 Oct 16 12:37 temp01.dbf

-rw-r----- 1 oracle oinstall 1073750016 Apr 5 22:26 temp.dbf

-rw-r----- 1 oracle oinstall 309338112 Apr 5 22:26 undotbs01.dbf

-rw-r----- 1 oracle oinstall 166469632 Apr 5 22:26 users01.dbf

Delete redo file

[root@testdb59 /data/u01/app/oracle/oradata/stdb59]# rm *.log

Check again, it has been found that there is no redo file

[root@testdb59 /data/u01/app/oracle/oradata/stdb59]# ll

total 13595388

-rw-r----- 1 oracle oinstall 144916480 Apr 5 22:50 control01.ctl

-rw-r----- 1 oracle oinstall 2147491840 Apr 5 22:50 liuwenhe.dbf

-rw-r----- 1 oracle oinstall 4938801152 Apr 5 22:50 soe3.dbf

-rw-r----- 1 oracle oinstall 2469404672 Apr 5 22:50 soe.dbf

-rw-r----- 1 oracle oinstall 2705334272 Apr 5 22:50 sysaux01.dbf

-rw-r----- 1 oracle oinstall 786440192 Apr 5 22:50 system01.dbf

-rw-r----- 1 oracle oinstall 30416896 Oct 16 12:37 temp01.dbf

-rw-r----- 1 oracle oinstall 1073750016 Apr 5 22:41 temp.dbf

-rw-r----- 1 oracle oinstall 309338112 Apr 5 22:50 undotbs01.dbf

-rw-r----- 1 oracle oinstall 166469632 Apr 5 22:50 users01.dbf

SQL> create table t(int int);

Table created.

SQL> insert into t values (100);

1 row created.

SQL> commit;

SQL>alter system switch logfile;

System altered.

SQL> alter system checkpoint;

System altered.

A little not understand !!!! asked the teacher, I realized that is open file handles still, after the restart, there is no! Will error

(In vitro words: That rm this file, but the file is actually still there, to talk about his works it, then I put everyone to share test, the principle is actually not difficult, this tool needs the ext4 or ext3 file system can only be achieved because ext3 file system is a journaling file system, ext3 file system when information is stored by the inode number and block storage block.

? Shenma do not know what is the inode number and block blocks Well, say understand the point, such as:?? A partition such as a book, then the book block is a block of each page of content, the inode number is the catalog of the book, the system find the file inode number and then find someone to block fast according to the information on the hard disk inode number to find, understand it!

In principle deleted talk about it. When deleting a file on the hard drive, in fact, not really imagined it in the supernatant hard to get rid of, he is the inode number and block off the chain block, but the actual data still on the hard disk, there is no sense in delete the windos is so fast, it did not take this into account when you delete a file in place to re-copy the new files, then the file will overwrite the previous, that is removed does not matter, do not go in that location put files)

Because the database consistency is closed, that is, it does not require instance recovery, there is no need missing redo, so you can delete reconstruction directly, of course, can recover database to recover lost redo, so for this case, there are two recovery the way:

Method One: direct clear the corresponding redo log group is deleted to re-establish!!

SQL> shutdown immediate # consistency Close

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

Total System Global Area 1603411968 bytes

Fixed Size 2253664 bytes

Variable Size 1275071648 bytes

Database Buffers 318767104 bytes

Redo Buffers 7319552 bytes

Database mounted.

SQL> archive log list;

Database log mode No Archive Mode

Automatic archival Disabled

Archive destination USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence 30641

Current log sequence 30642

Cleanup to delete or re-establish direct clear all of the redo log groups, including the redo log group and the current state of active state!

SQL> alter database clear logfile group 1;

Database altered.

SQL> alter database clear logfile group 3;

Database altered.

SQL> alter database open ;

Database altered.

Method Two: recover the restoration redo log, my experiment, this method will sometimes error, if error then use the first method to recover!

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

Total System Global Area 830930944 bytes

Fixed Size 2257800 bytes

Variable Size 536874104 bytes

Database Buffers 289406976 bytes

Redo Buffers 2392064 bytes

Database mounted.

SQL>

### recover the lost redo file, but need to be created automatically open after resetlogs on!

SQL> recover database until cancel;

Media recovery complete.

SQL> alter database open resetlogs;

Database altered.

Two: Oracle did not open the archive, non-uniform close the database

[root@testdb59 /data/u01/app/oracle/oradata/stdb59]# rm -f *.log

SQL> shu abort ### non-database consistency closed

ORACLE instance shut down.

Try to use this time in front of the clear error or recover database will not be restored, because this time is the need to do instance recovery, then the basis to judge when to resume examples, please refer to another article (Oracle principle ----- About roll forward and roll back the understanding of oracle instance recovery), given as follows:

First try to rebuild, when you try to clear the current log group, will get an error prompt is needed because the non-conformance close !!! really need to use the loss of active and redo current state of the instance to recover!

First, start the database to mount state

SQL> alter database clear logfile group 3;

alter database clear logfile group 3

*

ERROR at line 1:

ORA-01624: log 3 needed for crash recovery of instance stdb59 (thread 1)

ORA-00312: online log 3 thread 1:

'/data/u01/app/oracle/oradata/stdb59/redo03.log'

And then try to recover database, the results can not be sure, because of the need to redo instance recovery has been lost !!

SQL> recover database until cancel;

ORA-00279: change 21959466 generated at 04/06/2019 21:15:45 needed for thread 1

ORA-00289: suggestion :

/data/u01/app/oracle/fast_recovery_area/STDB59/archivelog/2019_04_06/o1_mf_1_2_%

u_.arc

ORA-00280: change 21959466 for thread 1 is in sequence #2

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

CANCEL

ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below

ORA-01194: file 1 needs more recovery to be consistent

ORA-01110: data file 1: '/data/u01/app/oracle/oradata/stdb59/system01.dbf'

ORA-01112: media recovery not started

SQL> alter database open RESETLOGS;

alter database open RESETLOGS

ERROR at line 1:

ORA-01194: file 1 needs more recovery to be consistent

ORA-01110: data file 1: '/data/u01/app/oracle/oradata/stdb59/system01.dbf'

So for this case, the recovery in the following way:

After using a hidden parameter _allow_resetlogs_corruption forced to start the database, set this parameter, the database Open the process, Oracle will skip some consistency checks, so that the database may skip an inconsistent state, open the destination database

SQL> create pfile='/home/oracle/pfile.ora' from spfile;

File created.

Then add the /home/oracle/pfile.ora

*._allow_resetlogs_corruption=true

SQL> startup mount pfile='/home/oracle/pfile.ora';

SQL> recover database until cancel; # recover lost redo file

ORA-00279: change 21959471 generated at 04/06/2019 22:34:01 needed for thread 1

ORA-00289: suggestion :

/data/u01/app/oracle/fast_recovery_area/STDB59/archivelog/2019_04_06/o1_mf_1_2_%

u_.arc

ORA-00280: change 21959471 for thread 1 is in sequence #2

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

CANCEL

ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below

ORA-01194: file 1 needs more recovery to be consistent

ORA-01110: data file 1: '/data/u01/app/oracle/oradata/stdb59/system01.dbf'

ORA-01112: media recovery not started

With luck you can directly open the database in a way resetlogs!

SQL> alter database open RESETLOGS;

Database altered.

If you encounter the following error, then you have to rebuild the control file:

SQL> alter database open RESETLOGS;

alter database open RESETLOGS

*

ERROR at line 1:

ORA-01092: ORACLE instance terminated. Disconnection forced

ORA-00704: bootstrap process failure

ORA-00704: bootstrap process failure

ORA-00600: internal error code, arguments: [2662], [0], [21959484], [0],

[21959877], [4194545], [], [], [], [], [], []

Process ID: 13177

Session ID: 63 Serial number: 5

Rebuild the database control file

1) directly alter database backup controlfile this being given as follows

SQL> alter database backup controlfile to trace as '/data/u01/control_rebuild.trc';

alter database backup controlfile to trace as '/data/u01/control_rebuild.trc'

*

ERROR at line 1:

ORA-16433: The database must be opened in read/write mode.

2) the following may also be used to reconstruct a specific format,

Query redo information in the database:

SQL> select GROUP#,MEMBER from v$logfile;

GROUP# MEMBER

3 /data/u01/app/oracle/oradata/stdb59/redo03.log

1 /data/u01/app/oracle/oradata/stdb59/redo01.log

datafile information query the database

SQL> select MEMBER from v$logfile;

MEMBER

--------------------------------------------------------------------------------

/data/u01/app/oracle/oradata/stdb59/redo03.log

/data/u01/app/oracle/oradata/stdb59/redo01.log

/data/u01/app/oracle/oradata/stdb59/redo04.log

/data/u01/app/oracle/oradata/stdb59/redo05.log

/data/u01/app/oracle/oradata/stdb59/redo06.log

/data/u01/app/oracle/oradata/stdb59/redo07.log

Find out the database character set:

SQL> select userenv('language') nls_lang from dual;

NLS_LANG

----------------------------------------------------

AMERICAN_AMERICA.AL32UTF8

Then edit the script to create the control file: Note that the testdb57 database (db_name), adg if it is converted into the main library, do not write db_unique_name

CREATE CONTROLFILE REUSE DATABASE 'testdb57' NORESETLOGS ARCHIVELOG

MAXLOGFILES 50

MAXLOGMEMBERS 5

MAXDATAFILES 100

MAXINSTANCES 8

MAXLOGHISTORY 226

LOGFILE

GROUP 3 '/data/u01/app/oracle/oradata/stdb59/redo03.log' SIZE 50M,

GROUP 1 '/data/u01/app/oracle/oradata/stdb59/redo01.log' SIZE 50M

DATAFILE

'/data/u01/app/oracle/oradata/stdb59/system01.dbf',

'/data/u01/app/oracle/oradata/stdb59/sysaux01.dbf',

'/data/u01/app/oracle/oradata/stdb59/undotbs01.dbf',

'/data/u01/app/oracle/oradata/stdb59/users01.dbf',

'/data/u01/app/oracle/oradata/stdb59/liuwenhe.dbf',

'/data/u01/app/oracle/oradata/stdb59/soe.dbf',

'/data/u01/app/oracle/oradata/stdb59/soe3.dbf'

CHARACTER SET AL32UTF8;

Then start the database directly to nomount state, create a script to execute

SQL> startup nomount pfile='/home/oracle/pfile.ora';

ORACLE instance started.

Total System Global Area 1603411968 bytes

Fixed Size 2253664 bytes

Variable Size 1275071648 bytes

Database Buffers 318767104 bytes

Redo Buffers 7319552 bytes

CREATE CONTROLFILE REUSE DATABASE 'testdb57' NORESETLOGS ARCHIVELOG

MAXLOGFILES 50

MAXLOGMEMBERS 5

MAXDATAFILES 100

MAXINSTANCES 8

MAXLOGHISTORY 226

LOGFILE

GROUP 3 '/data/u01/app/oracle/oradata/stdb59/redo03.log' SIZE 50M,

GROUP 1 '/data/u01/app/oracle/oradata/stdb59/redo01.log' SIZE 50M

DATAFILE

'/data/u01/app/oracle/oradata/stdb59/system01.dbf',

'/data/u01/app/oracle/oradata/stdb59/sysaux01.dbf',

'/data/u01/app/oracle/oradata/stdb59/undotbs01.dbf',

'/data/u01/app/oracle/oradata/stdb59/users01.dbf',

'/data/u01/app/oracle/oradata/stdb59/liuwenhe.dbf',

'/data/u01/app/oracle/oradata/stdb59/soe.dbf',

'/data/u01/app/oracle/oradata/stdb59/soe3.dbf'

CHARACTER SET AL32UTF8;

Control file created.

Then use oradebug promote memory scn number, in order to facilitate the implementation of the latter recover the redo to recover lost files, recover because the process will read the memory scn. Note that alter session set events '10015 trace name adjust_scn level 10'; in this manner has expired 11.2.0.4

(Digression: Let's talk about Oracle's internal database SCN, SCN is a monotonically increasing number of digital, control files, data files, online Redo logs, and archive log backup set, are included in the figures. internal documents, SCN is stored bit is the basis .Base SCN number is to be preserved by 32 bits. Once beyond this 32-bit length, the system will automatically carry Wrap Wrap base and by two portions that , carry Wrap count exceeds the number represented by the 4G)

SQL> oradebug poke 0x06001AE70 4 0x001B7740

oradebug promote scn number, Poke command, a first parameter corresponding to the number of bits of memory is written, is written to the length of the second parameter, the third parameter value is written. The default value is 10 hexadecimal is written, we hexadecimal (0x beginning), each segment value specified here is written, with the corresponding hexadecimal 8, corresponds to the number of digits is four

First, find out the database control file scn No.

SQL> select file#, checkpoint_change# from v$datafile;

FILE# CHECKPOINT_CHANGE#

---------- ------------------

1 21959486

2 21959486

3 21959486

4 21959486

5 21959486

6 21959486

7 21959486

7 rows selected.

SQL> oradebug setmypid

Statement processed.

SQL> oradebug DUMPvar SGA kcsgscn_

kcslf kcsgscn_ [06001AE70, 06001AEA0) = 014F14A2 00000001 00000000 00000000 000000EB 00000000 00000000 00000000 00000000 00000000 6001AB50 00000000

SQL> oradebug poke 0x06001AE70 4 21959486

BEFORE: [06001AE70, 06001AE74) = 00000000

AFTER: [06001AE70, 06001AE74) = 014F133E

(Or can be converted into a hexadecimal 21959486, then modify the

SQL> select to_char(21959486, 'XXXXXXXXXXX') from dual;

TO_CHAR(2195

------------

14F133E

SQL> oradebug poke 0x06001AE70 4 0x14F133E

BEFORE: [06001AE70, 06001AE74) = 00000000

AFTER: [06001AE70, 06001AE74) = 014F133E)

Check again, it has been turned into a 014F133E (corresponding to 10 decimal is 21959486)

SQL> oradebug DUMPvar SGA kcsgscn_

kcslf kcsgscn_ [06001AE70, 06001AEA0) = 014F133E 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 6001AB50 00000000

And then do recover incomplete recovery:

SQL> recover database until cancel;

ORA-00279: change 21959486 generated at 04/06/2019 23:52:28 needed for thread 1

ORA-00289: suggestion :

/data/u01/app/oracle/fast_recovery_area/STDB59/archivelog/2019_04_07/o1_mf_1_2_%

u_.arc

ORA-00280: change 21959486 for thread 1 is in sequence #2

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

CANCEL

ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below

ORA-01194: file 1 needs more recovery to be consistent

ORA-01110: data file 1: '/data/u01/app/oracle/oradata/stdb59/system01.dbf'

ORA-01112: media recovery not started

SQL> alter database open resetlogs;

Database altered.

So far a successful recovery!

Three: oracle open archiving, consistency closed

This situation is the same situation 1, do not require instance recovery, so you can delete or recover from the new group can direct all of the redo,

Method One: direct clear the corresponding redo log group is deleted to re-establish!!

SQL> shutdown immediate # consistency Close

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

Total System Global Area 1603411968 bytes

Fixed Size 2253664 bytes

Variable Size 1275071648 bytes

Database Buffers 318767104 bytes

Redo Buffers 7319552 bytes

Database mounted.

Cleanup to delete or re-establish direct clear all of the redo log groups, including the redo log group and the current state of active state!

SQL> alter database clear logfile group 1;

Database altered.

SQL> alter database clear logfile group 3;

Database altered.

SQL> alter database open ;

Database altered.

Method Two: recover the restoration redo log, my experiment, this method will sometimes error, if error then use the first method to recover!

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

Total System Global Area 830930944 bytes

Fixed Size 2257800 bytes

Variable Size 536874104 bytes

Database Buffers 289406976 bytes

Redo Buffers 2392064 bytes

Database mounted.

SQL>

### recover the lost redo file, but need to be created automatically open after resetlogs on!

SQL> recover database until cancel;

Media recovery complete.

SQL> alter database open resetlogs;

Database altered.

Four: open archives, non-uniform closed;

This case, only the aid of archive logs do not fully recover!

SQL> select * from v$log;

GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC

---------- ---------- ---------- ---------- ---------- ---------- ---

STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME

---------------- ------------- --------- ------------ ---------

1 1 39 52428800 512 1 YES

INACTIVE 4318162327 20-APR-19 4318209770 20-APR-19

3 1 40 52428800 512 1 NO

CURRENT 4318209770 20-APR-19 2.8147E+14

SQL> archive log list;

Database log mode Archive Mode

Automatic archival Enabled

Archive destination USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence 39

Next log sequence to archive 40

Current log sequence 40

Delete redo log files

[oracle@testdb59 stdb59]$ rm -f *.log

Then close the non-conformance

SQL> shu abort

ORACLE instance shut down.

Resolution process:

SQL> startup mount

ORACLE instance started.

Total System Global Area 1603411968 bytes

Fixed Size 2253664 bytes

Variable Size 1275071648 bytes

Database Buffers 318767104 bytes

Redo Buffers 7319552 bytes

Database mounted.

### recover the lost redo file, but need to be created automatically open after resetlogs on!

SQL> recover database until cancel;

Media recovery complete.

Resetlog try to open the way, if given as follows, then had the aid of hidden parameters _allow_resetlogs_corruption;

SQL> alter database open RESETLOGS;

alter database open RESETLOGS

*

ERROR at line 1:

ORA-01194: file 1 needs more recovery to be consistent

ORA-01110: data file 1: '/data/u01/app/oracle/oradata/stdb59/system01.dbf'

After using a hidden parameter _allow_resetlogs_corruption forced to start the database, set this parameter, the database Open the process, Oracle will skip some consistency checks, so that the database may skip an inconsistent state, open the destination database

SQL> create pfile='/home/oracle/pfile.ora' from spfile;

File created.

Then add the /home/oracle/pfile.ora

*._allow_resetlogs_corruption=true

SQL> startup mount pfile='/home/oracle/pfile.ora';

SQL> alter database open RESETLOGS;

Database altered.

Then close the database consistency, remove the implicit parameter _allow_resetlogs_corruption, restart the database!

Summary: Whether or not to open the archive to open the archive, as long as the non-conformance to close the database, you need the help of hidden parameters _allow_resetlogs_corruption, consistency, then close the database recovery is relatively simple, state started to mount, you can rebuild the lost redo file!

Guess you like

Origin www.linuxidc.com/Linux/2019-08/160291.htm