您好,登錄后才能下訂單哦!
本篇內容介紹了“怎么將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 ch2 type disk; allocate channel ch3 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 ch2; release channel ch3; }
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 ch2 type disk; allocate channel ch3 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 ch2; release channel ch3; 8> 9> } allocated channel: ch2 channel ch2: SID=29 instance=PROD1 device type=DISK allocated channel: ch3 channel ch3: SID=266 instance=PROD1 device type=DISK Starting backup at 26-FEB-20 current log archived channel ch2: starting compressed archived log backup set channel ch2: 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 ch2: starting piece 1 at 26-FEB-20 channel ch3: starting compressed archived log backup set channel ch3: 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 ch3: starting piece 1 at 26-FEB-20 channel ch2: finished piece 1 at 26-FEB-20 piece handle=+FLASHBACK/backup/arch_20200226_06upflvi_1_1.bak tag=TAG20200226T044954 comment=NONE channel ch2: backup set complete, elapsed time: 00:00:07 channel ch2: starting compressed archived log backup set channel ch2: 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 ch2: starting piece 1 at 26-FEB-20 channel ch3: finished piece 1 at 26-FEB-20 piece handle=+FLASHBACK/backup/arch_20200226_07upflvi_1_1.bak tag=TAG20200226T044954 comment=NONE channel ch3: backup set complete, elapsed time: 00:00:07 channel ch2: finished piece 1 at 26-FEB-20 piece handle=+FLASHBACK/backup/arch_20200226_08upflvp_1_1.bak tag=TAG20200226T044954 comment=NONE channel ch2: backup set complete, elapsed time: 00:00:01 Finished backup at 26-FEB-20 Starting backup at 26-FEB-20 channel ch2: starting compressed full datafile backup set channel ch2: 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 ch2: starting piece 1 at 26-FEB-20 channel ch3: starting compressed full datafile backup set channel ch3: 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 ch3: starting piece 1 at 26-FEB-20 channel ch3: finished piece 1 at 26-FEB-20 piece handle=+FLASHBACK/backup/db_20200226_0aupflvq_1_1.bak tag=TAG20200226T045002 comment=NONE channel ch3: backup set complete, elapsed time: 00:00:35 channel ch3: starting compressed full datafile backup set channel ch3: specifying datafile(s) in backup set including current control file in backup set channel ch3: starting piece 1 at 26-FEB-20 channel ch3: finished piece 1 at 26-FEB-20 piece handle=+FLASHBACK/backup/db_20200226_0bupfm0t_1_1.bak tag=TAG20200226T045002 comment=NONE channel ch3: backup set complete, elapsed time: 00:00:01 channel ch3: starting compressed full datafile backup set channel ch3: specifying datafile(s) in backup set including current SPFILE in backup set channel ch3: starting piece 1 at 26-FEB-20 channel ch3: finished piece 1 at 26-FEB-20 piece handle=+FLASHBACK/backup/db_20200226_0cupfm0v_1_1.bak tag=TAG20200226T045002 comment=NONE channel ch3: backup set complete, elapsed time: 00:00:01 channel ch2: finished piece 1 at 26-FEB-20 piece handle=+FLASHBACK/backup/db_20200226_09upflvq_1_1.bak tag=TAG20200226T045002 comment=NONE channel ch2: backup set complete, elapsed time: 00:00:44 Finished backup at 26-FEB-20 Starting backup at 26-FEB-20 current log archived channel ch2: starting compressed archived log backup set channel ch2: specifying archived log(s) in backup set input archived log thread=1 sequence=106 RECID=22 STAMP=1033361447 channel ch2: starting piece 1 at 26-FEB-20 channel ch2: finished piece 1 at 26-FEB-20 piece handle=+FLASHBACK/backup/arch_20200226_0dupfm17_1_1.bak tag=TAG20200226T045047 comment=NONE channel ch2: backup set complete, elapsed time: 00:00:01 Finished backup at 26-FEB-20 Starting backup at 26-FEB-20 channel ch2: starting 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/ctl_20200226_0eupfm18_1_1.bak tag=TAG20200226T045048 comment=NONE channel ch2: backup set complete, elapsed time: 00:00:01 Finished backup at 26-FEB-20 released channel: ch2 released channel: ch3 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中”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。