<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>惜分飞 &#187; rman加密</title>
	<atom:link href="https://www.xifenfei.com/tag/rman%e5%8a%a0%e5%af%86/feed" rel="self" type="application/rss+xml" />
	<link>https://www.xifenfei.com</link>
	<description>提供7*24专业数据库(Oracle,SQL Server,MySQL,PostgreSQL等)恢复和技术支持@Tel:17813235971</description>
	<lastBuildDate>Sat, 07 Nov 2026 15:45:44 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>给你的rman备份集加上密码锁</title>
		<link>https://www.xifenfei.com/2015/01/%e7%bb%99%e4%bd%a0%e7%9a%84rman%e5%a4%87%e4%bb%bd%e9%9b%86%e5%8a%a0%e4%b8%8a%e5%af%86%e7%a0%81%e9%94%81.html</link>
		<comments>https://www.xifenfei.com/2015/01/%e7%bb%99%e4%bd%a0%e7%9a%84rman%e5%a4%87%e4%bb%bd%e9%9b%86%e5%8a%a0%e4%b8%8a%e5%af%86%e7%a0%81%e9%94%81.html#comments</comments>
		<pubDate>Thu, 29 Jan 2015 15:08:53 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[Oracle 安全]]></category>
		<category><![CDATA[encryption，rman]]></category>
		<category><![CDATA[oracle 安全]]></category>
		<category><![CDATA[rman加密]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=5728</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2015/01/%e7%bb%99%e4%bd%a0%e7%9a%84rman%e5%a4%87%e4%bb%bd%e9%9b%86%e5%8a%a0%e4%b8%8a%e5%af%86%e7%a0%81%e9%94%81.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div id="xifenfeicopyright">
<p>联系：<a href="https://www.xifenfei.com/about_xifenfei" target="_blank">手机/微信(+86 17813235971)   QQ(107644445)</a><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&#038;uin=107644445&#038;site=qq&#038;menu=yes"><img src="https://www.xifenfei.com/wp-content/themes/img/site_qq.jpg" alt="QQ咨询惜分飞" title="QQ咨询惜分飞"/></a></p>
<p>标题：<a href="https://www.xifenfei.com/2015/01/%e7%bb%99%e4%bd%a0%e7%9a%84rman%e5%a4%87%e4%bb%bd%e9%9b%86%e5%8a%a0%e4%b8%8a%e5%af%86%e7%a0%81%e9%94%81.html" target="_blank">给你的rman备份集加上密码锁</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>数据的安全越来越重要,不是说你的生产库安全，你的数据就一定安全了，rman备份也是泄露数据的一个重要地方,如果别人拿到了你的备份集,一样等同入侵了你的生产库。为了rman备份的安全，最简单方式就是使用set encryption方式在rman备份过程中设置密码,需要版本为10.2及其以后企业版版,另外如果需要备份到带库只能使用oracle自己的osb(Oracle Secure Backup),注意rman只有backupset可以加密,copy无法进行加密<br />
<strong>数据库版本</strong></p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE    11.2.0.4.0      Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production

SQL&gt; show parameter compatible

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
compatible                           string      11.2.0.4.0
</pre>
<p><strong>支持rman加密算法</strong></p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select ALGORITHM_NAME
  2  from V$RMAN_ENCRYPTION_ALGORITHMS;

ALGORITHM_NAME
----------------------------------------------------------------
AES128
AES192
AES256
</pre>
<p><strong>调整加密算法</strong></p>
<pre class="brush: sql; title: ; notranslate">
RMAN&gt; show  ENCRYPTION ALGORITHM;

RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default

RMAN&gt; CONFIGURE ENCRYPTION ALGORITHM 'AES256';

new RMAN configuration parameters:
CONFIGURE ENCRYPTION ALGORITHM 'AES256';
new RMAN configuration parameters are successfully stored

RMAN&gt; show ENCRYPTION ALGORITHM;

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE ENCRYPTION ALGORITHM 'AES256';
</pre>
<p><strong>创建新测试数据文件</strong><br />
我们这里测试的是对新创建的5号文件进行加密备份和还原</p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/system01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u01/app/oracle/oradata/orcl/users01.dbf

SQL&gt; create tablespace rman_xifenfei datafile 
  2 '/u01/app/oracle/oradata/orcl/xifenfei01.dbf' size 100M;

Tablespace created.

SQL&gt; select file#,name from v$datafile;

     FILE# NAME
---------- --------------------------------------------------
         1 /u01/app/oracle/oradata/orcl/system01.dbf
         2 /u01/app/oracle/oradata/orcl/sysaux01.dbf
         3 /u01/app/oracle/oradata/orcl/undotbs01.dbf
         4 /u01/app/oracle/oradata/orcl/users01.dbf
         5 /u01/app/oracle/oradata/orcl/xifenfei01.dbf

SQL&gt; create table chf.t_xifenfei tablespace rman_xifenfei 
  2  as select * from dba_objects;

Table created.

SQL&gt; select count(*) from chf.t_xifenfei;

  COUNT(*)
----------
     86721
</pre>
<p><strong>rman加密备份</strong></p>
<pre class="brush: bash; title: ; notranslate">
RMAN&gt; set encryption on identified by 'www.xifenfei.com' only;

executing command: SET encryption

RMAN&gt; backup datafile 5;

Starting backup at 28-JAN-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=5 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/xifenfei01.dbf
channel ORA_DISK_1: starting piece 1 at 28-JAN-15
channel ORA_DISK_1: finished piece 1 at 28-JAN-15
piece handle=/u01/2015_01_28/o1_mf_nnndf_TAG20150128T230115_bdkyfvlw_.bkp tag=TAG20150128T230115 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 28-JAN-15
</pre>
<p><strong>准备恢复测试</strong></p>
<pre class="brush: bash; title: ; notranslate">
RMAN&gt; sql 'alter database datafile 5 offline';

sql statement: alter database datafile 5 offline

[oracle@localhost ~]$ rm /u01/app/oracle/oradata/orcl/xifenfei01.dbf
[oracle@localhost ~]$ ls /u01/app/oracle/oradata/orcl/xifenfei01.dbf
ls: /u01/app/oracle/oradata/orcl/xifenfei01.dbf: No such file or directory
</pre>
<p><strong>rman恢复测试</strong></p>
<pre class="brush: bash; title: ; notranslate">
[oracle@localhost ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Wed Jan 28 23:02:24 2015

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1378620768)

RMAN&gt; list backup of datafile 5;

using target database control file instead of recovery catalog

List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1       Full    10.94M     DISK        00:00:01     28-JAN-15      
        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20150128T230115
        Piece Name: /u01/2015_01_28/o1_mf_nnndf_TAG20150128T230115_bdkyfvlw_.bkp
  List of Datafiles in backup set 1
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  5       Full 54057180   28-JAN-15 /u01/app/oracle/oradata/orcl/xifenfei01.dbf

--未输入密码
RMAN&gt; restore datafile 5;

Starting restore at 28-JAN-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=492 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 00005 to /u01/app/oracle/oradata/orcl/xifenfei01.dbf
channel ORA_DISK_1: reading from backup piece /u01/2015_01_28/o1_mf_nnndf_TAG20150128T230115_bdkyfvlw_.bkp
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 01/28/2015 23:02:52
ORA-19870: error while restoring backup piece /u01/2015_01_28/o1_mf_nnndf_TAG20150128T230115_bdkyfvlw_.bkp
ORA-19913: unable to decrypt backup
ORA-28365: wallet is not open

--设置错误密码
RMAN&gt; SET DECRYPTION IDENTIFIED BY 'www.orasos.com';

executing command: SET decryption

RMAN&gt; restore datafile 5;

Starting restore at 28-JAN-15
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 00005 to /u01/app/oracle/oradata/orcl/xifenfei01.dbf
channel ORA_DISK_1: reading from backup piece /u01/2015_01_28/o1_mf_nnndf_TAG20150128T230115_bdkyfvlw_.bkp
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 01/28/2015 23:03:31
ORA-19870: error while restoring backup piece /u01/2015_01_28/o1_mf_nnndf_TAG20150128T230115_bdkyfvlw_.bkp
ORA-19913: unable to decrypt backup
ORA-28365: wallet is not open

--设置正确密码
RMAN&gt; SET DECRYPTION IDENTIFIED BY 'www.xifenfei.com';

executing command: SET decryption

RMAN&gt; restore datafile 5;

Starting restore at 28-JAN-15
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 00005 to /u01/app/oracle/oradata/orcl/xifenfei01.dbf
channel ORA_DISK_1: reading from backup piece /u01/2015_01_28/o1_mf_nnndf_TAG20150128T230115_bdkyfvlw_.bkp
channel ORA_DISK_1: piece handle=/u01/2015_01_28/o1_mf_nnndf_TAG20150128T230115_bdkyfvlw_.bkp tag=TAG20150128T230115
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 28-JAN-15
</pre>
<p><strong>验证数据还原</strong></p>
<pre class="brush: bash; title: ; notranslate">
RMAN&gt; recover datafile 5;

Starting recover at 28-JAN-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=7 device type=DISK

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 28-JAN-15

RMAN&gt; sql 'alter database datafile 5 online';

sql statement: alter database datafile 5 online

RMAN&gt; exit

Recovery Manager complete.
[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Jan 28 23:05:55 2015

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL&gt; select count(*) from chf.t_xifenfei;

  COUNT(*)
----------
     86721
</pre>
<p>至此我们可以看到,最简单的rman加密备份和加密恢复测试完成,在使用set encryption加密后,如果不输入或者错误的输入密码无法使用备份集,从而确保了备份集的安全.</p>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/06/rman%e9%80%9a%e8%bf%87nfs%e5%a4%87%e4%bb%bd.html" rel="bookmark" class="crp_title">rman通过nfs备份</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/11/rman%e4%bb%8e%e5%a4%9a%e4%bb%bd%e5%a4%87%e4%bb%bd%e4%b8%ad%e8%bf%98%e5%8e%9f%e6%93%8d%e4%bd%9c.html" rel="bookmark" class="crp_title">rman从多份备份中还原操作</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/03/rman-%e5%a4%87%e4%bb%bd%e5%87%ba%e7%8e%b0ora-00245rman-08132.html" rel="bookmark" class="crp_title">rman 备份出现ORA-00245/RMAN-08132</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/04/%e5%88%a9%e7%94%a8scn%e5%a2%9e%e9%87%8f%e5%a4%87%e4%bb%bd%e5%ae%9e%e7%8e%b0%e6%95%b0%e6%8d%ae%e5%ba%93%e5%a2%9e%e9%87%8f%e6%81%a2%e5%a4%8d.html" rel="bookmark" class="crp_title">利用scn增量备份实现数据库增量恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/08/asm%e4%b8%ad%e6%95%b0%e6%8d%ae%e6%96%87%e4%bb%b6%e4%bb%8ediskgroup-to-new-diskgroup.html" rel="bookmark" class="crp_title">asm数据文件迁移(asm&#8211;>asm)</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2015/06/ora-00230-operation-disallowed-snapshot-control-file-enqueue-unavailable.html" rel="bookmark" class="crp_title">ORA-00230: operation disallowed: snapshot control file enqueue unavailable</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2013/06/oracle-12c-rman-%e5%8a%9f%e8%83%bd%e5%a2%9e%e5%bc%ba.html" rel="bookmark" class="crp_title">ORACLE 12C RMAN 功能增强</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/08/ora-01578%e5%9d%8f%e5%9d%97%e8%a7%a3%e5%86%b32.html" rel="bookmark" class="crp_title">ORA-01578坏块解决(2)</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/11/ora-19693-backup-piece-s-already-included.html" rel="bookmark" class="crp_title">ORA-19693: backup piece %s already included</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2013/03/%e9%9d%9e%e5%bd%92%e6%a1%a3%e5%bc%82%e5%b8%b8%e6%95%b0%e6%8d%ae%e5%ba%93rman%e5%a4%87%e4%bb%bd.html" rel="bookmark" class="crp_title">非归档异常数据库rman备份</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/11/%e8%ae%aerman%e7%9a%84crosscheck%e5%92%8cobsolete.html" rel="bookmark" class="crp_title">议rman的crosscheck和obsolete</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/08/%e9%80%9a%e8%bf%87odu%e9%aa%8c%e8%af%81rman-backup%e5%af%b9%e4%ba%8etruncate%e5%af%b9%e8%b1%a1%e5%a4%87%e4%bb%bd%e5%a4%84%e7%90%86.html" rel="bookmark" class="crp_title">通过odu验证rman backup对于truncate对象备份处理</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2015/01/%e7%bb%99%e4%bd%a0%e7%9a%84rman%e5%a4%87%e4%bb%bd%e9%9b%86%e5%8a%a0%e4%b8%8a%e5%af%86%e7%a0%81%e9%94%81.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
