【RMAN】RMAN備份至ASM
一、問題描述
此次,我們希望將RMAN備份出來的檔案放到ASM當中儲存,這個操作不太難,就是正常的RMAN指令碼,將format輸出到正確的磁碟組就好。接下來我們實踐一下。
二、實踐
1.在磁碟組中建立目錄
[grid@sam1 ~]$ asmcmd -p ASMCMD [+] > cd +flashback ASMCMD [+flashback] > mkdir backup ASMCMD [+flashback] > ls PROD/ backup/ cluster/
2.準備備份指令碼
run { allocate channel ch1 type disk; allocate channel ch2 type disk; backup as compressed backupset database format '+FLASHBACK/backup/db_%T_%U.bak' plus archivelog format '+FLASHBACK/backup/arch_%T_%U.bak'; backup current controlfile format '+FLASHBACK//backup/ctl_%T_%U.bak'; release channel ch1; release channel ch2; }
3.RAMN執行指令碼
[oracle@sam1 ~]$ rman target / Recovery Manager: Release 11.2.0.3.0 - Production on Wed Feb 26 04:26:00 2020 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database: PROD (DBID=285149356) RMAN> run { allocate channel ch1 type disk; allocate channel ch2 type disk; 2> 3> 4> backup as compressed backupset database format '+FLASHBACK/backup/db_%T_%U.bak' plus archivelog 5> format '+FLASHBACK/backup/arch_%T_%U.bak'; 6> backup current controlfile format '+FLASHBACK//backup/ctl_%T_%U.bak'; 7> release channel ch1; release channel ch2; 8> 9> } allocated channel: ch1 channel ch1: SID=29 instance=PROD1 device type=DISK allocated channel: ch2 channel ch2: SID=266 instance=PROD1 device type=DISK Starting backup at 26-FEB-20 current log archived channel ch1: starting compressed archived log backup set channel ch1: specifying archived log(s) in backup set input archived log thread=2 sequence=48 RECID=4 STAMP=1032423541 input archived log thread=1 sequence=92 RECID=1 STAMP=1032421894 input archived log thread=1 sequence=93 RECID=2 STAMP=1032423466 input archived log thread=1 sequence=94 RECID=3 STAMP=1032423539 input archived log thread=1 sequence=95 RECID=5 STAMP=1032429063 input archived log thread=2 sequence=49 RECID=7 STAMP=1033175617 channel ch1: starting piece 1 at 26-FEB-20 channel ch2: starting compressed archived log backup set channel ch2: specifying archived log(s) in backup set input archived log thread=1 sequence=96 RECID=6 STAMP=1032429064 input archived log thread=2 sequence=50 RECID=8 STAMP=1033175617 input archived log thread=1 sequence=97 RECID=11 STAMP=1033175627 input archived log thread=2 sequence=51 RECID=9 STAMP=1033175623 input archived log thread=2 sequence=52 RECID=10 STAMP=1033175623 input archived log thread=1 sequence=98 RECID=12 STAMP=1033176208 input archived log thread=1 sequence=99 RECID=13 STAMP=1033176251 input archived log thread=1 sequence=100 RECID=14 STAMP=1033188448 input archived log thread=1 sequence=101 RECID=16 STAMP=1033189715 input archived log thread=2 sequence=53 RECID=15 STAMP=1033189715 input archived log thread=2 sequence=54 RECID=17 STAMP=1033189716 channel ch2: starting piece 1 at 26-FEB-20 channel ch1: finished piece 1 at 26-FEB-20 piece handle=+FLASHBACK/backup/arch_20200226_06upflvi_1_1.bak tag=TAG20200226T044954 comment=NONE channel ch1: backup set complete, elapsed time: 00:00:07 channel ch1: starting compressed archived log backup set channel ch1: specifying archived log(s) in backup set input archived log thread=1 sequence=102 RECID=18 STAMP=1033191217 input archived log thread=1 sequence=103 RECID=19 STAMP=1033198828 input archived log thread=1 sequence=104 RECID=20 STAMP=1033358298 input archived log thread=1 sequence=105 RECID=21 STAMP=1033361394 channel ch1: starting piece 1 at 26-FEB-20 channel ch2: finished piece 1 at 26-FEB-20 piece handle=+FLASHBACK/backup/arch_20200226_07upflvi_1_1.bak tag=TAG20200226T044954 comment=NONE channel ch2: backup set complete, elapsed time: 00:00:07 channel ch1: finished piece 1 at 26-FEB-20 piece handle=+FLASHBACK/backup/arch_20200226_08upflvp_1_1.bak tag=TAG20200226T044954 comment=NONE channel ch1: backup set complete, elapsed time: 00:00:01 Finished backup at 26-FEB-20 Starting backup at 26-FEB-20 channel ch1: starting compressed full datafile backup set channel ch1: specifying datafile(s) in backup set input datafile file number=00007 name=+DATA/prod/datafile/data_housetax.269.873313903 input datafile file number=00008 name=+DATA/prod/datafile/xx.270.929566627 input datafile file number=00006 name=+DATA/prod/datafile/undotbs2.265.873311123 input datafile file number=00004 name=+DATA/prod/datafile/users.259.873310959 channel ch1: starting piece 1 at 26-FEB-20 channel ch2: starting compressed full datafile backup set channel ch2: specifying datafile(s) in backup set input datafile file number=00001 name=+DATA/prod/datafile/system.256.873310959 input datafile file number=00002 name=+DATA/prod/datafile/sysaux.257.873310959 input datafile file number=00005 name=+DATA/prod/datafile/example.264.873311025 input datafile file number=00003 name=+DATA/prod/datafile/undotbs1.258.873310959 channel ch2: starting piece 1 at 26-FEB-20 channel ch2: finished piece 1 at 26-FEB-20 piece handle=+FLASHBACK/backup/db_20200226_0aupflvq_1_1.bak tag=TAG20200226T045002 comment=NONE channel ch2: backup set complete, elapsed time: 00:00:35 channel ch2: starting compressed full datafile backup set channel ch2: specifying datafile(s) in backup set including current control file in backup set channel ch2: starting piece 1 at 26-FEB-20 channel ch2: finished piece 1 at 26-FEB-20 piece handle=+FLASHBACK/backup/db_20200226_0bupfm0t_1_1.bak tag=TAG20200226T045002 comment=NONE channel ch2: backup set complete, elapsed time: 00:00:01 channel ch2: starting compressed full datafile backup set channel ch2: specifying datafile(s) in backup set including current SPFILE in backup set channel ch2: starting piece 1 at 26-FEB-20 channel ch2: finished piece 1 at 26-FEB-20 piece handle=+FLASHBACK/backup/db_20200226_0cupfm0v_1_1.bak tag=TAG20200226T045002 comment=NONE channel ch2: backup set complete, elapsed time: 00:00:01 channel ch1: finished piece 1 at 26-FEB-20 piece handle=+FLASHBACK/backup/db_20200226_09upflvq_1_1.bak tag=TAG20200226T045002 comment=NONE channel ch1: backup set complete, elapsed time: 00:00:44 Finished backup at 26-FEB-20 Starting backup at 26-FEB-20 current log archived channel ch1: starting compressed archived log backup set channel ch1: specifying archived log(s) in backup set input archived log thread=1 sequence=106 RECID=22 STAMP=1033361447 channel ch1: starting piece 1 at 26-FEB-20 channel ch1: finished piece 1 at 26-FEB-20 piece handle=+FLASHBACK/backup/arch_20200226_0dupfm17_1_1.bak tag=TAG20200226T045047 comment=NONE channel ch1: backup set complete, elapsed time: 00:00:01 Finished backup at 26-FEB-20 Starting backup at 26-FEB-20 channel ch1: starting full datafile backup set channel ch1: specifying datafile(s) in backup set including current control file in backup set channel ch1: starting piece 1 at 26-FEB-20 channel ch1: finished piece 1 at 26-FEB-20 piece handle=+FLASHBACK/backup/ctl_20200226_0eupfm18_1_1.bak tag=TAG20200226T045048 comment=NONE channel ch1: backup set complete, elapsed time: 00:00:01 Finished backup at 26-FEB-20 released channel: ch1 released channel: ch2 RMAN>
4.檢查備份出來的檔案
ASMCMD [+flashback/backup] > ls arch_20200226_06upflvi_1_1.bak arch_20200226_07upflvi_1_1.bak arch_20200226_08upflvp_1_1.bak arch_20200226_0dupfm17_1_1.bak ctl_20200226_0eupfm18_1_1.bak db_20200226_09upflvq_1_1.bak db_20200226_0aupflvq_1_1.bak db_20200226_0bupfm0t_1_1.bak db_20200226_0cupfm0v_1_1.bak ASMCMD [+flashback/backup] > ls -lsL Type Redund Striped Time Sys Block_Size Blocks Bytes Space Name BACKUPSET UNPROT COARSE FEB 26 05:00:00 N 512 83386 42693632 42991616 arch_20200226_06upflvi_1_1.bak => +FLASHBACK/PROD/BACKUPSET/2020_02_26/annnf0_TAG20200226T044954_0.284.1033361395 BACKUPSET UNPROT COARSE FEB 26 05:00:00 N 512 68430 35036160 35651584 arch_20200226_07upflvi_1_1.bak => +FLASHBACK/PROD/BACKUPSET/2020_02_26/annnf0_TAG20200226T044954_0.283.1033361395 BACKUPSET UNPROT COARSE FEB 26 05:00:00 N 512 6759 3460608 4194304 arch_20200226_08upflvp_1_1.bak => +FLASHBACK/PROD/BACKUPSET/2020_02_26/annnf0_TAG20200226T044954_0.282.1033361401 BACKUPSET UNPROT COARSE FEB 26 05:00:00 N 512 84 43008 1048576 arch_20200226_0dupfm17_1_1.bak => +FLASHBACK/PROD/BACKUPSET/2020_02_26/annnf0_TAG20200226T045047_0.290.1033361447 BACKUPSET UNPROT COARSE FEB 26 05:00:00 N 16384 1132 18546688 18874368 ctl_20200226_0eupfm18_1_1.bak => +FLASHBACK/PROD/BACKUPSET/2020_02_26/ncnnf0_TAG20200226T045048_0.291.1033361449 BACKUPSET UNPROT COARSE FEB 26 05:00:00 N 8192 53464 437977088 439353344 db_20200226_09upflvq_1_1.bak => +FLASHBACK/PROD/BACKUPSET/2020_02_26/nnndf0_TAG20200226T045002_0.281.1033361403 BACKUPSET UNPROT COARSE FEB 26 05:00:00 N 8192 39146 320684032 321912832 db_20200226_0aupflvq_1_1.bak => +FLASHBACK/PROD/BACKUPSET/2020_02_26/nnndf0_TAG20200226T045002_0.286.1033361403 BACKUPSET UNPROT COARSE FEB 26 05:00:00 N 16384 68 1114112 2097152 db_20200226_0bupfm0t_1_1.bak => +FLASHBACK/PROD/BACKUPSET/2020_02_26/ncnnf0_TAG20200226T045002_0.287.1033361439 BACKUPSET UNPROT COARSE FEB 26 05:00:00 N 16384 6 98304 1048576 db_20200226_0cupfm0v_1_1.bak => +FLASHBACK/PROD/BACKUPSET/2020_02_26/nnsnf0_TAG20200226T045002_0.288.1033361439
5.可以將ASM中的備份檔案複製到檔案系統中
(1)直接cp檔案到作業系統中,只能一個一個檔案複製
ASMCMD [+flashback/backup] > cp arch_20200226_06upflvi_1_1.bak /home/grid copying +flashback/backup/arch_20200226_06upflvi_1_1.bak -> /home/grid/arch_20200226_06upflvi_1_1.bak
利用萬用字元也是隻複製一個檔案
ASMCMD [+flashback/backup] > cp *.* /home/grid copying +flashback/backup/arch_20200226_06upflvi_1_1.bak -> /home/grid/arch_20200226_06upflvi_1_1.bak ASMCMD [+flashback/backup] >
(2)
使用shell指令碼批量將檔案從ASM拷貝到檔案系統(
ASMCMD 中的cp 命令不能使用萬用字元 * ,只能通過指令碼實現批量拷貝)
[grid@sam1 ~]$ cat asmcp.sh #!/bin/sh export ORACLE_SID=+ASM1 echo " Start to copy backupfile from ASM to file system ...." asmcmd << EOF cd flashback/backup cp arch_20200226_06upflvi_1_1.bak /home/grid cp arch_20200226_07upflvi_1_1.bak /home/grid cp arch_20200226_08upflvp_1_1.bak /home/grid cp arch_20200226_0dupfm17_1_1.bak /home/grid cp ctl_20200226_0eupfm18_1_1.bak /home/grid cp db_20200226_09upflvq_1_1.bak /home/grid cp db_20200226_0aupflvq_1_1.bak /home/grid cp db_20200226_0bupfm0t_1_1.bak /home/grid cp db_20200226_0cupfm0v_1_1.bak /home/grid EOF [grid@sam1 ~]$ chmod u+x asmcp.sh [grid@sam1 ~]$ ls -l asmcp.sh -rwxr--r-- 1 grid oinstall 562 Feb 26 06:41 asmcp.sh [grid@sam1 ~]$ ./asmcp.sh Start to copy backupfile from ASM to file system .... ASMCMD> ASMCMD> copying +flashback/backup/arch_20200226_06upflvi_1_1.bak -> /home/grid/arch_20200226_06upflvi_1_1.bak ASMCMD> copying +flashback/backup/arch_20200226_07upflvi_1_1.bak -> /home/grid/arch_20200226_07upflvi_1_1.bak ASMCMD> copying +flashback/backup/arch_20200226_08upflvp_1_1.bak -> /home/grid/arch_20200226_08upflvp_1_1.bak ASMCMD> copying +flashback/backup/arch_20200226_0dupfm17_1_1.bak -> /home/grid/arch_20200226_0dupfm17_1_1.bak ASMCMD> copying +flashback/backup/ctl_20200226_0eupfm18_1_1.bak -> /home/grid/ctl_20200226_0eupfm18_1_1.bak ASMCMD> copying +flashback/backup/db_20200226_09upflvq_1_1.bak -> /home/grid/db_20200226_09upflvq_1_1.bak ASMCMD> copying +flashback/backup/db_20200226_0aupflvq_1_1.bak -> /home/grid/db_20200226_0aupflvq_1_1.bak ASMCMD> copying +flashback/backup/db_20200226_0bupfm0t_1_1.bak -> /home/grid/db_20200226_0bupfm0t_1_1.bak ASMCMD> copying +flashback/backup/db_20200226_0cupfm0v_1_1.bak -> /home/grid/db_20200226_0cupfm0v_1_1.bak ASMCMD> exit [grid@sam1 ~]$ ls -l *.bak -rw-r----- 1 grid oinstall 42693632 Feb 26 06:50 arch_20200226_06upflvi_1_1.bak -rw-r----- 1 grid oinstall 35036160 Feb 26 06:50 arch_20200226_07upflvi_1_1.bak -rw-r----- 1 grid oinstall 3460608 Feb 26 06:50 arch_20200226_08upflvp_1_1.bak -rw-r----- 1 grid oinstall 43008 Feb 26 06:50 arch_20200226_0dupfm17_1_1.bak -rw-r----- 1 grid oinstall 18546688 Feb 26 06:50 ctl_20200226_0eupfm18_1_1.bak -rw-r----- 1 grid oinstall 437977088 Feb 26 06:50 db_20200226_09upflvq_1_1.bak -rw-r----- 1 grid oinstall 320684032 Feb 26 06:50 db_20200226_0aupflvq_1_1.bak -rw-r----- 1 grid oinstall 1114112 Feb 26 06:50 db_20200226_0bupfm0t_1_1.bak -rw-r----- 1 grid oinstall 98304 Feb 26 06:50 db_20200226_0cupfm0v_1_1.bak
三、總結
RMAN備份放到ASM磁碟組中比較容易,但是將備份出來的檔案複製到檔案系統中時,無法使用萬用字元(*)來進行,這個有些不太方便。還要編輯指令碼來處理,實在不爽。 就這樣吧,這個操作畢竟是臨時操作,不要做為常態。Remember Where there is a will, there is a way.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26148431/viewspace-2697445/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【RMAN】RMAN的備份保留策略
- RMAN備份概述
- RMAN備份恢復典型案例——RMAN備份&系統變慢
- RMAN備份進度
- rman 備份指令碼指令碼
- RMAN的備份原理
- 【RMAN】在備庫執行rman備份時報錯RMAN-06820 ORA-17629
- RMAN備份恢復技巧
- 【rman備份策略】實驗
- Oracle RMAN備份實戰Oracle
- Oracle OCP(60):RMAN 備份Oracle
- rman 增量備份恢復
- RMAN 備份相關的概念
- [20190522]rman備份問題.txt
- RMAN備份異機恢復
- RMAN備份詳解(轉載)
- 使用RMAN備份資料庫資料庫
- 分享Oracle Rman的備份指令碼Oracle指令碼
- RMAN備份恢復效能優化優化
- RMAN加密備份的三種方式加密
- RMAN備份中發現壞塊
- RMAN自動備份任務新增
- oracle 12c rman備份pdbOracle
- 利用RMAN備份重建資料庫資料庫
- RMAN備份與恢復測試
- 【RMAN】Oracle12c以後rman 備份恢復命令參考Oracle
- 【RMAN】在多租戶環境下的RMAN備份及恢復
- 【RMAN】同時建立多個備份(建立多重備份)
- oracle10g RMAN增量備份策略Oracle
- rman備份archivelog出現ORA-19625Hive
- ORACLE DG從庫 Rman備份恢復Oracle
- Oracle RMAN備份以及壓縮原理分析Oracle
- rman備份異機恢復(原創)
- Oracle 備份恢復篇之RMAN catalogOracle
- 揭秘ORACLE備份之----RMAN之五(CATALOG)Oracle
- Oracle 11G RAC複製備庫RMAN-03002 RMAN-05501 RMAN-03015 RMAN-03009 RMAN-10038Oracle
- 【備份】RMAN中對控制檔案的幾種備份方法
- Oracle ADG環境下的RMAN備份策略Oracle