怎么将RMAN备份文件放到ASM中
短信预约 -IT技能 免费直播动态提醒
本篇内容介绍了“怎么将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中”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341