共計(jì) 4074 個(gè)字符,預(yù)計(jì)需要花費(fèi) 11 分鐘才能閱讀完成。
丸趣 TV 小編給大家分享一下 ARCHIVELOG 如何統(tǒng)計(jì)歸檔日志更準(zhǔn)確,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
做一個(gè)歸檔日志歷史記錄的一些信息,發(fā)現(xiàn)兩個(gè)視圖 v$archived_log 另一個(gè)是 V$log_history
下面我們先看下官方說(shuō)明:
v$archived_log 也就是這個(gè)視圖顯示的是控制文件中的信息,如果歸檔日志已經(jīng)刪除,name 列將顯示為空
V$ARCHIVED_LOG displays archived log information from the control file, including archive log names. An archive log record is inserted after the online redo log is successfully archived or cleared (name column is NULL if the log was cleared). If the log is archived twice, there will be two archived log records with the same THREAD#, SEQUENCE#, and FIRST_CHANGE#, but with a different name. An archive log record is also inserted when an archive log is restored from a backup set or a copy and whenever a copy of a log is made with the RMAN COPY command.
v$log_history 這個(gè)說(shuō)的比較簡(jiǎn)單,就是控制文件中的歷史信息
V$LOG_HISTORY displays log history information from the control file
那么它們有什么區(qū)別呢,或者說(shuō)誰(shuí)統(tǒng)計(jì)的個(gè)數(shù) 更準(zhǔn)確?(已做過(guò)統(tǒng)計(jì)測(cè)試,每天生成的歸檔日志數(shù)量不一致)
如下所示:
v$log_history
SQL SELECT trunc(first_time) Date ,
2 to_char(first_time, Dy) Day ,
3 count(1) Totals
4 FROM V$log_history where to_date(first_time) to_date(sysdate-15)
5 group by trunc(first_time), to_char(first_time, Dy)
6 Order by 1;
Date Day Totals
——— —— ———-
05-JUL-17 Wed 1
07-JUL-17 Fri 5
13-JUL-17 Thu 1
18-JUL-17 Tue 2
v$archived_log
SQL select trunc(completion_time) as date ,count(*) as Count ,(sum(blocks*block_size)/1024/1024) as MB from v$archived_log group by trunc(completion_time);
date Count MB
——— ———- ———-
18-JUL-17 3 28.9492188
07-JUL-17 7 229.628418
13-JUL-17 1 27.3828125
18-JUL-17 天,我手動(dòng)切了三次歸檔,如下
SQL alter system switch logfile;
System altered.
SQL /
System altered.
SQL /
System altered.
而 v$log_history 顯示的卻是 2 個(gè)
下面我們通過(guò) rman 來(lái)看 顯示結(jié)果 18 日這天是 2 個(gè),也就是統(tǒng)計(jì)信息跟 v$log_history 一樣
RMAN list archivelog all;
using target database control file instead of recovery catalog
List of Archived Log Copies for database with db_unique_name MYDB
=====================================================================
Key Thrd Seq S Low Time
——- —- ——- – ———
1 1 306 A 30-JUN-17
Name: /backup/mydbarchivelog/1_306_947429846.dbf
2 1 307 A 04-JUL-17
Name: /backup/mydbarchivelog/1_307_947429846.dbf
3 1 308 A 05-JUL-17
Name: /backup/mydbarchivelog/1_308_947429846.dbf
4 1 309 A 07-JUL-17
Name: /backup/mydbarchivelog/1_309_947429846.dbf
5 1 310 A 07-JUL-17
Name: /backup/mydbarchivelog/1_310_947429846.dbf
6 1 311 A 07-JUL-17
Name: /backup/mydbarchivelog/1_311_947429846.dbf
7 1 312 A 07-JUL-17
Name: /backup/mydbarchivelog/1_312_947429846.dbf
8 1 313 A 07-JUL-17
Name: /backup/mydbarchivelog/1_313_947429846.dbf
9 1 314 A 13-JUL-17
Name: /backup/mydbarchivelog/1_314_947429846.dbf
10 1 315 A 18-JUL-17
Name: /backup/mydbarchivelog/1_315_947429846.dbf
11 1 316 A 18-JUL-17
Name: /backup/mydbarchivelog/1_316_947429846.dbf
好,我們?cè)谕ㄟ^(guò)系統(tǒng)命令來(lái)看 , 卻是 3 個(gè)
SQL !ls -l /backup/mydbarchivelog
total 341292
-rw-r—– 1 oracle oinstall 27716608 Jun 28 16:33 1_303_947429846.dbf
-rw-r—– 1 oracle oinstall 1552896 Jun 29 11:10 1_304_947429846.dbf
-rw-r—– 1 oracle oinstall 20325888 Jun 30 09:21 1_305_947429846.dbf
-rw-r—– 1 oracle oinstall 19091968 Jul 7 13:58 1_306_947429846.dbf
-rw-r—– 1 oracle oinstall 22322176 Jul 7 13:58 1_307_947429846.dbf
-rw-r—– 1 oracle oinstall 21595136 Jul 7 13:58 1_308_947429846.dbf
-rw-r—– 1 oracle oinstall 48646656 Jul 7 15:15 1_309_947429846.dbf
-rw-r—– 1 oracle oinstall 47450112 Jul 7 15:49 1_310_947429846.dbf
-rw-r—– 1 oracle oinstall 41217024 Jul 7 16:00 1_311_947429846.dbf
-rw-r—– 1 oracle oinstall 40463360 Jul 7 22:00 1_312_947429846.dbf
-rw-r—– 1 oracle oinstall 28713472 Jul 13 11:10 1_313_947429846.dbf
-rw-r—– 1 oracle oinstall 30352896 Jul 18 12:57 1_314_947429846.dbf
-rw-r—– 1 oracle oinstall 1024 Jul 18 12:57 1_315_947429846.dbf
-rw-r—– 1 oracle oinstall 3072 Jul 18 12:57 1_316_947429846.dbf
什么情況呢,通過(guò)跟 rman 對(duì)比,我們可以看出,其實(shí)一個(gè)統(tǒng)計(jì)的是開(kāi)始時(shí)間,另一個(gè)統(tǒng)計(jì)的是結(jié)束(完成)時(shí)間,
開(kāi)始時(shí)間 也就是 rman 執(zhí)行命令 (list archivelog all) 查詢(xún)結(jié)果一致,另一個(gè)結(jié)束時(shí)間,也就跟操作系統(tǒng)中執(zhí)行命令(ls -lrt)結(jié)果一致,當(dāng)然他們統(tǒng)計(jì)的信息是在歸檔文件未刪除前是一致的,因?yàn)閯h除后,list archivelog all 和 ls -lrt’ 將不再顯示。
當(dāng)然,我們可以直接統(tǒng)計(jì)未刪除的歸檔日志大小
SQL –not delete archivelog sum size
SQL select ((sum(blocks * block_size)) /1024 /1024) as MB from v$archived_log where STANDBY_DEST = NO and deleted= NO
如果想要更準(zhǔn)確的結(jié)果(如果就是為了統(tǒng)計(jì)未刪除的信息)我們可以選擇 deleted= NO 或者 NAME IS NOT NULL.
以上是“ARCHIVELOG 如何統(tǒng)計(jì)歸檔日志更準(zhǔn)確”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注丸趣 TV 行業(yè)資訊頻道!