温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

12c 验证RMAN加密备份

发布时间:2020-07-23 16:26:13 来源:网络 阅读:968 作者:roidba 栏目:关系型数据库

日常工作中,经常会遇到需要备份,然后异机恢复数据,提供测试数据。
为了保证数据的安全性,建议大家加密备份。

测试环境:Oracle 12c R1 RAC环境

1.备份脚本如下:

<rac01:orcl1:/home/oracle>$cat rk_rman.sh 
#!/bin/sh
#backup full  database and archivelog
#filename:/home/oracle/rk_rman.sh
#oracle user execute:sh /home/oracle/rk_rman.sh
rman target / <<EOF
set encryption on identified by 'roidba' only;
run { 
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE BACKUP OPTIMIZATION ON;
#CONFIGURE SNAPSHOT CONTROLFILE NAME TO '+datadg/snapcf_orcl1.f';
allocate channel d1 type disk;
allocate channel d2 type disk;
allocate channel d3 type disk;
allocate channel d4 type disk;
backup as compressed backupset database format '/u01/bak/db_fullbk_%s_%p_%t.rmn' tag='backup_full' include current controlfile;
backup as compressed backupset archivelog from time 'sysdate - 1/12' format '/u01/bak/archive_%s_%p_%t.arc';
backup current controlfile tag='backup_contorlfile' format='/u01/bak/ctl_%s_%p_%t';
backup spfile tag='backup_spfile' format='/u01/bak/spfile_%s_%p_%t';
release channel d2;
release channel d1;
release channel d3;
release channel d4;
}
exit;
EOF
<rac01:orcl1:/home/oracle>$

2.删除一个数据文件用来做测试

ASMCMD [+datadg/orcl/datafile] > ls
SYSAUX.257.954539345
SYSTEM.258.954539407
UNDOTBS1.260.954539485
UNDOTBS2.265.954539975
USERS.259.962188425
ASMCMD [+datadg/orcl/datafile] > rm USERS.259.962188425
ASMCMD [+datadg/orcl/datafile] > 

3.恢复

RMAN> startup

connected to target database (not started)
Oracle instance started
database mounted
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 12/08/2017 10:44:56
ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
ORA-01110: data file 6: '+DATADG/ORCL/DATAFILE/users.259.962188425'

RMAN> restore datafile 6;

Starting restore at 08-DEC-2017 10:45:20
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1 instance=orcl1 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00006 to +DATADG/ORCL/DATAFILE/users.259.962188425
channel ORA_DISK_1: reading from backup piece /u01/bak/db_fullbk_82_1_962188844.rmn
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/08/2017 10:45:22
ORA-19870: error while restoring backup piece /u01/bak/db_fullbk_82_1_962188844.rmn
ORA-19913: unable to decrypt backup
ORA-28365: wallet is not open

RMAN> set decryption identified by 'roidba';    --基于密码的加密备份

executing command: SET decryption

RMAN> restore database; 

Starting restore at 08-DEC-2017 10:47:47
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00004 to +DATADG/ORCL/DATAFILE/undotbs1.260.954539485
channel ORA_DISK_1: restoring datafile 00005 to +DATADG/ORCL/DATAFILE/undotbs2.265.954539975
channel ORA_DISK_1: reading from backup piece /u01/bak/db_fullbk_83_1_962188844.rmn
channel ORA_DISK_1: piece handle=/u01/bak/db_fullbk_83_1_962188844.rmn tag=BACKUP_FULL
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00003 to +DATADG/ORCL/DATAFILE/sysaux.257.954539345
channel ORA_DISK_1: restoring datafile 00006 to +DATADG/ORCL/DATAFILE/users.259.962188425
channel ORA_DISK_1: reading from backup piece /u01/bak/db_fullbk_82_1_962188844.rmn
channel ORA_DISK_1: piece handle=/u01/bak/db_fullbk_82_1_962188844.rmn tag=BACKUP_FULL
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to +DATADG/ORCL/DATAFILE/system.258.954539407
channel ORA_DISK_1: reading from backup piece /u01/bak/db_fullbk_81_1_962188844.rmn
channel ORA_DISK_1: piece handle=/u01/bak/db_fullbk_81_1_962188844.rmn tag=BACKUP_FULL
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:55
Finished restore at 08-DEC-2017 10:50:35

RMAN> recover database;

Starting recover at 08-DEC-2017 10:50:51
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:02

Finished recover at 08-DEC-2017 10:50:53

RMAN> alter database open;

Statement processed
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI