---下面通过alter system backup controlfile to trace抽取的控制文件源本,讲得很不错
-- 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.
--
-----注解:重建控制控制文件分为两种类型:noresetlogs和resetlogs。
----- 二者区别:前者主要用于所在在线日志可以用,后者相反,就是在线日志不可用
-- Set #1. NORESETLOGS case
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.---重建后rman所有使用的数据就不能用了,所以马上进行备份方为安全
-- Additional logs may be required for media recovery of offline
-- Use this only if the current versions of all online logs are
-- available.
-- After mounting the created controlfile, the following SQL ---这个是说,mount了重建的控制文件之后,如下sql会把数据库加载到一个合适的保护模式(dg)
-- statement will place the database in the appropriate
-- protection mode:
-- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
--重建控制文件数据库在nomount状态下
STARTUP NOMOUNT
----重建控制文件
CREATE CONTROLFILE REUSE DATABASE "ONLY" NORESETLOGS ARCHIVELOG
MAXLOGFILES 192
MAXLOGMEMBERS 3
MAXDATAFILES 1024
MAXINSTANCES 32
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '+ASM1/only/redo01.log' SIZE 50M,
GROUP 2 '+ASM1/only/redo02.log' SIZE 50M,
GROUP 3 '+ASM1/only/redo03.log' SIZE 50M,
GROUP 4 '+ASM1/only/redo04.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'+ASM1/only/system01.dbf',
'+ASM1/only/undotbs01.dbf',
'+ASM1/only/sysaux01.dbf',
'+ASM1/only/users01.dbf',
'+ASM1/only/undotbs02.dbf'
CHARACTER SET WE8ISO8859P1
;
----下列讲的啥,呵呵。一些重建化身表的命令,log名字以下必须改变到磁盘已存在的文件上;每个分支的任何一个log file,用它们可以重建化身记录,
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
---对应上面,这是具体的命令
-- ALTER DATABASE REGISTER LOGFILE '+ASM1/only/1_1_562360180.dbf';
-- ALTER DATABASE REGISTER LOGFILE '+ASM1/only/1_1_716018174.dbf';
---如果数据文件使用了用来还原的备份,也可能是上次关机没用采用常规normal或immediate方式;此时需要你对此进行恢复;
-- 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 '+ASM1/only/temp01.dbf'
SIZE 20971520 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
-- End of tempfile additions.
--
---这是第二种类型,resetlogs,在生产中这种非常多的。就是在线日志也损坏了(可能是介质损坏)
-- Set #2. RESETLOGS case
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- The contents of online logs will be lost and all backups will ---在线日志的内容找不到了,所有的备份变得无效了
-- be invalidated. Use this only if online logs are damaged.
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
-- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ONLY" RESETLOGS ARCHIVELOG
MAXLOGFILES 192
MAXLOGMEMBERS 3
MAXDATAFILES 1024
MAXINSTANCES 32
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '+ASM1/only/redo01.log' SIZE 50M,
GROUP 2 '+ASM1/only/redo02.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'+ASM1/only/system01.dbf',
'+ASM1/only/undotbs01.dbf',
'+ASM1/only/sysaux01.dbf',
'+ASM1/only/users01.dbf',
'+ASM1/only/undotbs02.dbf'
CHARACTER SET WE8ISO8859P1
;
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '+ASM1/only/1_1_562360180.dbf';
-- ALTER DATABASE REGISTER LOGFILE '+ASM1/only/1_1_716018174.dbf';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
------以上为我何没有一句句注解,作用同noresetlogs是一样的,故未再作注解,请看下面,这是重头戏
-----利用备份的控制文件恢复数据库
RECOVER DATABASE USING BACKUP CONTROLFILE
---创建thread 2对应的日志文件(重用),请注意reuse
-- Create log files for threads other than thread one.
ALTER DATABASE ADD LOGFILE THREAD 2
GROUP 3 '+ASM1/only/redo03.log' SIZE 50M REUSE,
GROUP 4 '+ASM1/only/redo04.log' SIZE 50M REUSE;
---现在数据库可能打开了,但在线日志内容全部是新的,也就是说里面是空的
-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;
---下面同noresetlogs一样,不再注解
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '+ASM1/only/temp01.dbf'
SIZE 20971520 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
-- End of tempfile additions.
-- 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.
--
-----注解:重建控制控制文件分为两种类型:noresetlogs和resetlogs。
----- 二者区别:前者主要用于所在在线日志可以用,后者相反,就是在线日志不可用
-- Set #1. NORESETLOGS case
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.---重建后rman所有使用的数据就不能用了,所以马上进行备份方为安全
-- Additional logs may be required for media recovery of offline
-- Use this only if the current versions of all online logs are
-- available.
-- After mounting the created controlfile, the following SQL ---这个是说,mount了重建的控制文件之后,如下sql会把数据库加载到一个合适的保护模式(dg)
-- statement will place the database in the appropriate
-- protection mode:
-- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
--重建控制文件数据库在nomount状态下
STARTUP NOMOUNT
----重建控制文件
CREATE CONTROLFILE REUSE DATABASE "ONLY" NORESETLOGS ARCHIVELOG
MAXLOGFILES 192
MAXLOGMEMBERS 3
MAXDATAFILES 1024
MAXINSTANCES 32
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '+ASM1/only/redo01.log' SIZE 50M,
GROUP 2 '+ASM1/only/redo02.log' SIZE 50M,
GROUP 3 '+ASM1/only/redo03.log' SIZE 50M,
GROUP 4 '+ASM1/only/redo04.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'+ASM1/only/system01.dbf',
'+ASM1/only/undotbs01.dbf',
'+ASM1/only/sysaux01.dbf',
'+ASM1/only/users01.dbf',
'+ASM1/only/undotbs02.dbf'
CHARACTER SET WE8ISO8859P1
;
----下列讲的啥,呵呵。一些重建化身表的命令,log名字以下必须改变到磁盘已存在的文件上;每个分支的任何一个log file,用它们可以重建化身记录,
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
---对应上面,这是具体的命令
-- ALTER DATABASE REGISTER LOGFILE '+ASM1/only/1_1_562360180.dbf';
-- ALTER DATABASE REGISTER LOGFILE '+ASM1/only/1_1_716018174.dbf';
---如果数据文件使用了用来还原的备份,也可能是上次关机没用采用常规normal或immediate方式;此时需要你对此进行恢复;
-- 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 '+ASM1/only/temp01.dbf'
SIZE 20971520 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
-- End of tempfile additions.
--
---这是第二种类型,resetlogs,在生产中这种非常多的。就是在线日志也损坏了(可能是介质损坏)
-- Set #2. RESETLOGS case
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- The contents of online logs will be lost and all backups will ---在线日志的内容找不到了,所有的备份变得无效了
-- be invalidated. Use this only if online logs are damaged.
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
-- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ONLY" RESETLOGS ARCHIVELOG
MAXLOGFILES 192
MAXLOGMEMBERS 3
MAXDATAFILES 1024
MAXINSTANCES 32
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '+ASM1/only/redo01.log' SIZE 50M,
GROUP 2 '+ASM1/only/redo02.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'+ASM1/only/system01.dbf',
'+ASM1/only/undotbs01.dbf',
'+ASM1/only/sysaux01.dbf',
'+ASM1/only/users01.dbf',
'+ASM1/only/undotbs02.dbf'
CHARACTER SET WE8ISO8859P1
;
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '+ASM1/only/1_1_562360180.dbf';
-- ALTER DATABASE REGISTER LOGFILE '+ASM1/only/1_1_716018174.dbf';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
------以上为我何没有一句句注解,作用同noresetlogs是一样的,故未再作注解,请看下面,这是重头戏
-----利用备份的控制文件恢复数据库
RECOVER DATABASE USING BACKUP CONTROLFILE
---创建thread 2对应的日志文件(重用),请注意reuse
-- Create log files for threads other than thread one.
ALTER DATABASE ADD LOGFILE THREAD 2
GROUP 3 '+ASM1/only/redo03.log' SIZE 50M REUSE,
GROUP 4 '+ASM1/only/redo04.log' SIZE 50M REUSE;
---现在数据库可能打开了,但在线日志内容全部是新的,也就是说里面是空的
-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;
---下面同noresetlogs一样,不再注解
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '+ASM1/only/temp01.dbf'
SIZE 20971520 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
-- End of tempfile additions.
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9240380/viewspace-659625/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9240380/viewspace-659625/