alter system backup controlfile to trace內容詳解
---下面透過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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- recover database using backup controlfile理解Database
- ALTER SYSTEM FLUSH BUFFER_POOL
- Chromium Trace and Perfetto使用詳解
- Windows登錄檔內容詳解Windows
- MyBatis 核心配置檔案詳細內容詳解MyBatis
- 2.7.6.2.1 ALTER SYSTEM SET語句中的SCOPE子句
- Java核心內容面試題詳解Java面試題
- 轉載:System:System.arraycopy方法詳解
- alter system set event和set events的區別
- [20231023]備庫與alter system flush buffer_cache.txt
- 最強微服務部署工具——Docker內容詳解微服務Docker
- 詳解C++中繼承的基本內容C++中繼繼承
- python實現修改xml檔案內容詳解PythonXML
- CSS進階內容—盒子和陰影詳解CSS
- CSS進階內容—浮動和定位詳解CSS
- 微信開發:wx_sample.php內容詳解PHP
- alter system set ... scope=... 中的scope的含義是什麼?
- 『言善信』Fiddler工具 — 2、HTTP請求內容詳解HTTP
- DataGridView設定單元格的提示內容ToolTip詳解View
- [重慶思莊每日技術分享]-ORA-1142 signalled during: ALTER DATABASE END BACKUPDatabase
- WatchOS 7更新了哪些內容?WatchOS 7更新跳舞模式詳解模式
- jQuery滑鼠滑過表格標題切換表格內容詳解jQuery
- 報錯內容解決
- ORACLE之手動註冊監聽listener。alter system set local_listener="XXX"Oracle
- 智慧養老包含哪些內容?最新智慧養老系統詳解
- 網站漏洞滲透測試服務內容詳情見解網站
- Linux /etc/shadow 超詳細內容解析Linux
- PbootCMS模板內容詳情頁標籤呼叫boot
- docker-compose 配置檔案內容詳解以及常用命令介紹Docker
- AIGC內容風控解決方案AIGC
- MySQL 資料庫 ALTER命令講解MySql資料庫
- Java 內部類詳解Java
- Java內部類詳解Java
- 影片講解:PX-Backup安裝
- 全面解讀Http(HTTP內容分發)HTTP
- Java內部類詳解--匿名內部類Java
- python爬蟲利器 scrapy和scrapy-redis 詳解一 入門demo及內容解析Python爬蟲Redis
- Controlfile 重建控制檔案 noresetlogs, resetlogs..
- Java 內部類使用詳解Java