[20150902]rman的list archivelog命令.txt

lfree發表於2015-09-02

[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';

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

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';

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

2499    1    1422    A 2015-08-13 16:09:00
        Name: /u01/app/oracle/oradata/xxxxxx/archivelog/1_1422_862160568.dbf

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

2498    2    1237    A 2015-08-13 07:12:50
        Name: /u01/app/oracle/oradata/xxxxxx/archivelog/2_1237_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';

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

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,加兩次回車這樣會出現命令的一些解析,不斷猜出可以完成命令的拼寫。
--例子:

RMAN> list archivelog
2>
3>

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
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
2>
3>

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "end-of-file": expecting one of: "between"
RMAN-01007: at line 3 column 1 file: standard input

RMAN> list archivelog time 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

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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-1789599/,如需轉載,請註明出處,否則將追究法律責任。

相關文章