Backup recovery oracle Phuocbeo blog

17
Oracle Backup and Recover 101 Osborne Press ISBN 0-07-219461-8 First Printing Personal Note from the Authors Thanks for your purchase of our book – Oracle Backup & Recovery 101. In our attempt to provide the best book we could to guide you to a solid understanding of backup and recovery concepts and instructions, we painstakingly edited each chapter several times at many stages of development. Unfortunately, despite our efforts and those of the publisher, several errors made it into print. With each printing, we will identify any errors and post them in this document. If you find an error found in your copy that have not been listed in this document, please email us at [email protected] . We appreciate your input. The authors, Kenny Smith & Stephan Haisley Errata Listing In this document, we identify content errors that you may have in your copy of the book. Formatting, minor typographical and presentation errors are not included in this errata listing. In many cases in this listing we are including the entire sentence, displaying the

description

This is my favorite ebook. It contain more infomation backup, recovert Oracle database. Enjoy !

Transcript of Backup recovery oracle Phuocbeo blog

Oracle Backup and Recover 101

Osborne Press

ISBN 0-07-219461-8

First Printing

Personal Note from the Authors

Thanks for your purchase of our book – Oracle Backup & Recovery 101. In our attempt

to provide the best book we could to guide you to a solid understanding of backup and

recovery concepts and instructions, we painstakingly edited each chapter several times at

many stages of development. Unfortunately, despite our efforts and those of the

publisher, several errors made it into print. With each printing, we will identify any errors

and post them in this document. If you find an error found in your copy that have not

been listed in this document, please email us at [email protected]. We

appreciate your input.

The authors,

Kenny Smith & Stephan Haisley

Errata Listing

In this document, we identify content errors that you may have in your copy of the book.

Formatting, minor typographical and presentation errors are not included in this errata

listing. In many cases in this listing we are including the entire sentence, displaying the

current text that may be found in your book. We use a strike through font to show the

words we’d like to replace. We use a red color to denote the words we like to add. If a

paragraph is has major changes, we show the paragraph before and the revised paragraph

in full.This will make it easier for you to see how we intended the text to read in the

book.

Introduction

Page xix - paragraph 5

By configuring database archiving of all redo log files, you can recover the database

completely or to a point in time.

Page xx - paragraph 1

Lastly, you’ll incompletely recover the database while using an open database backup.

Page xx - paragraph 6

All database transactions are logged to files. You can mine those files for the SQL

commands contained within them.

Page xxi - paragraph 1

LogMiner provides the means to extract the SQL commands within your log files. You

can retrieve the transactional statements from the redo log files, which can then be re-

applied to a database. During this chapter, you will analyze the contents of redo logs.

Using the transactions statements retrieved, you’ll be able to explore how to make use of

the SQL by applying it to the database.

Page xxi - paragraph 2

These seven chapters will also assist an old time DBA to migrate to a new skill

set from the old tried-and-true user managed techniques. Most of the tasks discussed in

Part Two can be accomplished quickly and easily by RMAN. Therefore, you can easily

contrast how you perform a specific task via user-managed method with the equivalent

server-managed method.

Chapter 1

Page 7 - paragraph 6

This way, the picture looks as it did before Sid accessed changed the picture frame.

Page 12 - paragraph 7

(This paragraph belongs outside the gray box).

After being introduced to Sid’s family house, you can see that he has

structures for all family procedures. Like this family operation, an Oracle

database has places, processes, and procedures. With this family analogy in

mind, I’ll now briefly describe Oracle database structures, processes, and

operations that pertain to Oracle Backup and Recovery. Maybe you’ll

recognize some similarities to Sid’s family.

Page 13 - paragraph 3

This area of memory that is allocated when the instance is started and is split up into

three main sections:

Page 15 - paragraph 1

It represents a consistent committed version of the database …

Page 17 - paragraph 4

They are called online because they must be online and available for the database to use.

Page 18 - paragraph 2

Change the note to…

Nologging and Redo

You can turn off the logging of data block changes for certain operations by

setting the NOLOGGING attribute for a table, partition, index, or tablespace. Normal

SQL will create redo on a NOLOGGING object. Operations that will not create normal

redo for changes include:

- Direct load using SQL*Loader

- Direct-load INSERT

- CREATE TABLE ... AS SELECT

- CREATE INDEX

- ALTER TABLE ... MOVE or SPLIT PARTITION

- ALTER INDEX ... SPLIT or REBUILD PARTITION

- ALTER INDEX ... REBUILD

These operations still generate redo records, but they are classed as 'invalidation records'

and are very small compared to standard data block redo records. Because redo is not

being generated from these data changes, the blocks affected must be invalidated should

redo be applied to them. This means that once a NOLOGGING operation has been

performed on objects, particularly tables, a fresh backup must be made of the datafiles

containing them. If this is not done and an old backup is restored with the invalidation

redo records being applied to the database, the next time you try and access the object

you will get block corruption errors. When you prevent normal redo from being written,

you trade better performance for data recoverability.

Page 24-25 – Bullets

Change the order of these bullets and add some text.

�� Creates operation codes and data required to undo the block change into an undo

segment (rollback segment). This also creates redo vectors before making the

undo segment block changes.

�� Records the redo records to the redo log buffer.

Page 25 – Gray box

Replace the gray box with this text.

(s)The Life of a Database Transaction

A user named Jim changes his home phone in the Employee Application from

111-222-3333 to 111-222-4444. He makes his change via a form in a browser. What

happens to his phone number information? Say the employee table has a column named

phone and the employee table is in a tablespace named Users. The Users tablespace is

made up of a file named user.dbf.

When Jim submits his change, the block containing his employee row is fetched

from datafile user.dbf and read into the buffer cache. Before the changed phone number

is placed in the data block in memory, a redo record gets written to log buffer. The redo

record notes the block change from the old state to the new state. Next, undo information

gets written to a rollback segment named RBS (in case Jim changes his mind and so other

users can see his old phone number until he commits his change). After the redo and the

undo is created, the data block containing Jim's row is changed. When Jim commits his

change, a commit record is written to the log buffer. The log buffer is then flushed to the

current online redo log. The undo blocks in the rollback segment are also freed.

While Jim clicks on his sports web page to check the scores, the online redo log

fills up. The database begins writing to the next empty redo log. If the data block

containing Jim's phone number change has not been written out to disk due to lack of

space in the buffer cache it will be written out during the checkpoint. The archiver begins

to copy the online redo log containing Jim’s transaction details. Once the archiver is

finished, Jim’s new phone number exists in two locations – a database block in a file

called user.dbf and in an archive log file in the archive destination.

Page 27 – Bottom bullets…

�� CKPT updates the control files and datafile headers with checkpoint details.

�� The checkpoint gets logged in the alert log file.

Page 28 – paragraph 1

When the database is shut down, various tasks occur depending on the shutdown

method:

Page 29 – paragraph 1

�� Log switch Logan switches notebooks to hold picture negatives. An Oracle database

stops writing to an online redo log file and begins writing to another.

Chapter 2

Page 40 – paragraph 2

This must be done because after an incomplete recovery, you do not need any of the redo

after this time.

Page 41 – paragraph 1

… production database or the tablespaces…

Page 46 – paragraph 6

…possibly use extra recovery…

Page 52 – Question 4

The correct answer is only D. The A should be removed.

Chapter 3

Page 55 – Paragraph 5

During this chapter, you will install Oracle software, create two databases, ….

Page 60 – Task 2

This Java program is named the Oracle Universal Installer.

1. Install Oracle Enterprise Version 8.1.7. Your software version option may have

different numbers in the last two digits, but make sure the first three digits are 8.1.7.

2. For a Linux install, enter /app/oracle/product/8.1.7 in the Path field for the

ORACLE_HOME directory.

3. For a Windows NT in the Oracle Home Name field, type 817. In the Path field, type

D:\app\oracle\product\8.1.7. Oracle on Windows NT has named Oracle Homes; Linux

does not.

Page 64 – Task 1

LINUX> $ORACLE_HOME/bin/dbassist &

WINNT> %ORACLE_HOME%\bin\launch.exe %ORACLE_HOME%\assistants\dbca

DBAssist.cl

Page 67 – Exercise 3.3

The amount of total time is 55. (Not 50)

Page 77 – Middle of page

SQL> execute DBMS_JOB.INTERVAL (1,null,null,'sysdate+1'); --Every day

SQL> execute DBMS_JOB.INTERVAL (1,null,null,'sysdate+1/24'); --Every Hour

SQL> execute DBMS_JOB.INTERVAL (1,null,null,'sysdate+1/(24*60)'); --Every

Minute

Chapter 4

Page 86 – Figure 4-1

Backups in this chapter exercises will be written to /oradata/PRACTICE/backup/ch04.

Page 88 – Exercise 4.1: Task 1

Change the SQL statement from the tina.date_log table:

SELECT TO_DATE TO_CHAR(max(create_date), .......)

Page 89 – Closed Backup script

Change line 18 of the script (add the ampersand):

18. &fil

Page 103 – Exercise 4.4: Task 1

Change the SQL statement from the tina.date_log table:

SELECT TO_DATE TO_CHAR(max(create_date), .......)

Page 107 – paragraph 1

For cancel-based recovery in this exercise, you have to manually apply the log file names

and then type CANCEL’ when you reach the log file that was current at the time of the

tablespace drop. (Remove the apostrophe after CANCEL).

Chapter 5

Throughout the chapter, change all references from directory

/oradata/PRACTICE/backup/ch5 to /oradata/PRACTICE/backup/ch05.

Page 115 - Figure 5-1

Change Tools0.1 to tools01. Change user.01 to users01.

All exercises in this chapter create backups in the /oradata/PRACTICE/backup/ch05

directory.

Page 116 - Second Bullet

All subsequent changes to the same block create normal redo change vectors while the

block still remains in the buffer cache.

Page 119– Open Backup Script

Change the line of the script that creates a backup of the control file to:

prompt alter database backup controlfile to '&dir./control.ctl' REUSE;;

Page 131 - Paragraph 2

The recover command determined that the redo needed for the recovery begins in archive

file sequence from 221 to 51.

Page 133 - Task Table

5. Recover database to a point in time

Page 133 - Last Code listing

SQL> INSERT INTO tina.date_log VALUES (sysdate+(365*5));

SQL> COMMIT;

Page 135 - Last Task heading

Recover Database to Point in Time

Page 136 - paragraph 4

Start Cancel-based recovery.

Page 138 - paragraph 2

During database startup and shutdown, you may have some problems.

Page 138 - paragraph 6

During database shutdown startup, you may get an error.

Page 141 - answer 5

5. C. When you issue the ALTER TABLESPACE TOOLS BEGIN BACKUP command,

the TOOLS tablespace undergoes a checkpoint. All changes for the files in that

tablespace get recorded as block images to the redo files.

Page 147 - gray box

2. The user running this command must be granted the OSDBA SYSDBA role.

Page 151 - paragraph 4

This file will be located in the location directory defined by the user_dump_dest

initialization parameter.

Page 152 - last paragraph

On a startup NOMOUNT, you only read the init.ora file and establish the memory

structures and background processes required by Oracle.

Page 153 - first paragraph

Both the online redo logs and the archived redo logs from the original database can no

longer be used for this database once you reset the logs to include your new database

name.

Page 155 - Gray box - last sentence

For extra credit, vary the file names, directories, and order. Note that once you get your

database open, the file number from the v$datafile dictionary view is the same in the

copied database as it is in original database. (I’m not recommending you change the

datafile order, but you can try this to help you understand the duplication process better.)

Page 160 - First paragraph

When you clone a database, you may (and probably will) run into various problems

along the way. Usually, those problems show up in an error message during a task in the

project.

Page 161 - paragraph 2

The CLNE database may need redo in the current PRACTICE database archive online

log.

Chapter 6

Throughout the chapter, change all occurrences of the database and directory from

STANDBY to STBY.

Chapter 7

Page 169 - Task listing

Remove task 3. The standby control file is made when the backup is taken.

Chapter 8

Page 186 - Bullet “Full database mode”

The import parameter defining user database mode is FULL=Y.

Page 195 - First paragraph

Two parameters that create output and do not change the database are SHOW and

INDEXFILE.

Page 196 - Point 2

The text definitions in the log files have been wrapped within words double-quotes.

Page 201 - paragraph 5

Create an export with three tables of Tina’s table using a parameter file as shown in this

example:

Chapter 9

Page 209 - last bullet

Any database files required for tablespace recovery. In this chapter, the auxiliary set is

the primary PRACTICE database backup control file, backup datafiles of the SYSTEM,

RBS and TEMP and RBS tablespaces, the auxiliary database parameter file and the

primary PRACTICE database archived log files.

Page 212 - first paragraph

You will recover this table using TSPITR. Before you drop the table, first create rebuild

an index on the employee table in the INDX tablespace.

Page 212 - last paragraph

Because any data changes made to objects in the USERS tablespace after TSPITR the

drop table command will not be recovered, the support department will not be found in

the department table.

Page 216 - Last paragraph

By doing this, you avoid the risk of corrupting the primary database instance by writing

over the control files, datafiles or online redo logs.

Page 217 - first paragraph

Then, you will recover the recovery set datafiles to prepare them for Export/Import

transporting back into the PRACTICE database.

Page 222 - first paragraph in Task 3

When you drop the tables tablespace including contents, the objects contained within it

are removed from the data dictionary.

Page 238 - Second Listing

SQL> EXECUTE dbms_logmnr.add_logfile( -

2 logfilename => 'd:\oradata\PRACTICE\archive\100.arc', -

2 logfilename => '/oradata/PRACTICE/archive/100.arc', -

3 options => dbms_logmnr.REMOVEFILE);

Page 242 - First Paragraph

You can see that someone logged in as user SCOTT and performed this update. You also

know the culprit was logged on to a machine named SJCOMP as an operating system

user named SJONES.

Page 245 - LogMiner

Once your investigation of the redo logs is completed, run the END_LOGMNR

procedure of the DBMS_LOGMNR package.

Page 246 - Summary

Occasional analysis of the online redo log files can help you find out when table data is

changed or perform capacity analysis on your Oracle database. LogMiner serves is a

handy means to look at the contents of Oracle 8, 8i or 9i database redo logs.

Chapter 11

Page 255 - Figure 11-1

Remove the Channels line between the target database and Recovery Manager

executable.

Page 256 - Bullet “Automated backup, restoration, and recovery”

RMAN reads the control file each time the database is backed up to make sure the correct

structural contents (tablespaces, datafiles, control files, and archive log files) are backed

up.

Page 267 - Gray box

After each backup, the second catalog also needs to be resynced to ensure that it contains

the newly created backup information.

Page 272 - Third bullet

The alert log file on the target and the catalog database may contain helpful information

for troubleshooting the MML.

Chapter 12

Page 281 - First paragraph

Second, let’s talk about items that involve the destination of the backup set.

Page 283 - First paragraph

A full whole database backup will therefore include the current control file.

Page 285 - Figure 12-1

The last Sunday Level 0 backup should be number 127 instead of 120. The same mistake

is made in figure 12-2.

Page 288 - both Points named “Finally”

Finally All the redo generated since the time of the Saturday backup will be applied.

Page 297 - First Paragraph

In this task, you’ll back up the database while it is open. The script in Listing 12-3 is

the same as the script is in task 1 with one exception: the database is open instead

of closed. This script demonstrates how easy this is.

Page 299 - First Bullet

�� including current controlfile in backupset The current control file is copied with

the system tablespace datafile. This message line comes right after the system datafile

copy backup.

Page 301 - Second bullet

�� Line 2 The database control files must be mounted to run any RMAN backup

commands. Why? All database schema structural information is stored in the target

control files.

Page 305 - paragraph 4

These files must be protected to be absolutely sure that you can recover your database to

a point in time in the past or to the current time.

Page 309 - last paragraph

When you run b_archive_delete.rcv, the DELETE INPUT qualifier instructs RMAN to

delete the archive log files that have been backed up after they have been successfully …

Page 309 - question 1

What RMAN command creates a copy of used database file blocks?

Chapter 13

Page 321 - paragraph 1

Throughout this chapter, you’ll see many RMAN commands applied toward checking

and maintaining cataloged backups of the PRACTICE database, …

Page 323 - Last paragraph

Not only can you perform a validation of a specific backup set, but you can also simulate

a restore of the database or portions of a database using the Validate option on the

RESTORE command. Finally, RMAN can validate that a recovery can be made to a

previous point in time using an UNTIL parameter to set the desired stop point of

recovery.

Page 335 Thursday bullet

�� Thursday Cumulative incremental level1 backup with tag THU_LEVEL1.

Page 341 - Backup Archive Logs

Open a SQL*Plus session as the catalog owner and run queries like you’ve done in

previous tasks (select from V$BACKUP_REDOLOG and RC_BACKUP_REDOLOG

instead).

Page 351 - Question 2

2. Which recovery catalog view shows backup sets made by RMAN?

Chapter 14

No known errors.

Chapter 15

Page 388 - First bullet

For example, if you have the init.ora parameter

CONTROL_FILE_RECORD_KEEP_TIME set to 21 days, you may not be able to

restore from a backup taken two months ago.

Page 389 - Figure 15-1

The arrows should not include exercise references.

Page 397 - paragraph 3

If, during all the output from the duplicate command script, you do not encounter an error

script and you see the RMAN-06400: database opened message, the RMAN database

duplication operation was a success!

Page 397 - Last code listing

SQL> CONNECT sys/practice@clne

Page 399 - Paragraph 2

Create your backup duplicate database with the script shown in Listing 15.2. Be sure to

shut down the CLNE database and open the instance without mounting it prior to running

this duplication script.

Chapter 16

Page 407 - Dorecover Bullet

�� DORECOVER Recovers the standby database using incremental datafile and

archive log backups.

Page 408 - Third Bullet

You must have a backup, that includes a standby control file.

Page 410 - Item 6

If tape backups are used, the standby server must have access to the Media Management

Layer and tape library that the primary database uses to makes its backups.

Page 414 - First bullet

RMAN can store that special file in a datafile backup piece. This backup control file can

also be used to restore the target database control file if needed.

Page 416 - First paragraph

This duplicate, however, is configured to be a STBY standby of the PRACTICE

database.

Page 422 - Item 4

The backup containing the standby control file was performed within the current online

redo log file. Redo information about the standby control file is contained in the

current online redo log file. Make sure hat you’ve switched log files so that RMAN

can access redo information current when the standby control file was created.

RMAN will read the archive log file.

Page 423 - Table titles

Change the word Duplication to Standby.

Issue the duplicate database command while connect to the target, catalog and auxiliary.

The standby control file is automatically by RMAN during standby creation.

Chapter 17

Page 438 - Fifth Bullet

Remove the bullet item.

Check that data in other tablespaces contains data that was changed after the recovery

time of the users tablespace.

Page 440 - Server-Managed TSPITR column

Performs automatic incomplete recovery and opens with RESETLOGS.