通過Trace檔案瞭解Oracle控制檔案

來源:互聯網
上載者:User

Oracle中的alter database backup controlfile to trace;命令用來將控制檔案備份為.trc尾碼的文字檔。這個檔案名稱的格式為:sid_ora_pid.trc,儲存在參數user_dump_dest指定的位置。這個檔案裡儲存的是建立新控制檔案的SQL,我們可以通過它來大概瞭解一下控制檔案裡都有那些內容。 orcl@ORCL>select * from v$version;

BANNER
----------------------------------------------------------------
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
PL/SQL Release 9.2.0.1.0 - Production
CORE 9.2.0.1.0 Production
TNS for 32-bit Windows: Version 9.2.0.1.0 - Production
NLSRTL Version 9.2.0.1.0 - Production
orcl@ORCL>show parameter user_dump_dest;NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
user_dump_dest string D:\oracle\admin\orcl\udump
orcl@ORCL>alter database backup controlfile to trace;

Database altered.

我們在D:\oracle\admin\orcl\udump這個目錄下找到最新產生的那個檔案就是剛才對控制檔案的備份。
這個檔案中的內容:

1.注釋

*** SESSION ID:(9.5) 2008-03-18 20:40:22.000
*** 2008-03-18 20:40:22.000
# The following are current System-scope REDO Log Archival related
# parameters and can be included in the database initialization file.
#
# LOG_ARCHIVE_DEST=''
# LOG_ARCHIVE_DUPLEX_DEST=''
#
# LOG_ARCHIVE_FORMAT=ARC%S.%T
# REMOTE_ARCHIVE_ENABLE=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\RDBMS'
# LOG_ARCHIVE_DEST_1='MANDATORY NOREOPEN NODELAY'
# LOG_ARCHIVE_DEST_1='ARCH NOAFFIRM 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 should be used only if
# the current versions of all online logs are available. The second
# set opens the database with the RESETLOGS option and should be used
# if online logs are unavailable.
# The appropriate set of statements can be copied from the trace into
# a script file, edited as necessary, and executed when there is a
# need to re-create the control file.
#
2.NORESETLOGS case SQL(包含資料庫的記錄檔和資料檔案的物理位置和大小等資訊)

***在聯機日誌可用的情況下使用下邊這些命令重新構建控制檔案

# 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 "ORCL" NORESETLOGS NOARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 50
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 1
MAXLOGHISTORY 226
LOGFILE
GROUP 1 'D:\ORACLE\ORADATA\ORCL\REDO01.LOG' SIZE 100M,
GROUP 2 'D:\ORACLE\ORADATA\ORCL\REDO02.LOG' SIZE 100M,
GROUP 3 'D:\ORACLE\ORADATA\ORCL\REDO03.LOG' SIZE 100M
-- STANDBY LOGFILE
DATAFILE
'D:\ORACLE\ORADATA\ORCL\SYSTEM01.DBF',
'D:\ORACLE\ORADATA\ORCL\UNDOTBS01.DBF',
'D:\ORACLE\ORADATA\ORCL\CWMLITE01.DBF',
'D:\ORACLE\ORADATA\ORCL\DRSYS01.DBF',
'D:\ORACLE\ORADATA\ORCL\EXAMPLE01.DBF',
'D:\ORACLE\ORADATA\ORCL\INDX01.DBF',
'D:\ORACLE\ORADATA\ORCL\ODM01.DBF',
'D:\ORACLE\ORADATA\ORCL\TOOLS01.DBF',
'D:\ORACLE\ORADATA\ORCL\USERS01.DBF',
'D:\ORACLE\ORADATA\ORCL\XDB01.DBF',
'D:\ORACLE\ORADATA\ORCL\SCOTT_TABLAESPACE.ORA',
'D:\ORACLE\ORADATA\ORCL\TEST.DBF'
CHARACTER SET ZHS16GBK
;
**********rman資訊*******

# Configure RMAN configuration record 1
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('RETENTION POLICY','TO RECOVERY WINDOW OF 7 DAYS');
# Configure RMAN configuration record 2
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CONTROLFILE AUTOBACKUP','ON');

******其它資訊******

# 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;
# 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\ORCL\TEMP01.DBF'
SIZE 41943040 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
# End of tempfile additions.
3。RESETLOGS case SQL

在聯機日誌停用情況下使用這些SQL構造控制檔案。所有的聯機日誌將丟失,所有的備份都失效。包含的資訊同上邊。

# 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 "ORCL" RESETLOGS NOARCHIVELOG
-- SET STANDBY TO MAXIMIZE PERFORMANCE
MAXLOGFILES 50
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 1
MAXLOGHISTORY 226
LOGFILE
GROUP 1 'D:\ORACLE\ORADATA\ORCL\REDO01.LOG' SIZE 100M,
GROUP 2 'D:\ORACLE\ORADATA\ORCL\REDO02.LOG' SIZE 100M,
GROUP 3 'D:\ORACLE\ORADATA\ORCL\REDO03.LOG' SIZE 100M
-- STANDBY LOGFILE
DATAFILE
'D:\ORACLE\ORADATA\ORCL\SYSTEM01.DBF',
'D:\ORACLE\ORADATA\ORCL\UNDOTBS01.DBF',
'D:\ORACLE\ORADATA\ORCL\CWMLITE01.DBF',
'D:\ORACLE\ORADATA\ORCL\DRSYS01.DBF',
'D:\ORACLE\ORADATA\ORCL\EXAMPLE01.DBF',
'D:\ORACLE\ORADATA\ORCL\INDX01.DBF',
'D:\ORACLE\ORADATA\ORCL\ODM01.DBF',
'D:\ORACLE\ORADATA\ORCL\TOOLS01.DBF',
'D:\ORACLE\ORADATA\ORCL\USERS01.DBF',
'D:\ORACLE\ORADATA\ORCL\XDB01.DBF',
'D:\ORACLE\ORADATA\ORCL\SCOTT_TABLAESPACE.ORA',
'D:\ORACLE\ORADATA\ORCL\TEST.DBF'
CHARACTER SET ZHS16GBK
;
# Configure RMAN configuration record 1
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('RETENTION POLICY','TO RECOVERY WINDOW OF 7 DAYS');
# Configure RMAN configuration record 2
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CONTROLFILE AUTOBACKUP','ON');
# 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\ORCL\TEMP01.DBF'
SIZE 41943040 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
# End of tempfile additions.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.