Oracle控制文件

来源:http://www.cnblogs.com/baisha/archive/2017/01/17/6292943.html
-Advertisement-
Play Games

什麼是控制文件 oracle控制文件是一個跟蹤資料庫的物理組成的二進位文件,僅與一個資料庫相關聯,每個資料庫有唯一的控制文件,可以維護多個相同的拷貝。控制文件是oracle資料庫用來查找資料庫文件,並從總體上管理漱口狀態的根文件。控制文件包含以下信息: 資料庫名稱和資料庫唯一標識符(DBID) 創建 ...


  1. 什麼是控制文件

oracle控制文件是一個跟蹤資料庫的物理組成的二進位文件,僅與一個資料庫相關聯,每個資料庫有唯一的控制文件,可以維護多個相同的拷貝。控制文件是oracle資料庫用來查找資料庫文件,並從總體上管理漱口狀態的根文件。控制文件包含以下信息:

  • 資料庫名稱和資料庫唯一標識符(DBID)
  • 創建資料庫的時間戳
  • 有關資料庫文件、聯機重做日誌、歸檔日誌的信息
  • 表空間信息
  • RMAN備份信息

控制文件的作用

  • 包含數據文件、重做日誌文件等打開資料庫所需要的信息。控制文件跟蹤資料庫的結構變化。例如,當管理員添加、重命名、刪除數據文件或重做日誌文件是,資料庫將更新控制文件,記錄相應的修改。
  • 包含資料庫打開時需要使用的元數據。例如,控制文件中包含包括檢查點在內等用於恢複數據庫所需的信息。在實例恢復過程中,檢查點能指示出redo stream需要的起始SCN。每次提交更改之前檢查點確保SCN已保存到磁碟上的數據文件中。至少每隔三秒,檢查點進程會在控制文件中記錄有關重做日誌中的檢查點的位置。

在資料庫使用期間,oracle資料庫不斷讀取和寫入控制文件,並且只要資料庫處於打開狀態,控制文件就必須是可用的,以便可以寫入。例如,恢複數據庫涉及控制文件中讀取資料庫中包含的所有數據文件名稱。其他的操作,如添加數據文件,會更新存儲在控制文件中的信息。

控制文件的結構

與資料庫相關的信息存儲在控制文件中的不同部分中。每個部分是有關資料庫的某個方面的一組記錄。例如,控制文件中有一個部分追蹤數據文件,並包含你一個記錄集合,每個數據文件有一條記錄。每個部分存儲在多個邏輯控制文件塊中。同一部分可以跨越多個塊。

控制文件中包含以下類型的記錄:

  • 迴圈重用記錄

這些記錄包含可以被覆蓋的非關鍵信息。當所有可用的記錄槽用完時,資料庫需要擴展控制文件或覆蓋最舊的記錄,以便為新記錄騰出空間。迴圈重用記錄可以刪除,並且不會影響資料庫運行,如:RMAN備份記錄,歸檔日誌歷史信息等信息。

  • 非迴圈重用記錄

這些記錄包含不經常更改且不能被覆蓋的關鍵信息。包括表空間、數據文件、聯機重做日誌文件、重做線程。oracle資料庫絕不會重用這些記錄,除非從表空間中刪除相應的對象。

  1. 如何查看控制文件

方法一,直接查看v$controlfile_record_section視圖。

v$controlfile_record_section的數據來源於X$KCCRS內部表,其定義如下:

select inst_id,

decode(indx,0,'DATABASE',1,'CKPT PROGRESS',2,'REDO THREAD',

3,'REDO LOG',4,'DATAFILE',5,'FILENAME',6,'TABLESPACE',

7,'TEMPORARY FILENAME',8,'RMAN CONFIGURATION',9,'LOG HISTORY',

10,'OFFLINE RANGE',11,'ARCHIVED LOG',12,'BACKUP SET',

13,'BACKUP PIECE',14,'BACKUP DATAFILE',15,'BACKUP REDOLOG',

16,'DATAFILE COPY',17,'BACKUP CORRUPTION',18,'COPY CORRUPTION',

19,'DELETED OBJECT',20,'PROXY COPY',21,'BACKUP SPFILE',

23,'DATABASE INCARNATION',24,'FLASHBACK LOG',25,'RECOVERY DESTINATION',

26,'INSTANCE SPACE RESERVATION',27,'REMOVABLE RECOVERY FILES',

28,'RMAN STATUS',29,'THREAD INSTANCE NAME MAPPING',30,'MTTR',

31,'DATAFILE HISTORY',32,'STANDBY DATABASE MATRIX',

33,'GUARANTEED RESTORE POINT',34,'RESTORE POINT',

35,'DATABASE BLOCK CORRUPTION',36,'ACM OPERATION',

37,'FOREIGN ARCHIVED LOG','UNKNOWN') TYPE,

rsrsz,

rsnum,

rsnus,

rsiol,

rsilw,

rsrlw

from x$kccrs

where indx not in (22);

為什麼使用上述定義,可以通過查看$ORACLE_HOME/rdbms/admin/dbmsbkrs.sql得知,該腳本是DBMS_BACKUP_RESTORE包的創建代碼,如果資料庫中不存在DBMS_BACKUP_RESTORE包,可以使用該腳本創建。其中有一段對類型定義常量的部分如下:

--********************************

-- Controlfile Sizing Procedures--

--******************************--

 

-- These procedures are used to resize a record section of the controlfile

-- and to calculate the size of a controlfile having specified counts of

-- records of each type.

--

-- Valid record types are defined as the following constants:

 

RTYP_DB_INFO constant binary_integer := 0;

RTYP_CKPTPROG constant binary_integer := 1;

RTYP_THREAD constant binary_integer := 2;

RTYP_LOGFILE constant binary_integer := 3;

RTYP_DATAFILE constant binary_integer := 4;

RTYP_FILENAME constant binary_integer := 5;

RTYP_TABLESPACE constant binary_integer := 6;

RTYP_RESERVED1 constant binary_integer := 7;

RTYP_TEMPFILE constant binary_integer := 7;

RTYP_RMAN_CONFIGURATION constant binary_integer := 8;

RTYP_LOG_HISTORY constant binary_integer := 9;

RTYP_OFFLINE_RANGE constant binary_integer := 10;

RTYP_ARCHIVED_LOG constant binary_integer := 11;

RTYP_BACKUP_SET constant binary_integer := 12;

RTYP_BACKUP_PIECE constant binary_integer := 13;

RTYP_BACKUP_DFILE constant binary_integer := 14;

RTYP_BACKUP_LOG constant binary_integer := 15;

RTYP_DFILE_COPY constant binary_integer := 16;

RTYP_BACKUP_DFILE_CORR constant binary_integer := 17;

RTYP_DFILE_COPY_CORR constant binary_integer := 18;

RTYP_DELETED_OBJECT constant binary_integer := 19;

RTYP_RESERVED3 constant binary_integer := 20;

RTYP_PROXY constant binary_integer := 20;

RTYP_RESERVED4 constant binary_integer := 21;

RTYP_BACKUP_SPFILE constant binary_integer := 21;

RTYP_DB2 constant binary_integer := 22;

RTYP_INCARNATION constant binary_integer := 23;

RTYP_FLASHBACK constant binary_integer := 24;

RTYP_RA_INFO constant binary_integer := 25;

RTYP_INST_RSVT constant binary_integer := 26;

RTYP_AGED_FILES constant binary_integer := 27;

RTYP_RMAN_STATUS constant binary_integer := 28;

RTYP_THREAD_INST constant binary_integer := 29;

RTYP_MTR constant binary_integer := 30;

RTYP_DFH constant binary_integer := 31;

RTYP_SDM constant binary_integer := 32;

RTYP_RSP constant binary_integer := 33;

RTYP_NRR constant binary_integer := 34;

RTYP_BLOCK_CORRUPTION constant binary_integer := 35;

RTYP_ACM_OPERATION constant binary_integer := 36;

RTYP_FOREIGN_ARCHIVED_LOG constant binary_integer := 37;

通過上面代碼與v$controlfile_record_section視圖的創建代碼比較就能明白了。

方法二,通過trace文件查看控制文件的創建腳本

--生成trace文件

alter database backup controlfile to trace;

--查看trace文件位置

SELECT a.VALUE || b.symbol || c.instance_name || '_ora_' || d.spid || '.trc' trace_file

FROM (SELECT VALUE FROM v$parameter WHERE name = 'user_dump_dest') a,

(SELECT SUBSTR(VALUE, -6, 1) symbol FROM v$parameter WHERE name = 'user_dump_dest') b,

(SELECT instance_name FROM v$instance) c,

(SELECT spid FROM v$session s, v$process p, v$mystat m WHERE

s.paddr = p.addr AND s.sid = m.sid AND m.statistic# = 0) d;

 

其中創建控制文件的部分如下所示:

CREATE CONTROLFILE REUSE DATABASE "ORACL" RESETLOGS NOARCHIVELOG

MAXLOGFILES 16

MAXLOGMEMBERS 3

MAXDATAFILES 100

MAXINSTANCES 8

MAXLOGHISTORY 292

LOGFILE

GROUP 1 '/u01/app/oracle/oradata/oracl/redo01.log' SIZE 50M BLOCKSIZE 512,

GROUP 2 '/u01/app/oracle/oradata/oracl/redo02.log' SIZE 50M BLOCKSIZE 512,

GROUP 3 '/u01/app/oracle/oradata/oracl/redo03.log' SIZE 50M BLOCKSIZE 512

-- STANDBY LOGFILE

DATAFILE

'/u01/app/oracle/oradata/oracl/system01.dbf',

'/u01/app/oracle/oradata/oracl/sysaux01.dbf',

'/u01/app/oracle/oradata/oracl/undotbs01.dbf',

'/u01/app/oracle/oradata/oracl/users01.dbf'

CHARACTER SET ZHS16GBK;

標紅的參數需要特別註意

MAXDATAFILES

這個參數是保存在控制文件里的,在DBCA創建實例的時候可以指定該值的大小。

官方解釋:

The MAXDATAFILES option of CREATE DATABASE determines the number of data files a database can have. With Oracle Real Application Clusters, databases tend to have more data files and log files than an exclusive mounted database.

MAXDATAFILES與DB_FILES參數的關係可以參見MOS文檔:MAXDATAFILES and DB_FILES Parameters (文檔 ID 119507.1)

MAXINSTANCES

The MAXINSTANCES optionof CREATE DATABASE limits the number of instances that can access a databaseconcurrently. The default value for this option underz/OS is 15. Set MAXINSTANCES to a value greater than the maximum numberof instances you expect to run concurrently.

MAXLOGFILESMAXLOGMEMBERS

The MAXLOGFILES option of CREATE DATABASE specifies the maximum number of redo log groups that can be created for the database. The MAXLOGMEMBERS option specifies the maximum number of members or number of copies per group. Set MAXLOGFILES to the maximum number of instances you plan to run concurrently multiplied by the maximum anticipated number of groups per thread.

MAXLOGHISTORY

The MAXLOGHISTORY option of CREATE DATABASE specifies the maximum number of redolog files that can be recorded in the log history of the control file.The log history is used for automatic media recovery of Oracle Real ApplicationClusters.

For Oracle Real Application Clusters, set MAXLOGHISTORY to a large value, such as 100. The control file can then store information about this number of redo log files. When the log history exceeds this limit, the Oracle server overwrites the oldest entries in the log history. The default for MAXLOGHISTORY is 0 (zero), which disables log history.

  1. 不重建控制文件清理控制文件中的記錄

這裡指清除迴圈重用記錄。

方法一,通過重建控制文件或設置control_file_record_keep_time=0。

方法二,使用execute sys.dbms_backup_restore.resetCfileSection清理。

清理v$archived_log對應的記錄,執行execute sys.dbms_backup_restore.resetCfileSection(11)

清理v$rman_status對應的記錄,執行execute sys.dbms_backup_restore.resetCfileSection(28);

使用參數請參照上一部分介紹。

註:請勿隨意在生產環境上執行!

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • httpd yum install httpd -y systemctl status httpd systemctl start httpd systemctl stop firewalld Mariadb yum install mariadb-server mariadb-client -y ...
  • SQL Server 其實從SQL Server 2005開始,也提供了類似ORACLE中固定執行計劃的功能,只是好像很少人使用這個功能。當然在SQL Server中不叫"固定執行計劃"這個概念,而是叫"執行計劃指南"(Plan Guide 很多翻譯是計劃指南,個人覺得執行計劃指南稍好一些)。當然兩... ...
  • 最近在做oracle相關的項目,剛接觸oracle,與sqlserver語法上還是有區別的 sqlserver : 示例:FX+當前年月日+00001 如下圖流水號實力所示 原理: 首先 'FX'是固定的,獲取當前年月日方法在sqlserver中分別是: 1.年:YEAR(GETDATE()) 2. ...
  • 一、博客前言 自接觸學習MySQL已有一段時間了,對於MySQL的基礎知識還是有一定的瞭解的。在這一路學習過來,每次不管看書還是網上看的資料,對於MySQL數據類型中的時間日期類型總是一掃而過,不曾停下來認認真真的研究學習。最近在圖書館借了一本關於MysQL的書籍,打算全面的學習研究一遍。 在之前, ...
  • 本篇源碼基於趙星對Spark 1.3.1解析進行整理。話說,我不認為我這下文源碼的排版很好,不能適應的還是看總結吧。 雖然1.3.1有點老了,但對於standalone模式下的Master、Worker和劃分stage的理解是很有幫助的。 總結: master和worker都要創建ActorSyst ...
  • 通過授予和拒絕(Grant/Deny)命令控制用戶的許可權,只能控制用戶對資料庫對象的訪問許可權,這意味著,用戶訪問的粒度是對象整體,可以是一個數據表,或視圖等,用戶要麼能夠訪問資料庫對象,要麼沒有許可權訪問,就是說,一個資料庫對象,通過授予和拒絕用戶的許可權/角色(Permission或Role),無法使 ...
  • 一、Mysql-Proxy原理 Mysql-Proxy是一個處於你的client端和Mysql Server端之間的一個簡單程式,它可以監測、分析和改變他們的通信。它使用靈活沒有限制,常見的用途包括:負載平衡,故障、查詢分析,查詢過濾和修改等等。 Mysql -Proxy就是這麼一個中間層代理,簡單 ...
  • 翻譯MySQL官方文檔隨筆——Create User Syntax MySQL Create User Syntax mysql創建用戶 mysql create user ...
一周排行
    -Advertisement-
    Play Games
  • 前言 本文介紹一款使用 C# 與 WPF 開發的音頻播放器,其界面簡潔大方,操作體驗流暢。該播放器支持多種音頻格式(如 MP4、WMA、OGG、FLAC 等),並具備標記、實時歌詞顯示等功能。 另外,還支持換膚及多語言(中英文)切換。核心音頻處理採用 FFmpeg 組件,獲得了廣泛認可,目前 Git ...
  • OAuth2.0授權驗證-gitee授權碼模式 本文主要介紹如何筆者自己是如何使用gitee提供的OAuth2.0協議完成授權驗證並登錄到自己的系統,完整模式如圖 1、創建應用 打開gitee個人中心->第三方應用->創建應用 創建應用後在我的應用界面,查看已創建應用的Client ID和Clien ...
  • 解決了這個問題:《winForm下,fastReport.net 從.net framework 升級到.net5遇到的錯誤“Operation is not supported on this platform.”》 本文內容轉載自:https://www.fcnsoft.com/Home/Sho ...
  • 國內文章 WPF 從裸 Win 32 的 WM_Pointer 消息獲取觸摸點繪製筆跡 https://www.cnblogs.com/lindexi/p/18390983 本文將告訴大家如何在 WPF 裡面,接收裸 Win 32 的 WM_Pointer 消息,從消息裡面獲取觸摸點信息,使用觸摸點 ...
  • 前言 給大家推薦一個專為新零售快消行業打造了一套高效的進銷存管理系統。 系統不僅具備強大的庫存管理功能,還集成了高性能的輕量級 POS 解決方案,確保頁面載入速度極快,提供良好的用戶體驗。 項目介紹 Dorisoy.POS 是一款基於 .NET 7 和 Angular 4 開發的新零售快消進銷存管理 ...
  • ABP CLI常用的代碼分享 一、確保環境配置正確 安裝.NET CLI: ABP CLI是基於.NET Core或.NET 5/6/7等更高版本構建的,因此首先需要在你的開發環境中安裝.NET CLI。這可以通過訪問Microsoft官網下載並安裝相應版本的.NET SDK來實現。 安裝ABP ...
  • 問題 問題是這樣的:第三方的webapi,需要先調用登陸介面獲取Cookie,訪問其它介面時攜帶Cookie信息。 但使用HttpClient類調用登陸介面,返回的Headers中沒有找到Cookie信息。 分析 首先,使用Postman測試該登陸介面,正常返回Cookie信息,說明是HttpCli ...
  • 國內文章 關於.NET在中國為什麼工資低的分析 https://www.cnblogs.com/thinkingmore/p/18406244 .NET在中國開發者的薪資偏低,主要因市場需求、技術棧選擇和企業文化等因素所致。歷史上,.NET曾因微軟的閉源策略發展受限,儘管後來推出了跨平臺的.NET ...
  • 在WPF開發應用中,動畫不僅可以引起用戶的註意與興趣,而且還使軟體更加便於使用。前面幾篇文章講解了畫筆(Brush),形狀(Shape),幾何圖形(Geometry),變換(Transform)等相關內容,今天繼續講解動畫相關內容和知識點,僅供學習分享使用,如有不足之處,還請指正。 ...
  • 什麼是委托? 委托可以說是把一個方法代入另一個方法執行,相當於指向函數的指針;事件就相當於保存委托的數組; 1.實例化委托的方式: 方式1:通過new創建實例: public delegate void ShowDelegate(); 或者 public delegate string ShowDe ...