[20181102]資料檔案改名與awr.txt
[20181102]資料檔案改名與awr.txt
--//當資料檔案改名時,awr報表可能並不真實反應對應資料檔案,透過例子說明問題.
1.環境:
SCOTT@book> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
SCOTT@book> select * from v$dbfile;
FILE# NAME
------------ ----------------------------------------
4 /mnt/ramdisk/book/users01.dbf
3 /mnt/ramdisk/book/undotbs01.dbf
2 /mnt/ramdisk/book/sysaux01.dbf
1 /mnt/ramdisk/book/system01.dbf
5 /mnt/ramdisk/book/example01.dbf
6 /mnt/ramdisk/book/tea01.dbf
6 rows selected.
--//file#=6,name=/mnt/ramdisk/book/tea01.dbf
SCOTT@book> select * from DBA_HIST_DATAFILE;
DBID FILE# CREATION_CHANGE# FILENAME TS# TSNAME BLOCK_SIZE
------------ ------------ ---------------- ------------------------------- --- -------- ----------
1337401710 1 7 /mnt/ramdisk/book/system01.dbf 0 SYSTEM 8192
1337401710 2 1834 /mnt/ramdisk/book/sysaux01.dbf 1 SYSAUX 8192
1337401710 3 923328 /mnt/ramdisk/book/undotbs01.dbf 2 UNDOTBS1 8192
1337401710 4 16143 /mnt/ramdisk/book/users01.dbf 4 USERS 8192
1337401710 5 952916 /mnt/ramdisk/book/example01.dbf 6 EXAMPLE 8192
1337401710 6 13276257767 /mnt/ramdisk/book/tea01.dbf 7 TEA 8192
6 rows selected.
2.改名資料檔案看看.
SCOTT@book> alter database datafile 6 offline ;
Database altered.
SCOTT@book> recover datafile 6;
Media recovery complete.
$ mv /mnt/ramdisk/book/tea01.dbf /mnt/ramdisk/book/tea02.dbf
SCOTT@book> alter database rename file '/mnt/ramdisk/book/tea01.dbf' to '/mnt/ramdisk/book/tea02.dbf';
Database altered.
SCOTT@book> alter database datafile 6 online ;
Database altered.
--//改名成功.並且online.
3.建立awr的snapshot:
SCOTT@book> exec dbms_workload_repository.create_snapshot;
PL/SQL procedure successfully completed.
SCOTT@book> select * from DBA_HIST_DATAFILE;
DBID FILE# CREATION_CHANGE# FILENAME TS# TSNAME BLOCK_SIZE
------------ ------------ ---------------- ------------------------------- --- -------- ----------
1337401710 1 7 /mnt/ramdisk/book/system01.dbf 0 SYSTEM 8192
1337401710 2 1834 /mnt/ramdisk/book/sysaux01.dbf 1 SYSAUX 8192
1337401710 3 923328 /mnt/ramdisk/book/undotbs01.dbf 2 UNDOTBS1 8192
1337401710 4 16143 /mnt/ramdisk/book/users01.dbf 4 USERS 8192
1337401710 5 952916 /mnt/ramdisk/book/example01.dbf 6 EXAMPLE 8192
1337401710 6 13276257767 /mnt/ramdisk/book/tea01.dbf 7 TEA 8192
6 rows selected.
--//依舊是/mnt/ramdisk/book/tea01.dbf.
SCOTT@book> exec dbms_workload_repository.create_snapshot;
PL/SQL procedure successfully completed.
SCOTT@book> select snap_id,file#,filename from DBA_HIST_FILESTATXS where file#=6 and snap_id>=1230;
SNAP_ID FILE# FILENAME
------------ ------------ ----------------------------------------
1230 6 /mnt/ramdisk/book/tea01.dbf
1231 6 /mnt/ramdisk/book/tea01.dbf
1232 6 /mnt/ramdisk/book/tea01.dbf
1233 6 /mnt/ramdisk/book/tea01.dbf
--//你可以發現file#=6,在awr報表中看到的還是/mnt/ramdisk/book/tea01.dbf.
4.建立awr報表看看:
--//業務太少,看不到對該表空間的IO操作.
SCOTT@book> create table tt tablespace tea as select * from all_objects;
Table created.
SCOTT@book> update tt set owner=lower(owner), OBJECT_NAME=lower(OBJECT_NAME);
84761 rows updated.
SCOTT@book> commit ;
Commit complete.
SCOTT@book> update tt set owner=lower(owner), OBJECT_NAME=lower(OBJECT_NAME);
84761 rows updated.
SCOTT@book> commit ;
Commit complete.
SCOTT@book> exec dbms_workload_repository.create_snapshot;
PL/SQL procedure successfully completed.
--//再次建立awr報表:
File IO Stats DB/Inst: BOOK/book Snaps: 1233-1234
-> ordered by Tablespace, File
Tablespace Filename
------------------------ ----------------------------------------------------
Av Av Av 1-bk Av 1-bk Writes Buffer Av Buf
Reads Rds/s Rd(ms) Blks/Rd Rds/s Rd(ms) Writes avg/s Waits Wt(ms)
------- ------- ------- ------- ------- ------- ------- ------- -------- -------
SYSAUX /mnt/ramdisk/book/sysaux01.dbf
56 0 0.0 1.4 0 0.0 345 1 0 0.0
SYSTEM /mnt/ramdisk/book/system01.dbf
382 1 0.0 1.0 1 0.0 11 0 1 0.0
TEA /mnt/ramdisk/book/tea01.dbf
114 0 0.0 10.6 0 0.0 38 0 0 0.0
UNDOTBS1 /mnt/ramdisk/book/undotbs01.dbf
0 0 N/A N/A 0 N/A 25 0 0 0.0
------------------------------------------------------
--//可以發現記錄的資料檔案還是/mnt/ramdisk/book/tea01.dbf.
5.問題原因:
--//問題在於oracle並不是每次生成awr snapshot時更新DBA_HIST_DATAFILE檢視資訊.
SCOTT@book> select * from DBA_HIST_DATAFILE where file#=6;
DBID FILE# CREATION_CHANGE# FILENAME TS# TSNAME BLOCK_SIZE
------------ ------------ ---------------- --------------------------- --- ------ ----------
1337401710 6 13276257767 /mnt/ramdisk/book/tea01.dbf 7 TEA 8192
--//如果檢視包DBMS_WORKLOAD_REPOSITORY,可以發現如下資訊:
-- update_datafile_info()
-- This routine updates WRH$_DATAFILE rows for the datafile name and
-- tablespace name. Whenever this procedure runs, it will update these
-- values with the current information in the database.
--
-- This routine is useful when a datafile/tablespace has been moved or
-- renamed. As this change is generally not always captured in the next
-- snapshot in AWR. This change will be captured at max after some
-- (generally 50) snapshots. So the AWR and AWR report may be wrong with
-- respect to data file name or tablespace name for that duration.
--
-- To fix this problem, we can use this procedure to sync the table
-- WRH$_DATAFILE with the current information in database.
--
PROCEDURE update_datafile_info;
--//也就是一般在50個snapshot後,才會自動更新.可以手工呼叫這個包更新反應真實的情況:
SCOTT@book> exec dbms_workload_repository.update_datafile_info;
PL/SQL procedure successfully completed.
SCOTT@book> select * from DBA_HIST_DATAFILE where file#=6;
DBID FILE# CREATION_CHANGE# FILENAME TS# TSNAME BLOCK_SIZE
------------ ------------ ---------------- --------------------------- --- ------ ----------
1337401710 6 13276257767 /mnt/ramdisk/book/tea02.dbf 7 TEA 8192
SCOTT@book> select snap_id,file#,filename from DBA_HIST_FILESTATXS where file#=6 and snap_id>=1230;
SNAP_ID FILE# FILENAME
------------ ------------ ----------------------------------------
1230 6 /mnt/ramdisk/book/tea02.dbf
1231 6 /mnt/ramdisk/book/tea02.dbf
1232 6 /mnt/ramdisk/book/tea02.dbf
1233 6 /mnt/ramdisk/book/tea02.dbf
1234 6 /mnt/ramdisk/book/tea02.dbf
1235 6 /mnt/ramdisk/book/tea02.dbf
1236 6 /mnt/ramdisk/book/tea02.dbf
7 rows selected.
--//OK,現在更新過來的.這樣的情況也發生在12c 線上移動資料檔名的情況.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2218543/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 更改資料檔案位置或改名
- 將一個DB改名前的資料檔案備份加入改名後的資料庫資料庫
- 檔案與資料
- Oracle檔案改名實驗記錄Oracle
- mv 命令 – 移動或改名檔案
- Linux基楚操作指引【檔案改名、檔案備份、檔案刪除】Linux
- mysql5.7資料庫改名MySql資料庫
- 資料檔案合併與拆分
- JAVA檔案與資料流(1)Java
- SVN培訓筆記(下拉專案、同步修改、新增檔案、修改檔案、刪除檔案、改名檔案等)筆記
- Oracle 表空間與資料檔案Oracle
- 新增資料檔案與恢復cf
- sra 資料轉成 fastq並改名AST
- 建立資料庫檔案-日誌檔案-次要資料庫檔案資料庫
- 同時丟失控制檔案與資料檔案的恢復
- ASM與檔案系統之間copy資料檔案--檔案系統到ASMASM
- Python資料夾與檔案的操作Python
- 資料檔案
- PostgreSQL資料檔案災難恢復-解析與資料dumpSQL
- SQL Server資料庫檔案與Windows系統透明檔案壓縮SQLServer資料庫Windows
- 關於控制檔案與資料檔案頭資訊的說明(zt)
- oracle資料庫移動資料檔案、日誌檔案和控制檔案Oracle資料庫
- 資料庫檔案和檔案組資料庫
- Linux中隱藏檔案與資料夾Linux
- matlab 資料檔案MAT的讀與寫Matlab
- 資料庫引數檔案控制檔案日誌檔案資料檔案跟蹤檔案等8大檔案的字典資料庫
- 新增多個資料夾進行同時改名
- [20170221]資料檔案與檔案系統快取.txt快取
- 資料泵檔案
- 資料檔案誤刪--但有資料檔案的copy恢復
- win10批量檔案改名方法 win10系統下如何批量重新命名檔案Win10
- win10批次檔案改名方法 win10系統下如何批次重新命名檔案Win10
- 檔案系統與資料庫的優缺點資料庫
- hadoop 資料夾檔案的建立與刪除Hadoop
- 重新命名與遷移聯機資料檔案
- ORACLE 只讀資料檔案備份與恢復Oracle
- Oracle資料庫event事件與dump檔案介紹Oracle資料庫事件
- Delphi與Word(三)取得Word檔案的資料 (轉)