0523-0525

Previous Table of Contents Next

Page 523

Copying a control file at the operating system level should be done only in conjunction with a cold backup.

Mirrored Control Files

A recommended method for backing up an Oracle database control file is to mirror the control files. Unlike true disk mirroring, which is implemented at the operating system level by using technology such as RAID 0/1, this method merely designates multiple copies of the control file to which the database will write. This is done by means of the CONTROL_FILES parameter in the INIT.ORA parameter file:

 control_files = (/u03/oradata/norm/control.ctl, /u05/oradata/norm/control.ctl) 

You can include additional control files by editing the INIT.ORA file, shutting down, and restarting the database instance. For example:

 control_files = (/u03/oradata/norm/control.ctl, /u05/oradata/norm/control.ctl, /u07/oradata/norm/control.ctl) 

When you mirror the control files, place each control file on a separate physical disk to prevent all the copies from being lost in the event of a disk failurethe concept behind mirroring. Although an Oracle instance can function with only one control file, Oracle recommends at least two. However, you can have as many control files as there are physical disk drives . Control files are extremely cheap in terms of storage and performance cost (writing the information to the control file).

Backing Up Control Files (Online)

Although mirroring control files is useful, it is still a good idea to make actual backups of control files. In a worst-case disaster scenario, all the control files could be lost and the database might need to be restored on an alternate hardware system. Mirroring is not of much use then.

Because a reliable backup of a control file is not available from the operating system, Oracle provides a method that makes a reliable backup copy of the control file while the database is running. Use the alter database command from Oracle Server*Manager or SQL*Plus. For example,

 alter database backup controlfile to `/u10/admin/norm/arch/bk_control.ctl'; 

This command makes a backup control file and places it in the destination directory under the filename specified in the command. In this case, the directory is the path /u10/admin/norm/arch and the name of the backup control file is bk_control.ctl. Here is a full script that makes backup copies of control files:

 #!/bin/ksh $ORACLE_HOME/bin/svrmgrl << EOF connect internal alter database backup controlfile to    `/u10/admin/norm/arch/control.ctl'; exit EOF 

Page 524

You can back up this control file to tape along with the other files. That way, you make a full recovery possible.

Backup to Trace

Suppose that during routine maintenance to extend a tablespace, you encounter an error indicating that the maximum number of database files has been reached. A low default value had been used when the instance was created. The only way to change this value is to re-create the control file. To do this, however, you must know all the data files, redo log files, and so on that make up the instance.

With a fair amount of research, any DBA could cobble together the necessary information to perform this task. For most DBAs, though, time is a premium resource; the easier an activity can be done, the better. Oracle provides a facility that enables you to back up a control file to trace by issuing an alter database command from Oracle Server*Manager or SQL*Plus:

 alter database backup controlfile to trace; 

When you invoke this command, you create a SQL script that is capable of re-creating the current control file of the Oracle instance. The destination of the script is the directory specified in the USER_DUMP_DEST parameter of the INIT.ORA parameter file. For example:

 #!/bin/ksh $ORACLE_HOME/bin/svrmgrl << EOF connect internal alter database backup controlfile to trace; exit EOF 

When you execute this command, the editable SQL script shown here is produced. This script can be quickly changed and used, which ensures that all the parameters are correct. The DBA needs to worry only about scheduling, not the daunting task of checking and double-checking parameters.

 Dump file /u01/app/oracle/admin/norm/udmp/ora_25132.trc Oracle7 Server Release 7.1.6.2.0 - Production Release With the distributed option PL/SQL Release 2.1.6.2.0 - Production ORACLE_HOME = /u07/app/oracle/product/7.1.6 ORACLE_SID = norm Oracle process number: 9                          Unix process id: 25132 System name:     HP-UX Node name:        testdev Release:              A.09.00 Version:              U Machine:             8999/867 Sat Sep  9 14:26:39 1995 Sat Sep  9 14:26:39 1995 ***SESSION ID:(6.21) # The following commands will create a new control file and use it # to open the database. # No data other than log history will be lost.  Additional logs may 

Page 525

 # be required for media recovery of offline data files.  Use this # only if the current version of all online logs are available. STARTUP NOMOUNT CREATE CONTROLFILE REUSE DATABASE "NORM" NORESETLOGS NOARCHIVELOG           MAXLOGFILES 64           MAXLOGMEMBERS 5           MAXDATAFILES 1022           MAXINSTANCES 10           MAXLOGHISTORY 100 LOGFILE   GROUP 1 (     `/u07/oradata/norm/redo101.log',     `/u09/oradata/norm/redo102.log'    ) SIZE 10M,   GROUP 2 (     `/u07/oradata/norm/redo201.log',     `/u09/oradata/norm/redo202.log'     ) SIZE 10M DATAFILE   `/u02/oradata/norm/system01.dbf' SIZE 80M,   `/u04/oradata/norm/rbs01.dbf' SIZE 300M,   `/u11/oradata/norm/temp01.dbf' SIZE 150M,   `/u08/oradata/norm/tools01.dbf' SIZE 20M,   `/u05/oradata/norm/users01.dbf' SIZE 10M ; # 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; 

You should periodically make a control file backup to trace, perhaps as often as you make a control file backup.

Redo Log File Backups

Although Oracle provides a concise method for making backups of control files, no such method exists for redo logs. The only option for making backups of the redo logs is the very one that you have been cautioned againstusing operating system copy utilities.

Assuming that four redo logs are located on a single disk, the following code segment demonstrates various techniques for making copies:

 cp /u01/oradata/norm/redo101.log /DB1/oradata/norm cp /u01/oradata/norm/redo* /DB1/oradata/norm cpio -ocvB /u01/oradata/norm/redo101* > /dev/rmt/0hc cpio -ocvB /u01/oradata/norm/redo* > /dev/rmt/0hc find /u*/oradata/norm/*.log  cpio -ocvB > /dev/rmt/0hc 

Some DBAs like to force the redo logs to perform a logfile switchusually forcing an archive log to be writtenbefore initiating a copy of the redo logs. This is done from Oracle Server*Manager or SQL*Plus by using the alter system command. For example:

 alter system switch logfile; 
Previous Table of Contents Next


Oracle Unleashed
Oracle Development Unleashed (3rd Edition)
ISBN: 0672315750
EAN: 2147483647
Year: 1997
Pages: 391

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net