ORACLE 之 rman 备份加密

时间:2021-09-29 10:13:57

ORACLE 之 rman 备份加密

 

oracle@oracle:~> rman target / 恢复管理器: Release 11.1.0.6.0 - Production on 星期四 3月 28 20:33:52 2013 Copyright (c) 1982, 2007, Oracle. All rights reserved. 连接到目标数据库: ORCL (DBID=1307032085) RMAN> show all; 使用目标数据库控制文件替代恢复目录
db_unique_name 为 ORCL 的数据库的 RMAN 配置参数为:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/opt/oracle/flash_recovery_area/ORCL/controlfile/c_%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BZIP2'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/opt/oracle/product/10.2/db_1/dbs/snapcf_orcl.f'; # default
第一种方式:使用明文密码:测试如下: RMAN> set encryption on identified by "root" only; 正在执行命令: SET encryption RMAN> host; soracle@oracle:~> sqlplus "/as sysdba" SQL*Plus: Release 11.1.0.6.0 - Production on 星期四 3月 28 20:34:26 2013 Copyright (c) 1982, 2007, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS@orcl#select tablespace_name from dba_tablespaces; TABLESPACE_NAME
------------------------------------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS
VPN_HUADAN
已选择6行。 SYS@orcl#!
oracle@oracle:~> exit
exit
SYS@orcl#exit
从 Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开
oracle@oracle:~> exit
exit
主机命令完成
RMAN> backup datafile 6; 启动 backup 于 28-3月 -13
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=132 设备类型=DISK
通道 ORA_DISK_1: 正在启动全部数据文件备份集
通道 ORA_DISK_1: 正在指定备份集内的数据文件
输入数据文件: 文件号=00006 名称=/opt/oracle/oradata/sysaux_add.dbf
通道 ORA_DISK_1: 正在启动段 1 于 28-3月 -13
通道 ORA_DISK_1: 已完成段 1 于 28-3月 -13
段句柄=/opt/oracle/flash_recovery_area/ORCL/backupset/2013_03_28/o1_mf_nnndf_TAG20130328T203507_8o8g86q7_.bkp 标记=TAG20130328T203507 注释=NONE
通道 ORA_DISK_1: 备份集已完成, 经过时间:00:00:26
完成 backup 于 28-3月 -13
RMAN> exit
恢复管理器完成。
oracle@oracle:~> exit
exit
SYS@orcl#su - oracle
SP2-0734: 未知的命令开头 "su - oracl..." - 忽略了剩余的行。
SYS@orcl#exit
已断开连接
oracle@oracle:~> exit
logout
oracle:~ # su - oracle
sqlploracle@oracle:~> cd oradata
oracle@oracle:~/oradata> ls
ORCL/ ORCL01/ sysaux_add.dbf sysaux_add.dbf_bak system_add.dbf system_add.dbf_bak
oracle@oracle:~/oradata> rm sysaux_add.dbf
oracle@oracle:~/oradata> sqlplus "/as sysdba"
SQL*Plus: Release 11.1.0.6.0 - Production on 星期四 3月 28 20:36:49 2013 Copyright (c) 1982, 2007, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS@orcl#desc dba_tablespaces;
名称 是否为空? 类型
----------------------------------------- -------- ----------------------------
TABLESPACE_NAME NOT NULL VARCHAR2(30)
BLOCK_SIZE NOT NULL NUMBER
INITIAL_EXTENT NUMBER
NEXT_EXTENT NUMBER
MIN_EXTENTS NOT NULL NUMBER
MAX_EXTENTS NUMBER
MAX_SIZE NUMBER
PCT_INCREASE NUMBER
MIN_EXTLEN NUMBER
STATUS VARCHAR2(9)
CONTENTS VARCHAR2(9)
LOGGING VARCHAR2(9)
FORCE_LOGGING VARCHAR2(3)
EXTENT_MANAGEMENT VARCHAR2(10)
ALLOCATION_TYPE VARCHAR2(9)
PLUGGED_IN VARCHAR2(3)
SEGMENT_SPACE_MANAGEMENT VARCHAR2(6)
DEF_TAB_COMPRESSION VARCHAR2(8)
RETENTION VARCHAR2(11)
BIGFILE VARCHAR2(3)
PREDICATE_EVALUATION VARCHAR2(7)
ENCRYPTED VARCHAR2(3)
COMPRESS_FOR VARCHAR2(18)
SYS@orcl#select file_name,tablespace_name from dba_data_files; FILE_NAME
--------------------------------------------------------------------------------
TABLESPACE_NAME
------------------------------------------------------------
/opt/oracle/oradata/ORCL/datafile/o1_mf_users_8no75m69_.dbf
USERS
/opt/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_8no736w0_.dbf
UNDOTBS1
/opt/oracle/oradata/ORCL/datafile/o1_mf_sysaux_8no736vh_.dbf
SYSAUX

FILE_NAME
--------------------------------------------------------------------------------
TABLESPACE_NAME
------------------------------------------------------------
/opt/oracle/oradata/ORCL/datafile/o1_mf_system_8no75lqw_.dbf
SYSTEM
/opt/oracle/oradata/ORCL/datafile/huadan
VPN_HUADAN
/opt/oracle/oradata/sysaux_add.dbf
SYSAUX

FILE_NAME
--------------------------------------------------------------------------------
TABLESPACE_NAME
------------------------------------------------------------
/opt/oracle/oradata/system_add.dbf
SYSTEM

已选择7行。
SYS@orcl#alter tablespace sysaux offline;
alter tablespace sysaux offline
*
第 1 行出现错误:
ORA-01116: 打开数据库文件 6 时出错
ORA-01110: 数据文件 6: '/opt/oracle/oradata/sysaux_add.dbf'
ORA-27041: 无法打开文件
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3

SYS@orcl#shutdown immediate
ORA-01116: 打开数据库文件 6 时出错
ORA-01110: 数据文件 6: '/opt/oracle/oradata/sysaux_add.dbf'
ORA-27041: 无法打开文件
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
SYS@orcl#select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
SYS@orcl#shutdown abort;
ORACLE 例程已经关闭。
SYS@orcl#
SYS@orcl#
SYS@orcl#exit
从 Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开
oracle@oracle:~/oradata> rman target /
恢复管理器: Release 11.1.0.6.0 - Production on 星期四 3月 28 20:40:01 2013 Copyright (c) 1982, 2007, Oracle. All rights reserved. 已连接到目标数据库 (未启动) RMAN> startup mount; Oracle 实例已启动
数据库已装载
系统全局区域总计 805875712 字节 Fixed Size 2148720 字节
Variable Size 553649808 字节
Database Buffers 243269632 字节
Redo Buffers 6807552 字节
RMAN> list backup of datafile 6; 使用目标数据库控制文件替代恢复目录 备份集列表
===================

BS 关键字 类型 LV 大小 设备类型 经过时间 完成时间
------- ---- -- ---------- ----------- ------------ ----------
99 Full 76.40M DISK 00:00:24 27-3月 -13
BP 关键字: 99 状态: AVAILABLE 已压缩: NO 标记: TAG20130327T231356
段名:/opt/oracle/flash_recovery_area/ORCL/backupset/2013_03_27/o1_mf_nnndf_TAG20130327T231356_8o63c5bt_.bkp
备份集 99 中的数据文件列表
文件 LV 类型 Ckp SCN Ckp 时间 名称
---- -- ---- ---------- ---------- ----
6 Full 2935775 27-3月 -13 /opt/oracle/oradata/sysaux_add.dbf
BS 关键字 类型 LV 大小 设备类型 经过时间 完成时间
------- ---- -- ---------- ----------- ------------ ----------
102 Full 75.38M DISK 00:00:32 28-3月 -13
BP 关键字: 102 状态: AVAILABLE 已压缩: NO 标记: TAG20130328T203507
段名:/opt/oracle/flash_recovery_area/ORCL/backupset/2013_03_28/o1_mf_nnndf_TAG20130328T203507_8o8g86q7_.bkp
备份集 102 中的数据文件列表
文件 LV 类型 Ckp SCN Ckp 时间 名称
---- -- ---- ---------- ---------- ----
6 Full 2937092 28-3月 -13 /opt/oracle/oradata/sysaux_add.dbf
RMAN> restore datafile 6; 启动 restore 于 28-3月 -13
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=154 设备类型=DISK
通道 ORA_DISK_1: 正在开始还原数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集还原的数据文件
通道 ORA_DISK_1: 将数据文件 00006 还原到 /opt/oracle/oradata/sysaux_add.dbf
通道 ORA_DISK_1: 正在读取备份片段 /opt/oracle/flash_recovery_area/ORCL/backupset/2013_03_28/o1_mf_nnndf_TAG20130328T203507_8o8g86q7_.bkp
DBGANY: Mismatched message length! [20:40:48.913] (krmiduem)
DBGANY: Mismatched message length! [20:40:48.949] (krmiduem)
MAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00600: internal error, arguments [3045] [] [] [] []
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: restore 命令 (在 03/28/2013 20:40:48 上) 失败
ORA-19870: 还原备份片段 /opt/oracle/flash_recovery_area/ORCL/backupset/2013_03_28/o1_mf_nnndf_TAG20130328T203507_8o8g86q7_.bkp 时出错
ORA-19913: 无法解密备份
ORA-28365: Wallet 未打开
oracle@oracle:~/oradata> rman target /
恢复管理器: Release 11.1.0.6.0 - Production on 星期四 3月 28 20:40:56 2013 Copyright (c) 1982, 2007, Oracle. All rights reserved. 已连接到目标数据库: ORCL (DBID=1307032085, 未打开) RMAN> set decryption identified by "root"; 正在执行命令: SET decryption
使用目标数据库控制文件替代恢复目录
RMAN> restore datafile 6; 启动 restore 于 28-3月 -13
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=170 设备类型=DISK
通道 ORA_DISK_1: 正在开始还原数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集还原的数据文件
通道 ORA_DISK_1: 将数据文件 00006 还原到 /opt/oracle/oradata/sysaux_add.dbf
通道 ORA_DISK_1: 正在读取备份片段 /opt/oracle/flash_recovery_area/ORCL/backupset/2013_03_28/o1_mf_nnndf_TAG20130328T203507_8o8g86q7_.bkp
通道 ORA_DISK_1: 段句柄 = /opt/oracle/flash_recovery_area/ORCL/backupset/2013_03_28/o1_mf_nnndf_TAG20130328T203507_8o8g86q7_.bkp 标记 = TAG20130328T203507
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 还原完成, 用时: 00:00:15
完成 restore 于 28-3月 -13
RMAN> recover datafile 6; 启动 recover 于 28-3月 -13
使用通道 ORA_DISK_1
正在开始介质的恢复
介质恢复完成, 用时: 00:00:01
完成 recover 于 28-3月 -13 RMAN> alter database open; 数据库已打开 RMAN> RMAN> host; oracle@oracle:~/oradata> l
total 615033
drwxr-x--- 4 oracle oinstall 240 2013-03-28 20:41 ./
drwxrwx--- 32 oracle oinstall 1368 2013-03-25 21:51 ../
drwxr-x--- 5 oracle oinstall 136 2013-03-24 11:50 ORCL/
drwxr-x--- 3 oracle oinstall 72 2013-03-20 22:17 ORCL01/
-rw-r----- 1 oracle oinstall 104865792 2013-03-28 20:42 sysaux_add.dbf
-rw-r----- 1 oracle oinstall 104865792 2013-03-21 11:40 sysaux_add.dbf_bak
-rw-r----- 1 oracle oinstall 209723392 2013-03-28 20:42 system_add.dbf
-rw-r----- 1 oracle oinstall 209723392 2013-03-21 11:40 system_add.dbf_bak
oracle@oracle:~/oradata> cd
oracle@oracle:~> cd admin
oracle@oracle:~/admin> ls
orcl ORCL01
oracle@oracle:~/admin> cd orcl/
oracle@oracle:~/admin/orcl> echo $ORACLE_SID
orcl
oracle@oracle:~/admin/orcl> ls
adump dpdump pfile
第二种透明方式:使用加密证书,局限性是只能在本地数据库进行修复和恢复。 oracle@oracle:~/admin/orcl> mkdir wallet
oracle@oracle:~/admin/orcl> exit
exit
主机命令完成
RMAN> RMAN> RMAN> RMAN> show all; db_unique_name 为 ORCL 的数据库的 RMAN 配置参数为:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/opt/oracle/flash_recovery_area/ORCL/controlfile/c_%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BZIP2'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/opt/oracle/product/10.2/db_1/dbs/snapcf_orcl.f'; # default
RMAN> host; oracle@oracle:~/oradata> sqlplus "/as sysdba" SQL*Plus: Release 11.1.0.6.0 - Production on 星期四 3月 28 20:47:40 2013 Copyright (c) 1982, 2007, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS@orcl#alter system set encryption key authenticated by "root"; 系统已更改。 SYS@orcl#exit
从 Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开
oracle@oracle:~/oradata> cd
oracle@oracle:~> cd admin/
oracle@oracle:~/admin> cd orcl/
oracle@oracle:~/admin/orcl> cd wallet/
oracle@oracle:~/admin/orcl/wallet> ls
ewallet.p12
oracle@oracle:~/admin/orcl/wallet> pwd
/opt/oracle/admin/orcl/wallet
oracle@oracle:~/admin/orcl/wallet> exit
exit
主机命令完成
RMAN> RMAN> RMAN> RMAN> show all; db_unique_name 为 ORCL 的数据库的 RMAN 配置参数为:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/opt/oracle/flash_recovery_area/ORCL/controlfile/c_%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BZIP2'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/opt/oracle/product/10.2/db_1/dbs/snapcf_orcl.f'; # default
RMAN> configure encryption for database on; 新的 RMAN 配置参数:
CONFIGURE ENCRYPTION FOR DATABASE ON;
已成功存储新的 RMAN 配置参数
RMAN> backup datafile 6; 启动 backup 于 28-3月 -13
使用通道 ORA_DISK_1
通道 ORA_DISK_1: 正在启动全部数据文件备份集
通道 ORA_DISK_1: 正在指定备份集内的数据文件
输入数据文件: 文件号=00006 名称=/opt/oracle/oradata/sysaux_add.dbf
通道 ORA_DISK_1: 正在启动段 1 于 28-3月 -13
通道 ORA_DISK_1: 已完成段 1 于 28-3月 -13
段句柄=/opt/oracle/flash_recovery_area/ORCL/backupset/2013_03_28/o1_mf_nnndf_TAG20130328T204900_8o8h2dly_.bkp 标记=TAG20130328T204900 注释=NONE
通道 ORA_DISK_1: 备份集已完成, 经过时间:00:00:26
完成 backup 于 28-3月 -13
RMAN> exit
恢复管理器完成。
oracle@oracle:~/oradata> exit
logout
oracle:~ # su - oracle
sqlplus "/as sysdoracle@oracle:~> sqlplus "/as sysdba"
SQL*Plus: Release 11.1.0.6.0 - Production on 星期四 3月 28 20:50:01 2013 Copyright (c) 1982, 2007, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS@orcl#alter system set encryption wallet close; 系统已更改。 SYS@orcl#exit
从 Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开
oracle@oracle:~> rman target /
恢复管理器: Release 11.1.0.6.0 - Production on 星期四 3月 28 20:50:30 2013 Copyright (c) 1982, 2007, Oracle. All rights reserved. 连接到目标数据库: ORCL (DBID=1307032085) RMAN> RMAN> host; oracle@oracle:~> ls
admin cfgtoollogs flash_recovery_area oradata pfile.ora xiaohai
arch_log Desktop install2013-03-21_00-47-48.log oradata_test product xiaohai.sql
bak diag orabak ORCL01 redo_bak
block_tracking.log Documents ora_bak_test pfile.bak test
oracle@oracle:~> cd oradata
oracle@oracle:~/oradata> ls
ORCL ORCL01 sysaux_add.dbf sysaux_add.dbf_bak system_add.dbf system_add.dbf_bak
oracle@oracle:~/oradata> rm sysaux_add.dbf
oracle@oracle:~/oradata> exit
exit
主机命令完成
RMAN> exit
恢复管理器完成。
oracle@oracle:~> exit
logout
oracle:~ # su - oracle
soracle@oracle:~> sqlplus "/as sysdba"
SQL*Plus: Release 11.1.0.6.0 - Production on 星期四 3月 28 20:51:01 2013 Copyright (c) 1982, 2007, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS@orcl#
SYS@orcl#shutdown abort;(这个是模拟极端恢复了,在恢复数据的时候需要进行实例恢复)
ORACLE 例程已经关闭。
SYS@orcl#startup mount;
ORACLE 例程已经启动。
Total System Global Area 805875712 bytes
Fixed Size 2148720 bytes
Variable Size 553649808 bytes
Database Buffers 243269632 bytes
Redo Buffers 6807552 bytes
数据库装载完毕。
SYS@orcl#!
oracle@oracle:~> rman target /
恢复管理器: Release 11.1.0.6.0 - Production on 星期四 3月 28 20:52:31 2013 Copyright (c) 1982, 2007, Oracle. All rights reserved. 已连接到目标数据库: ORCL (DBID=1307032085, 未打开) RMAN> restore datafile 6; 启动 restore 于 28-3月 -13
使用目标数据库控制文件替代恢复目录
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=154 设备类型=DISK
通道 ORA_DISK_1: 正在开始还原数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集还原的数据文件
通道 ORA_DISK_1: 将数据文件 00006 还原到 /opt/oracle/oradata/sysaux_add.dbf
通道 ORA_DISK_1: 正在读取备份片段 /opt/oracle/flash_recovery_area/ORCL/backupset/2013_03_28/o1_mf_nnndf_TAG20130328T204900_8o8h2dly_.bkp
DBGANY: Mismatched message length! [20:52:48.493] (krmiduem)
DBGANY: Mismatched message length! [20:52:48.494] (krmiduem)
MAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00600: internal error, arguments [3045] [] [] [] []
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: restore 命令 (在 03/28/2013 20:52:48 上) 失败
ORA-19870: 还原备份片段 /opt/oracle/flash_recovery_area/ORCL/backupset/2013_03_28/o1_mf_nnndf_TAG20130328T204900_8o8h2dly_.bkp 时出错
ORA-19913: 无法解密备份
ORA-28365: Wallet 未打开
oracle@oracle:~> exit
exit

注意恢复的时候,只需要吧wallet打开就行了。数据库会自动进行认证,然后直接可以进行修复和恢复操作了
SYS@orcl#alter system set wallet open identified by "root"; 系统已更改。 SYS@orcl#!
oracle@oracle:~> exit
exit
SYS@orcl#!
oracle@oracle:~> rman target /
恢复管理器: Release 11.1.0.6.0 - Production on 星期四 3月 28 20:53:29 2013 Copyright (c) 1982, 2007, Oracle. All rights reserved. 已连接到目标数据库: ORCL (DBID=1307032085, 未打开) RMAN> restore datafile 6; 启动 restore 于 28-3月 -13
使用目标数据库控制文件替代恢复目录
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=155 设备类型=DISK
通道 ORA_DISK_1: 正在开始还原数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集还原的数据文件
通道 ORA_DISK_1: 将数据文件 00006 还原到 /opt/oracle/oradata/sysaux_add.dbf
通道 ORA_DISK_1: 正在读取备份片段 /opt/oracle/flash_recovery_area/ORCL/backupset/2013_03_28/o1_mf_nnndf_TAG20130328T204900_8o8h2dly_.bkp
通道 ORA_DISK_1: 段句柄 = /opt/oracle/flash_recovery_area/ORCL/backupset/2013_03_28/o1_mf_nnndf_TAG20130328T204900_8o8h2dly_.bkp 标记 = TAG20130328T204900
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 还原完成, 用时: 00:00:15
完成 restore 于 28-3月 -13
RMAN> recover datafile 6; 启动 recover 于 28-3月 -13
使用通道 ORA_DISK_1
正在开始介质的恢复
介质恢复完成, 用时: 00:00:00
完成 recover 于 28-3月 -13 RMAN> alter database open; 数据库已打开 RMAN> exit
恢复管理器完成。
oracle@oracle:~> exit
exit
SYS@orcl#! 恢复管理器完成。
第三种方式:混合方式,使用加密证书和密码进行保护,这样做的目的是,可以再本地使用wallet打开直接进行修复和恢复,并且在其他平台上,只需要密码就可以进行数据库的修复和恢复
了。解除了,透明方式只能在本地进行修复和恢复的限制。
测试如下:

oracle@oracle:~> rman target /
恢复管理器: Release 11.1.0.6.0 - Production on 星期四 3月 28 20:55:37 2013 Copyright (c) 1982, 2007, Oracle. All rights reserved. 连接到目标数据库: ORCL (DBID=1307032085) RMAN> set encryption on identified by "root"; 正在执行命令: SET encryption
使用目标数据库控制文件替代恢复目录
RMAN> backup datafile 6; 启动 backup 于 28-3月 -13
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=154 设备类型=DISK
通道 ORA_DISK_1: 正在启动全部数据文件备份集
通道 ORA_DISK_1: 正在指定备份集内的数据文件
输入数据文件: 文件号=00006 名称=/opt/oracle/oradata/sysaux_add.dbf
通道 ORA_DISK_1: 正在启动段 1 于 28-3月 -13
通道 ORA_DISK_1: 已完成段 1 于 28-3月 -13
段句柄=/opt/oracle/flash_recovery_area/ORCL/backupset/2013_03_28/o1_mf_nnndf_TAG20130328T205628_8o8hj85n_.bkp 标记=TAG20130328T205628 注释=NONE
通道 ORA_DISK_1: 备份集已完成, 经过时间:00:00:26
完成 backup 于 28-3月 -13
RMAN> RMAN> exit 可以看到只是在对第一种恢复方式中少了only,但是实现的却是不同的目的。
如果在其他机器上修复和恢复数据库只需要执行backup之前输入下面的命令进行解密;
set decryption on identified by "root";
oracle@oracle:~> exit
exit
SYS@orcl#alter system set encryption wallet close; 系统已更改。
SYS@orcl#exit
从 Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开
oracle@oracle:~> ls
cd admin/ flash_recovery_area/ .nautilus/ .skel/
arch_log/ .gconf/ orabak/ .ssh/
bak/ .gconfd/ ora_bak_test/ test/
.bash_history .gnome/ oradata/ .thumbnails/
block_tracking.log .gnome2/ oradata_test/ .viminfo
cfgtoollogs/ .gnome2_private/ ORCL01/ .wapi/
.config/ .gstreamer-0.10/ pfile.bak .Xauthority
Desktop/ .gtkrc pfile.ora xiaohai/
diag/ .gtkrc-1.2-gnome2 product/ xiaohai.sql
.dmrc .ICEauthority .profile .xsession-errors
Documents/ install2013-03-21_00-47-48.log .recently-used
.esd_auth .metacity/ redo_bak/
oracle@oracle:~> cd admin/
oracle@oracle:~/admin> ls
orcl/ ORCL01/
oracle@oracle:~/admin> cd orcl/
oracle@oracle:~/admin/orcl> ls
adump/ dpdump/ pfile/ wallet/
oracle@oracle:~/admin/orcl> cd wallet/
oracle@oracle:~/admin/orcl/wallet> ls
ewallet.p12
oracle@oracle:~/admin/orcl/wallet> rm *
oracle@oracle:~/admin/orcl/wallet>
oracle@oracle:~/admin/orcl/wallet>
oracle@oracle:~/admin/orcl/wallet>

oracle@oracle:~/admin/orcl/wallet> sqlplus "/as sysdba"
SQL*Plus: Release 11.1.0.6.0 - Production on 星期四 3月 28 20:59:08 2013 Copyright (c) 1982, 2007, Oracle. All rights reserved.
连接到:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS@orcl#
SYS@orcl#
SYS@orcl#alter system set encryption key identified by "root";
可以看到到了11G在生成wallet的证书的时候就不需要多加authenticated,这个是11g的增强; 系统已更改。 SYS@orcl#exit
从 Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开
oracle@oracle:~/admin/orcl/wallet> ls
ewallet.p12
oracle@oracle:~/admin/orcl/wallet>