Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Oracle Database 11g.pdf
Скачиваний:
78
Добавлен:
10.06.2015
Размер:
12.69 Mб
Скачать

704  Appendix A  n  Lab Exercises

10.Open the database with the alter database open resetlogs command. Since you are using a backup control file, you must use the resetlogs command.

SQL> alter database open resetlogs; Database altered.

Lab 3.3: Recovering from Loss of the Current Online Redo Log

In this lab we will be recovering from the loss of the current online redo log. This is perhaps one of the worst-case situations that you would face as an Oracle DBA!

1.Back up the database. Details on how to do a full online database backup are found in Chapter 2. In summary, follow these steps:

a.Put the database in hot backup mode.

b.Copy all database datafiles to a backup location.

c.Take the database out of hot backup mode.

d.Force a log switch. Back up the archived redo logs.

Here is an example of a backup:

[oracle@localhost orcl]$ sqlplus “/ as sysdba”

SQL*Plus: Release 11.1.0.6.0 - Production on Sun Aug 17 15:35:48 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to:

Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production With the Partitioning, OLAP, Data Mining

and Real Application Testing options SQL> alter database begin backup; Database altered.

SQL> host cp /oracle01/oradata/orcl/*.dbf /oracle01/backup/orcl SQL> alter database end backup;

Database altered.

SQL> alter system switch logfile; System altered.

SQL> host cp /oracle01/backup/arch/* /oracle01/backup/orcl/* SQL> alter database backup controlfile to trace;

Database altered.

SQL> alter database backup controlfile to ‘/oracle01/oradata/orcl/control1.bak’; Database altered.

Lab 3.3: Recovering from Loss of the Current Online Redo Log 

705

2.Determine the location of the online redo logs by querying the MEMBER column of the

V$LOGFILE view.

SQL> select member from v$logfile; MEMBER

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

/oracle01/oradata/orcl/redo03.log

/oracle01/oradata/orcl/redo02.log

/oracle01/oradata/orcl/redo01.log

/oracle01/oradata/orcl/redo01a.log

/oracle01/oradata/orcl/redo02a.log

/oracle01/oradata/orcl/redo03a.log

3.While the database is still running, remove all of the online redo logs.

SQL> host rm /oracle01/oradata/orcl/redo03.log SQL> host rm /oracle01/oradata/orcl/redo02.log SQL> host rm /oracle01/oradata/orcl/redo01.log SQL> host rm /oracle01/oradata/orcl/redo01a.log SQL> host rm /oracle01/oradata/orcl/redo02a.log SQL> host rm /oracle01/oradata/orcl/redo03a.log

Note that this lab is set up to demonstrate recovering a database from an actual crash as a result of the loss of the online redo logs. If the database has not actually crashed, you would issue an alter database checkpoint command and then try an alter database clear logfile command to try to save the database from crashing.

4.If the database is still running, simulate a crash using the shutdown abort command.

SQL> shutdown abort ORACLE instance shut down.

5.Start up the database to see the error you will receive.

SQL> startup

 

 

ORACLE instance started.

 

 

Total System Global Area

159027200

bytes

Fixed Size

1298556

bytes

Variable Size

134221700

bytes

Database Buffers

20971520

bytes

Redo Buffers

2535424

bytes

Database mounted.

 

 

ORA-00313: open failed for members of log group 1 of thread 1

706  Appendix A  n  Lab Exercises

ORA-00312: online log 1 thread 1: ‘/oracle01/oradata/orcl/redo01a.log’ ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory Additional information: 3

ORA-00312: online log 1 thread 1: ‘/oracle01/oradata/orcl/redo01.log’ ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory Additional information: 3

6.Restore the database from the backup taken in step 1.

[oracle@localhost orcl]$ cp /oracle01/backup/orcl/*.gz . &

7.Mount the database using the startup mount command.

[oracle@localhost orcl]$ sqlplus / as sysdba

SQL*Plus: Release 11.1.0.6.0 - Production on Sun Aug 17 16:26:56 2008 Copyright (c) 1982, 2007, Oracle. All rights reserved.

Connected to

an idle instance.

 

SQL> startup

mount

 

 

ORACLE instance started.

 

 

Total System

Global Area

167395328

bytes

Fixed Size

 

1298612

bytes

Variable Size

 

142610252

bytes

Database Buffers

20971520

bytes

Redo Buffers

 

2514944

bytes

Database mounted.

 

 

8.Using the V$ARCHIVED_LOG, determine the last log sequence number archived.

SQL> select max(sequence#) from v$archived_log 2 where resetlogs_change#=

3 (select max(resetlogs_change#) from v$archived_log); MAX(SEQUENCE#)

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

9

9.Recover the database using the recover database until cancel command. Use the last archived redo log sequence number found in step 8 as the sequence to recover to. Once you reach that sequence number, cancel the recovery.

SQL> recover database using backup controlfile until cancel; SQL> recover database until cancel using backup controlfile; ORA-00279: change 5026562 generated at 08/19/2008 16:23:14

Lab 4.1: Creating an RMAN Offline Backup  

707

needed for thread 1 ORA-00289: suggestion :

/oracle01/flash_recovery_area/ORCL/archivelog/2008_08_19/ o1_mf_1_9_4bpm2cgp_.arcORA-00280: change 5026562

for thread 1 is in sequence #9

Specify log: {<RET>=suggested | filename | AUTO | CANCEL} ORA-00279: change 5026597 generated at 08/19/2008 16:23:33 needed for thread 1

ORA-00289: suggestion : /oracle01/flash_recovery_area/ORCL/archivelog/2008_08_19/ o1_mf_1_10_4bpm2bt3_.arc

ORA-00280: change 5026597 for thread 1 is in sequence #10 ORA-00278: log file ‘/oracle01/flash_recovery_area/ORCL/archivelog/2008_08_19/ o1_mf_1_9_4bpm2cgp_.arc’ no longer needed for this recovery Specify log: {<RET>=suggested | filename | AUTO | CANCEL} cancel

Media recovery cancelled.

10.Open the database with the alter database open resetlogs command. Your recovery is complete.

SQL> alter database open resetlogs; Database altered.

Lab 4.1: Creating an RMAN

Offline Backup

In this lab, you will be creating an RMAN offline backup. You can back up databases in NOARCHIVELOG or ARCHIVELOG mode with offline backups.

1.Start RMAN.

C:\>rman target=/

Recovery Manager: Release 11.1.0.6.0 - Production on Thu Sep 11 18:58:55 2008

Copyright (c) 1982, 2007, Oracle. All rights reserved. connected to target database: ORCL (DBID=1190537904)

708  Appendix A  n  Lab Exercises

2.Shut down the database from RMAN using the RMAN shutdown immediate command. Then start the database in MOUNT mode with the RMAN startup mount command.

RMAN> shutdown immediate

using target database control file instead of recovery catalog database closed

database dismounted Oracle instance shut down

RMAN> startup mount

 

 

connected to target database

(not started)

Oracle instance started

 

 

database mounted

 

 

Total System Global Area

397557760

bytes

Fixed Size

1333452

bytes

Variable Size

281020212

bytes

Database Buffers

109051904

bytes

Redo Buffers

6152192

bytes

3.Back up the database using the backup command. In this case, we are not going to back up the database archived redo logs if the database is in ARCHIVELOG mode. Since it was shut down in a consistent manner, we don’t need to back up any archived redo logs to restore this backup.

RMAN> Backup database; Starting backup at 11-SEP-08 allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=155 device type=DISK

channel ORA_DISK_1: starting compressed full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00002 name=C:\ORACLE\ORADATA\ORCL\SYSAUX01.DBF input datafile file number=00001 name=C:\ORACLE\ORADATA\ORCL\SYSTEM01.DBF input datafile file number=00005 name=C:\ORACLE\ORADATA\ORCL\UNDOTBS02.DBF input datafile file number=00004 name=C:\ORACLE\ORADATA\ORCL\USERS01.DBF channel ORA_DISK_1: starting piece 1 at 11-SEP-08

channel ORA_DISK_1: finished piece 1 at 11-SEP-08 piece handle=C:\ORACLE\FLASH_RECOVERY_AREA\ORCL

\BACKUPSET\2008_09_11\O1_MF_NNNDF_TAG20080911T204331_4DMOTSN1_.BKP tag=TAG20080911T204331 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:05:26 Finished backup at 11-SEP-08

Starting Control File and SPFILE Autobackup at 11-SEP-08

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]