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

Backing Up the Control File 

91

Backing Up the Control File

Finally, we need to talk about control-file backups. We introduced you to the control file in Chapter 1. In Oracle there are three ways to manually back up a control file (again, RMAN methods will be covered in Chapter 4):

NN

Backing up the original control file during a cold backup

NN

Creating a backup control file

NN

Creating a trace file with the create control file command in it

We have really already covered the first method in this chapter. Let’s look at the remaining two methods in some more detail. We will address recovering from a lost control file in Chapter 3.

Creating a Backup Control File

The backup control file is almost the same as a regular control file. It has some areas in it that are marked such that Oracle recognizes that it’s a backup control file. When a backup control file is used, some form of recovery will be required (typically just involving the use of the archived and online redo logs if the database is otherwise intact).

To create the backup control file simply issue the alter database backup controlfile to command, indicating at the end of the command where you want the control file to be created.

For example, if you wanted to create a backup control file after the online backup you performed in Exercise 2.4, you would simply need to issue the following command:

SQL> alter database backup controlfile to ‘c:\backup\orcl\backup2\backup_control.ctl’; Database altered.

The result is the creation of a backup control file called backup_control.ctl found in the c:\backup\orcl\backup2 directory, as you can see here:

SQL> host dir c:\backup\orcl\backup2\backup_control.ctl

Volume in drive

C has no label.

Volume Serial Number is 08DE-E1AB

Directory of c:\backup\orcl\backup2

08/02/2008 03:24 PM

10,174,464 BACKUP_CONTROL.CTL

1

File(s)

10,174,464 bytes

0

Dir(s)

9,930,571,776 bytes free

We will cover recovering from control-file loss using a backup control file in Chapter 3.

92  Chapter 2  n  Performing Oracle User-Managed Backups

Creating a Trace File with the Create Control File Command in It

If all else fails and you do not have a backup control file, don’t worry; you have another option, the create controlfile command. Normally, manually executing the command can be challenging because you need to know a lot of information about your database (like the names and locations of all the database datafiles). However, you can prepare for the possibility of having to use the create controlfile command by creating one in advance. The alter database backup controlfile to trace command will create a trace file with the create controlfile command in it for you. The trace file is stored in the new diagnostic directory structure in Oracle Database 11g.

The diagnostic directory structure is a new standard introduced in Oracle Database 11g that defines where Oracle stores files related to database troubleshooting and diagnostics. The base directory of this structure is defined by the parameter DIAGNOSTIC_DEST. Here is an example of the setting of DIAGNOSTIC_DEST on an Oracle database:

SQL> show parameter diag

 

 

NAME

TYPE

VALUE

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

-----------

---------

diagnostic_dest

string

C:\ORACLE

A whole book could be written on the new 11g diagnostic capabilities, but what we are interested in is where user-generated trace files get created, because when we issue the

alter database backup controlfile to trace command, the resulting file will be a usergenerated trace file.

In this case, the trace file will be created in $DIAGNOSTIC_BASE\diag\rdbms\orcl\orcl\ trace as shown in this code example:

SQL> alter database backup controlfile to trace;

Database altered.

C:\oracle\diag\rdbms\orcl\orcl\trace>dir

Volume in drive C has no label.

Volume Serial Number is 08DE-E1AB

Directory of C:\oracle\diag\rdbms\orcl\orcl\trace

08/02/2008

03:38 PM

<DIR>

.

 

08/02/2008

03:38 PM

<DIR>

..

08/02/2008

03:38 PM

1,027,520

alert_orcl.log

08/02/2008

03:38 PM

9,572

orcl_ora_12120.trc

08/02/2008

03:38 PM

91

orcl_ora_12120.trm

 

4

File(s)

1,037,183

bytes

 

4

Dir(s)

9,964,507,136

bytes free

Backing Up the Control File 

93

The trace file is called orcl_ora_12120.trc (it’s easy to tell since there are no other trace files in the directory). Another option with the alter database backup controlfile to trace command is to define an alternate location for the trace file. The syntax for this command is as follows:

alter database backup controlfile to trace as ’/tmp/my_control_trace.trc’;

If you look in the file, you will find a trace-file header in it first. Later down the trace file you will find two different versions of the create controlfile command. Here is an example of the create control file command that you might find in this file:

CREATE CONTROLFILE REUSE DATABASE “ORCL” NORESETLOGS ARCHIVELOG MAXLOGFILES 16

MAXLOGMEMBERS 3

MAXDATAFILES 100

MAXINSTANCES 8 MAXLOGHISTORY 292

LOGFILE

GROUP 1 ‘C:\ORACLE\ORADATA\ORCL\REDO01.LOG’ SIZE 50M, GROUP 2 ‘C:\ORACLE\ORADATA\ORCL\REDO02.LOG’ SIZE 50M, GROUP 3 (

‘C:\ORACLE\ORADATA\ORCL\REDO03A.LOG’,

‘C:\ORACLE\ORADATA\ORCL\REDO03B.LOG’

)SIZE 100M

--STANDBY LOGFILE DATAFILE

‘C:\ORACLE\ORADATA\ORCL\SYSTEM01.DBF’,

‘C:\ORACLE\ORADATA\ORCL\SYSAUX01.DBF’,

‘C:\ORACLE\ORADATA\ORCL\UNDOTBS01.DBF’,

‘C:\ORACLE\ORADATA\ORCL\USERS01.DBF’, ‘C:\ORACLE\ORADATA\ORCL\REVEAL_DATA_01.DBF’, ‘C:\ORACLE\ORADATA\ORCL\REVEAL_INDEX_01.DBF’, ‘C:\ORACLE\ORADATA\ORCL\USERS02.DBF’

CHARACTER SET WE8MSWIN1252;

You will notice that this output includes the datafile names, the location and names of the online redo logs, and other information needed by the create controlfile command. The trace file contains other output that will be required to complete the recovery process, so you should back up the trace file as it is. In Chapter 3 we will address the process of recovering from a control-file loss using the output contained in the trace files.

94  Chapter 2  n  Performing Oracle User-Managed Backups

Summary

In this chapter, we covered all aspects of user-managed Oracle database backups. We started with a quick review of the Oracle architecture related to backup and recovery so you could have a good foundation on which to build your knowledge. In that review, we discussed processes and memory in Oracle. We discussed ARCHIVELOG and NOARCHIVELOG mode. We also discussed startup and shutdown of the database, the different modes the database is in while starting up or shutting down, and why those modes are important during a recovery exercise.

We then reviewed configuring your database for backup and recovery, which mostly pertained to backups in ARCHIVELOG mode. We talked about archive logs, and the archivelog destination parameters. We talked about how an archive log is named when its created. We provided you with a list of parameters that are commonly used when configuring Oracle online backups, and we also provided you with a list of data dictionary views you might need to use to manage archived redo logs.

We then moved on to the topic of offline (cold) backups. We demonstrated how you could do an offline backup of your database. We proceeded to the topic of online backups, demonstrating that they are almost as simple as offline backups. Finally, we discussed backup control files and how they could be created.

Exam Essentials

Be able to configure a database of user-initiated online backups.  ​  ​Understand the different parameters that need to be configured when you are going to back up a database with user-based online backups. You will need to understand parameters such as LOG_ARCHIVE_ DEST_1 and how to configure them. You will need to understand what happens if you have two archive-log destination directories defined.

Be able to back up your database with an offline backup.  ​  ​Understand the steps that need to be performed to do an offline backup. Understand the difference between an offline backup and an online backup and how these differences can be used to decide the optimal backup strategy.

Be able to back up your database with an online backup.  ​  Know​ how to configure your database for an online backup. Understand how to put the database in ARCHIVELOG mode so you can do online backups. Understand how to determine which archived redo logs you will need to back up when doing an online backup.

Be able to back up your database control file.  ​  ​Understand why it is important to back up your control file. Understand the different methods of backing up your control file. Understand what a backup control file is.

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