[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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 檔案與資料
- mv 命令 – 移動或改名檔案
- Linux基楚操作指引【檔案改名、檔案備份、檔案刪除】Linux
- 資料檔案合併與拆分
- SVN培訓筆記(下拉專案、同步修改、新增檔案、修改檔案、刪除檔案、改名檔案等)筆記
- [20210929]帶有回車的檔案如何改名.txt
- sra 資料轉成 fastq並改名AST
- Linux中隱藏檔案與資料夾Linux
- hadoop 資料夾檔案的建立與刪除Hadoop
- 新增多個資料夾進行同時改名
- [20191021]改名與namespace.txtnamespace
- 檔案系統與資料庫的優缺點資料庫
- 阿里Android開發規範:檔案與資料庫阿里Android資料庫
- 畸形檔案 資料夾
- Oracle 資料檔案回收Oracle
- win10批量檔案改名方法 win10系統下如何批量重新命名檔案Win10
- win10批次檔案改名方法 win10系統下如何批次重新命名檔案Win10
- 表空間與資料檔案的offline和online操作
- Laravel Homestead踩坑記3——資料庫與配置檔案Laravel資料庫
- [20210326]Disk file operations IO與檔案型資料庫.txt資料庫
- Oracle資料檔案和臨時檔案的管理Oracle
- git的gitignore檔案排除資料夾和檔案Git
- 修改Oracle資料檔名及資料檔案存放路徑Oracle
- 織夢資料庫配置檔案-DedeCMS織夢資料庫檔案在哪裡資料庫
- SQLServer移動資料檔案SQLServer
- 讀取資料夾檔案
- [20190410]dg建立臨時表檔案資料檔案.txt
- MySQL8.0.18資料庫新增資料檔案MySql資料庫
- MongoDB與MMAPV1相關的資料檔案簡述MongoDB
- C檔案與檔案的操作
- 12c pdb線上移動資料檔案或者重新命名資料檔案
- 帝國CMS資料庫配置檔案是哪個檔案?資料庫
- 【/proc/檔案淺析】另類辦法恢復資料檔案和控制檔案
- UAVStack之檔案資料歸集
- oracle資料庫的配置檔案Oracle資料庫
- java資料list寫入檔案Java
- 使用yaml檔案讀取資料YAML
- oracle 線上rename資料檔案Oracle