[20151207]不斷應用日誌.txt
[20151207]不斷應用日誌.txt
--許多講rman的書都提到這個類似的指令碼:
RUN {
RECOVER COPY OF DATABASE WITH TAG 'incr_update';
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' DATABASE format '/home/oracle/backup/%U';
}
--透過不斷的應用日誌(最好開啟塊跟蹤),減少切換事件,自己也測試看看,先刪除備份再測試:
1.環境:
SCOTT@book> @ &r/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
RMAN> list copy ;
specification does not match any datafile copy in the repository
specification does not match any control file copy in the repository
specification does not match any archived log in the repository
RMAN> list backup;
specification does not match any backup in the repository
2.先測試format '%b'是否有效:
RMAN> BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' datafile 5 format '/home/oracle/backup/%b';
Starting backup at 2015-12-07 09:26:37
using channel ORA_DISK_1
no parent backup or copy of datafile 5 found
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/mnt/ramdisk/book/example01.dbf
output file name=/u01/app/oracle/fast_recovery_area/BOOK/datafile/o1_mf_example_c69r2f64_.dbf tag=INCR_UPDATE RECID=19 STAMP=897816398
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 2015-12-07 09:26:40
RMAN> BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' datafile 5 format '/home/oracle/backup/%b';
Starting backup at 2015-12-07 09:26:44
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/mnt/ramdisk/book/example01.dbf
channel ORA_DISK_1: starting piece 1 at 2015-12-07 09:26:44
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 12/07/2015 09:26:44
ORA-19715: invalid format b for generated name
ORA-27302: failure occurred at: slgpn
--可以發現這樣格式無效。
RMAN> list copy ;
specification does not match any control file copy in the repository
specification does not match any archived log in the repository
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- ---------- -------------------
19 5 A 2015-12-07 09:26:38 13212707504 2015-12-07 09:26:37
Name: /u01/app/oracle/fast_recovery_area/BOOK/datafile/o1_mf_example_c69r2f64_.dbf
Tag: INCR_UPDATE
RMAN> delete copy of database ;
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- ---------- -------------------
19 5 A 2015-12-07 09:26:38 13212707504 2015-12-07 09:26:37
Name: /u01/app/oracle/fast_recovery_area/BOOK/datafile/o1_mf_example_c69r2f64_.dbf
Tag: INCR_UPDATE
Do you really want to delete the above objects (enter YES or NO)? yes
deleted datafile copy
datafile copy file name=/u01/app/oracle/fast_recovery_area/BOOK/datafile/o1_mf_example_c69r2f64_.dbf RECID=19 STAMP=897816398
Deleted 1 objects
3.先建立as copy 備份
--要保持原來的檔名,必須先執行如下:
RMAN> backup as copy database format '/home/oracle/backup/%b';
Starting backup at 2015-12-07 09:29:45
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
output file name=/home/oracle/backup/users01.dbf tag=TAG20151207T092945 RECID=20 STAMP=897816589
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
output file name=/home/oracle/backup/system01.dbf tag=TAG20151207T092945 RECID=21 STAMP=897816595
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/mnt/ramdisk/book/sysaux01.dbf
output file name=/home/oracle/backup/sysaux01.dbf tag=TAG20151207T092945 RECID=22 STAMP=897816598
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/mnt/ramdisk/book/example01.dbf
output file name=/home/oracle/backup/example01.dbf tag=TAG20151207T092945 RECID=23 STAMP=897816600
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/mnt/ramdisk/book/undotbs01.dbf
output file name=/home/oracle/backup/undotbs01.dbf tag=TAG20151207T092945 RECID=24 STAMP=897816603
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
copying current control file
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 12/07/2015 09:30:03
ORA-19715: invalid format b for generated name
ORA-27302: failure occurred at: slgpn
continuing other job steps, job failed will not be re-run
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 2015-12-07 09:30:03
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 12/07/2015 09:30:03
ORA-19715: invalid format b for generated name
ORA-27302: failure occurred at: slgpn
--注意後面的錯誤並不重要,主要問題是格式%b無法建立spfile以及控制檔案的備份。
RMAN> list copy ;
specification does not match any control file copy in the repository
specification does not match any archived log in the repository
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- ---------- -------------------
21 1 A 2015-12-07 09:29:55 13212707624 2015-12-07 09:29:52
Name: /home/oracle/backup/system01.dbf
Tag: TAG20151207T092945
22 2 A 2015-12-07 09:29:58 13212707626 2015-12-07 09:29:56
Name: /home/oracle/backup/sysaux01.dbf
Tag: TAG20151207T092945
24 3 A 2015-12-07 09:30:03 13212707630 2015-12-07 09:30:02
Name: /home/oracle/backup/undotbs01.dbf
Tag: TAG20151207T092945
20 4 A 2015-12-07 09:29:49 13212707621 2015-12-07 09:29:45
Name: /home/oracle/backup/users01.dbf
Tag: TAG20151207T092945
23 5 A 2015-12-07 09:30:00 13212707628 2015-12-07 09:29:59
Name: /home/oracle/backup/example01.dbf
Tag: TAG20151207T092945
--可以發現現在的copy備份儲存的檔名與原來一樣。
4.轉換為0級備份:
catalog datafilecopy '/home/oracle/backup/system01.dbf' level 0 tag 'incr_update';
catalog datafilecopy '/home/oracle/backup/sysaux01.dbf' level 0 tag 'incr_update';
catalog datafilecopy '/home/oracle/backup/undotbs01.dbf' level 0 tag 'incr_update';
catalog datafilecopy '/home/oracle/backup/users01.dbf' level 0 tag 'incr_update';
catalog datafilecopy '/home/oracle/backup/example01.dbf' level 0 tag 'incr_update';
RMAN> list copy ;
specification does not match any control file copy in the repository
specification does not match any archived log in the repository
List of Datafile Copies
=======================
Key File S Completion Time Ckp SCN Ckp Time
------- ---- - ------------------- ---------- -------------------
25 1 A 2015-12-07 09:36:15 13212707624 2015-12-07 09:29:52
Name: /home/oracle/backup/system01.dbf
Tag: INCR_UPDATE
26 2 A 2015-12-07 09:36:15 13212707626 2015-12-07 09:29:56
Name: /home/oracle/backup/sysaux01.dbf
Tag: INCR_UPDATE
27 3 A 2015-12-07 09:36:15 13212707630 2015-12-07 09:30:02
Name: /home/oracle/backup/undotbs01.dbf
Tag: INCR_UPDATE
20 4 A 2015-12-07 09:29:49 13212707621 2015-12-07 09:29:45
Name: /home/oracle/backup/users01.dbf
Tag: TAG20151207T092945
28 5 A 2015-12-07 09:36:15 13212707628 2015-12-07 09:29:59
Name: /home/oracle/backup/example01.dbf
Tag: INCR_UPDATE
SCOTT@book> select file#, tag, incremental_level, name ,CHECKPOINT_CHANGE# from v$datafile_copy where deleted='NO' order by 1;
FILE# TAG INCREMENTAL_LEVEL NAME CHECKPOINT_CHANGE#
------------ -------------------------------- ----------------- -------------------------------------------------- ------------------
1 INCR_UPDATE 0 /home/oracle/backup/system01.dbf 13212707624
2 INCR_UPDATE 0 /home/oracle/backup/sysaux01.dbf 13212707626
3 INCR_UPDATE 0 /home/oracle/backup/undotbs01.dbf 13212707630
4 INCR_UPDATE 0 /home/oracle/backup/users01.dbf 13212707621
5 INCR_UPDATE 0 /home/oracle/backup/example01.dbf 13212707628
5.建立指令碼:
RUN {
RECOVER COPY OF DATABASE WITH TAG 'incr_update';
BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' DATABASE format '/home/oracle/backup/%U';
}
--不斷執行就可以保證日誌不斷應用到備份。
Starting recover at 2015-12-07 09:39:13
using channel ORA_DISK_1
no copy of datafile 1 found to recover
no copy of datafile 2 found to recover
no copy of datafile 3 found to recover
no copy of datafile 4 found to recover
no copy of datafile 5 found to recover
Finished recover at 2015-12-07 09:39:13
Starting backup at 2015-12-07 09:39:13
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
input datafile file number=00002 name=/mnt/ramdisk/book/sysaux01.dbf
input datafile file number=00005 name=/mnt/ramdisk/book/example01.dbf
input datafile file number=00003 name=/mnt/ramdisk/book/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 2015-12-07 09:39:14
channel ORA_DISK_1: finished piece 1 at 2015-12-07 09:39:17
piece handle=/home/oracle/backup/11qo76i2_1_1 tag=INCR_UPDATE comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 2015-12-07 09:39:18
channel ORA_DISK_1: finished piece 1 at 2015-12-07 09:39:19
piece handle=/home/oracle/backup/12qo76i5_1_1 tag=INCR_UPDATE comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015-12-07 09:39:19
$ ll | grep -v "dbf"
total 3121492
-rw-r----- 1 oracle oinstall 196608 2015-12-07 09:39:15 11qo76i2_1_1
-rw-r----- 1 oracle oinstall 10321920 2015-12-07 09:39:18 12qo76i5_1_1
SCOTT@book> select file#, tag, incremental_level, name ,CHECKPOINT_CHANGE# from v$datafile_copy where deleted='NO' order by 1;
FILE# TAG INCREMENTAL_LEVEL NAME CHECKPOINT_CHANGE#
------------ -------------------------------- ----------------- -------------------------------------------------- ------------------
1 INCR_UPDATE 0 /home/oracle/backup/system01.dbf 13212707624
2 INCR_UPDATE 0 /home/oracle/backup/sysaux01.dbf 13212707626
3 INCR_UPDATE 0 /home/oracle/backup/undotbs01.dbf 13212707630
4 INCR_UPDATE 0 /home/oracle/backup/users01.dbf 13212707621
5 INCR_UPDATE 0 /home/oracle/backup/example01.dbf 13212707628
--可以發現第1次因為沒有1級備份,日誌不應用。下次就ok了。
Starting recover at 2015-12-07 09:41:15
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile copies to recover
recovering datafile copy file number=00001 name=/home/oracle/backup/system01.dbf
recovering datafile copy file number=00002 name=/home/oracle/backup/sysaux01.dbf
recovering datafile copy file number=00003 name=/home/oracle/backup/undotbs01.dbf
recovering datafile copy file number=00004 name=/home/oracle/backup/users01.dbf
recovering datafile copy file number=00005 name=/home/oracle/backup/example01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/backup/11qo76i2_1_1
channel ORA_DISK_1: piece handle=/home/oracle/backup/11qo76i2_1_1 tag=INCR_UPDATE
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished recover at 2015-12-07 09:41:16
Starting backup at 2015-12-07 09:41:16
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/mnt/ramdisk/book/users01.dbf
input datafile file number=00001 name=/mnt/ramdisk/book/system01.dbf
input datafile file number=00002 name=/mnt/ramdisk/book/sysaux01.dbf
input datafile file number=00005 name=/mnt/ramdisk/book/example01.dbf
input datafile file number=00003 name=/mnt/ramdisk/book/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 2015-12-07 09:41:16
channel ORA_DISK_1: finished piece 1 at 2015-12-07 09:41:19
piece handle=/home/oracle/backup/13qo76ls_1_1 tag=INCR_UPDATE comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 2015-12-07 09:41:20
channel ORA_DISK_1: finished piece 1 at 2015-12-07 09:41:21
piece handle=/home/oracle/backup/14qo76lv_1_1 tag=INCR_UPDATE comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2015-12-07 09:41:21
$ ll | grep -v "dbf"
total 3131808
-rw-r----- 1 oracle oinstall 196608 2015-12-07 09:39:15 11qo76i2_1_1
-rw-r----- 1 oracle oinstall 10321920 2015-12-07 09:39:18 12qo76i5_1_1
-rw-r----- 1 oracle oinstall 221184 2015-12-07 09:41:17 13qo76ls_1_1
-rw-r----- 1 oracle oinstall 10321920 2015-12-07 09:41:20 14qo76lv_1_1
--看來增量備份不能放在這個目錄,這樣比較混亂。
SCOTT@book> select file#, tag, incremental_level, name ,CHECKPOINT_CHANGE# from v$datafile_copy where deleted='NO' order by 1;
FILE# TAG INCREMENTAL_LEVEL NAME CHECKPOINT_CHANGE#
------------ -------------------------------- ----------------- -------------------------------------------------- ------------------
1 INCR_UPDATE 0 /home/oracle/backup/system01.dbf 13212707950
2 INCR_UPDATE 0 /home/oracle/backup/sysaux01.dbf 13212707950
3 INCR_UPDATE 0 /home/oracle/backup/undotbs01.dbf 13212707950
4 INCR_UPDATE 0 /home/oracle/backup/users01.dbf 13212707950
5 INCR_UPDATE 0 /home/oracle/backup/example01.dbf 13212707950
--補充如果
RMAN> backup as copy database format '/home/oracle/backup/%b';
SCOTT@book> select file#, tag, incremental_level, name ,CHECKPOINT_CHANGE# from v$datafile_copy where deleted='NO' order by 1;
FILE# TAG INCREMENTAL_LEVEL NAME CHECKPOINT_CHANGE#
------------ -------------------------------- ----------------- -------------------------------------------------- ------------------
1 TAG20151207T094732 /home/oracle/backup/system01.dbf 13212708292
2 TAG20151207T094732 /home/oracle/backup/sysaux01.dbf 13212708294
3 TAG20151207T094732 /home/oracle/backup/undotbs01.dbf 13212708298
4 TAG20151207T094732 /home/oracle/backup/users01.dbf 13212708288
5 TAG20151207T094732 /home/oracle/backup/example01.dbf 13212708296
-- INCREMENTAL_LEVEL = NULL.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-1867921/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 應用程式日誌Sample
- [20151207]filter( IS NULL).txtFilterNull
- DG沒有應用日誌應用日誌
- [Java/日誌] 日誌框架列印應用程式日誌程式碼的執行情況Java框架
- ELK日誌系統之通用應用程式日誌接入方案
- 從Jboss預設日誌檔案中分離應用日誌應用日誌
- [20170228]dg的日誌傳輸與應用問題.txt
- DG-在主庫/備庫刪除已經應用過的日誌.txt
- Docker應用容器日誌資訊收集Docker
- DG邏輯庫logstdby 日誌應用長時間不歸檔
- DG日誌不應用,GAP,主備切換解決思路與辦法
- 應用日誌採集是什麼意思?批次採集應用日誌軟體用哪個?怎麼操作?應用日誌
- [20150910]11G ADG與延遲日誌應用.txt
- [bug]MySQL 雜湊掃描錯誤地應用日誌導致主從中斷MySql應用日誌
- 通過helm部署EFK收集應用日誌,ingress-nginx日誌解析。應用日誌Nginx
- [20170412]分析重做日誌.txt
- 聯機重做日誌、歸檔日誌、備用重做日誌
- MySQL複製應用中繼日誌解析MySql中繼
- 縮小日誌大小,截斷日誌;然後shrink
- Java-異常、斷言和日誌Java
- 判斷standby日誌是否同步primary
- feign配置日誌不列印
- MYSQL啟用日誌和檢視日誌MySql
- PHP實現日誌寫入log.txtPHP
- 應急響應:日誌分析
- 基於Docker應用容器日誌檔案收集Docker
- dg庫日誌應用慢引數調整
- 利用ELK搭建Docker容器化應用日誌中心Docker應用日誌
- mysql audit-訪問日誌記錄應用MySql
- 關於SQL Server 截斷日誌[zt]SQLServer
- DB2_獲取診斷日誌DB2
- 【MySQL】慢查詢日誌不列印MySql
- 【Java雜記】日誌:Java日誌體系,從應用場景到發展歷史Java
- Data Guard備庫日誌的實時應用與非實時應用
- laravel5.7 不記錄 sql 報錯日誌,自定義日誌資訊LaravelSQL
- TXT文字Log日誌分割工具(附工具連結)
- Java應用日誌如何與Jaeger的trace關聯Java應用日誌
- 如何在iOS手機上檢視應用日誌iOS應用日誌