[20150902]rman的list archivelog指令.txt
--昨天同僚要查詢2015/8/13号日志,要确定需要檢查日志的範圍:
RMAN> list archivelog all completed between '2015-08-13' and '2015-08-13 18:00:00';
List of Archived Log Copies for database with db_unique_name xxxxxx
=====================================================================
Key Thrd Seq S Low Time
------- ---- ------- - -------------------
2497 1 1421 A 2015-08-13 07:12:52
Name: /u01/app/oracle/oradata/xxxxxx/archivelog/1_1421_862160568.dbf
--很奇怪!僅僅看見一個執行個體有檔案。另外的執行個體呢?增加一點時間:
RMAN> list archivelog all completed between '2015-08-13' and '2015-08-14 00:00:00';
2499 1 1422 A 2015-08-13 16:09:00
Name: /u01/app/oracle/oradata/xxxxxx/archivelog/1_1422_862160568.dbf
2498 2 1237 A 2015-08-13 07:12:50
Name: /u01/app/oracle/oradata/xxxxxx/archivelog/2_1237_862160568.dbf
--終于明白為什麼?主要是要了解rman指令list archivelog指令裡面的completed,表示完成的時間。而它顯示的Low Time。
--我上面的查詢實際上指在'2015-08-13' and '2015-08-13 18:00:00'這個時間段完成的日志。主要是單個日志檔案設定太大。
RMAN> list archivelog all completed between '2015-08-13' and '2015-08-14 06:00:00';
2501 1 1423 A 2015-08-13 20:44:16
Name: /u01/app/oracle/oradata/xxxxxx/archivelog/1_1423_862160568.dbf
2503 1 1424 A 2015-08-14 05:27:04
Name: /u01/app/oracle/oradata/xxxxxx/archivelog/1_1424_862160568.dbf
2500 2 1238 A 2015-08-13 20:44:18
Name: /u01/app/oracle/oradata/xxxxxx/archivelog/2_1238_862160568.dbf
2502 2 1239 A 2015-08-14 05:27:03
Name: /u01/app/oracle/oradata/xxxxxx/archivelog/2_1239_862160568.dbf
--可以發現執行個體1需要'2015-08-13' and '2015-08-13 18:00:00'時間範圍内,實際需要檔案
--Name: /u01/app/oracle/oradata/xxxxxx/archivelog/1_1421_862160568.dbf
--Name: /u01/app/oracle/oradata/xxxxxx/archivelog/1_1422_862160568.dbf
--Name: /u01/app/oracle/oradata/xxxxxx/archivelog/2_1237_862160568.dbf
--如果要真正這樣查詢,上面的指令自己還要做1點點判斷,如何寫rman指令直接顯示需要的結果呢?自己測試以下,應該寫成如下。
RMAN> list archivelog time between '2015-08-13' and '2015-08-13 18:00:00';
--順便寫一個rman小技巧,查手冊太慢。可以輸入list archivelog,加兩次回車這樣會出現指令的一些解析,不斷猜出可以完成指令的拼寫。
--例子:
RMAN> list archivelog
2>
3>
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "end-of-file": expecting one of: "all, from, high, like, low, scn, sequence, time, until, double-quoted-string, integer, single-quoted-string"
RMAN-01007: at line 3 column 1 file: standard input
RMAN> list archivelog time
RMAN-01009: syntax error: found "end-of-file": expecting one of: "between"