Oracle control file backup

Source: Internet
Author: User

The Oracle control file is the core file for running the Oracle database. If the control file is lost and cannot be recovered, the consequence is very serious and the database cannot be started.

Oracle provides two methods to back up control files:

1. Generate backup files

This is the most common method:

SQL> alter Database Backup controlfile to 'C:/controlfile. Bak ';

The database has been changed.

The final control file is backed up to C:/controlfile. Bak. The file extension can be customized without affecting the backup.

2. Generate a control file creation script

SQL> alter Database Backup controlfile to trace;

The database has been changed.

The script content is as follows:

The file is stored in: D:/Oracle/admin/ora92/udump:

Dump File d:/Oracle/admin/ora92/udump/ora92_ora_3500.trc
Tue Nov 21 16:06:04 2006
Oracle v9.2.0.1.0-production vsnsta = 0
Vsnsql = 12 vsnxtr = 3
Windows 2000 version 5.2 Service Pack 1, CPU type 586
Oracle9i Enterprise Edition Release 9.2.0.1.0-Production
With the partitioning, OLAP and Oracle Data Mining options
Jserver release 9.2.0.1.0-Production
Windows 2000 version 5.2 Service Pack 1, CPU type 586
Instance name: ora92

Redo thread mounted by this instance: 1

Oracle process number: 12

Windows Thread ID: 3500, image: Oracle. exe

* ** Session ID: (11.283) 16:06:04. 000
* ** 16:06:04. 000
# The following are current system-scope redo log archival related
# Parameters and can be encoded in the database initialization file.
#
# Log_archive_dest =''
# Log_archive_duplex_dest =''
#
# Log_archive_format = arc % S. % t
# Remote_archive_enable = true
# Log_archive_start = true
# Log_archive_max_processes = 2
# Standby_file_management = manual
# Standby_archive_dest = % ORACLE_HOME %/rdbms
# Fal_client =''
# Fal_server =''
#
# Log_archive_dest_1 = 'location = D:/Oracle/ora92/rdbms'
# Log_archive_dest_1 = 'mandatory noreopen nodelay'
# Log_archive_dest_1 = 'arch noaffrem sync'
# Log_archive_dest_1 = 'noregister noalternate nodependency'
# Log_archive_dest_1 = 'nomax _ failure noquota_size noquota_used'
# Log_archive_dest_state_1 = Enable
#
# Below are two sets of SQL statements, each of which creates a new
# Control file and uses it to open the database. The first set opens
# The database with the noresetlogs option and shoshould be used only if
# The current versions of all online logs are available. The second
# Set opens the database with the resetlogs option and shocould be used
# If online logs are unavailable.
# The appropriate set of statements can be copied from the trace
# A script file, edited as necessary, and executed when there is
# Need to re-create the control file.
#
# Set #1. noresetlogs case
#
# The following commands will create a new control file and use it
# To open the database.
# Data used by the recovery manager will be lost. Additional logs may
# 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 "ora92" noresetlogs archivelog
-- Set standby to maximize performance
Maxlogfiles 5
Maxlogmembers 3
Maxdatafiles 100
Maxinstances 1
# Maxloghistory 454
Logfile
Group 1 'd:/Oracle/oradata/ora92/redo01.log 'size 10 m,
Group 2 'd:/Oracle/oradata/ora92/redo02.log 'size 10 m,
Group 3 'd:/Oracle/oradata/ora92/redo03.log 'size 10 m
-- Standby logfile
Datafile
'D:/Oracle/oradata/ora92/system01.dbf ',
'D:/Oracle/oradata/ora92/undotbs01.dbf ',
'D:/Oracle/oradata/ora92/indx01.dbf ',
'D:/Oracle/oradata/ora92/tools01.dbf ',
'D:/Oracle/oradata/ora92/users01.dbf ',
'D:/Oracle/oradata/ora92/sp01.dbf'
Character Set zhs16gbk
;
# Recovery is required if any of the datafiles are restored backups,
# Or if the last shutdown was not normal or immediate.
Recover Database
# All logs need archiving and a log switch is needed.
Alter system archive log all;
# Database can now be opened normally.
Alter database open;
# Commands to add tempfiles to temporary tablespaces.
# Online tempfiles have complete space information.
# Other tempfiles may require adjustment.
Alter tablespace temp add tempfile 'd:/Oracle/oradata/ora92/temp01.dbf'
Size 41943040 reuse autoextend off;
# End of tempfile additions.
#
# Set #2. resetlogs case
#
# The following commands will create a new control file and use it
# To open the database.
# The contents of online logs will be lost and all backups will
# Be invalidated. Use this only if online logs are damaged.
Startup nomount
Create controlfile reuse Database "ora92" resetlogs archivelog
-- Set standby to maximize performance
Maxlogfiles 5
Maxlogmembers 3
Maxdatafiles 100
Maxinstances 1
# Maxloghistory 454
Logfile
Group 1 'd:/Oracle/oradata/ora92/redo01.log 'size 10 m,
Group 2 'd:/Oracle/oradata/ora92/redo02.log 'size 10 m,
Group 3 'd:/Oracle/oradata/ora92/redo03.log 'size 10 m
-- Standby logfile
Datafile
'D:/Oracle/oradata/ora92/system01.dbf ',
'D:/Oracle/oradata/ora92/undotbs01.dbf ',
'D:/Oracle/oradata/ora92/indx01.dbf ',
'D:/Oracle/oradata/ora92/tools01.dbf ',
'D:/Oracle/oradata/ora92/users01.dbf ',
'D:/Oracle/oradata/ora92/sp01.dbf'
Character Set zhs16gbk
;
# Recovery is required if any of the datafiles are restored backups,
# Or if the last shutdown was not normal or immediate.
Recover database using backup controlfile
# Database can now be opened zeroing the online logs.
Alter database open resetlogs;
# Commands to add tempfiles to temporary tablespaces.
# Online tempfiles have complete space information.
# Other tempfiles may require adjustment.
Alter tablespace temp add tempfile 'd:/Oracle/oradata/ora92/temp01.dbf'
Size 41943040 reuse autoextend off;
# End of tempfile additions.
#

If the control file is lost, you can use the following script to create a new control file.

Of course, you can also copy the file directly for backup, but if there is a change in the copy, the control file will be wrong. The above two methods first Oracle will read the file to the memory, back up the data from the memory to ensure the consistency of the control file.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.