Rman备份异机恢复指南续

简介:

先前整理了一篇rman备份异机恢复的文档,那篇文档比较偏向复杂型,需要对oracle的整个体系结构有一定的了解才能领悟,类似于oracle的手工建库 ;文章地址:http://ylw6006.blog.51cto.com/470441/659104
 其实oracle 10g的rman也提供了类似于DBCA一样的简便工具来实现rman备份的异机恢复,也就是duplicate,下面来介绍下操作步骤:
 
 环境介绍:
 源数据库:
 IP:192.168.227.20/24
 SID: orcl
 操作系统版本:rhel5.4 32位
 oracle版本:10.2.0.1
 
 辅助数据库:
  IP:192.168.227.30/24
 SID: orcl
 操作系统版本:rhel5.4 32位
 oracle版本:10.2.0.1(只安装oracle软件,不建库)


1:准备auxiliary数据库相关目录和文件:

 
  1. [oracle@auxiliary ~]$ mkdir -p $ORACLE_BASE/admin/orcl/{adump,bdump,cdump,dpdump,pfile,udump}  
  2. [oracle@auxiliary ~]$ mkdir -p $ORACLE_BASE/flash_recovery_area/  
  3. [oracle@auxiliary ~]$ mkdir -p $ORACLE_BASE/oradata/orcl  
  4. [oracle@auxiliary ~]$ cd $ORACLE_HOME/dbs  
  5. [oracle@auxiliary dbs]$ orapwd file=orapworcl password=123456 entries=5 
  6. [oracle@auxiliary dbs]$ strings orapworcl   
  7. ]\[Z  
  8. ORACLE Remote Password file  
  9. INTERNAL  
  10. 203EBE72907E750E  
  11. 466C75A1248EDE33 

2:从源服务器上创建并复制参数文件到辅助数据库:

 
  1. SQL> create pfile='/home/oracle/initorcl.ora' from spfile;  
  2. File created.  
  3.  
  4. SQL> !scp /home/oracle/initorcl.ora oracle@192.168.227.30:/u01/app/oracle/product/10.2.0/db_1/dbs  
  5. oracle@192.168.227.30's password:   
  6. initorcl.ora                    100% 1041     1.0KB/s   00:00 


备注:
如果存储位置不同的话,还需要添加以下参数,对数据文件位置进行转换。
db_file_name_convert = ('/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/yang')

3:在源服务器端利用备份oracle数据库,将备份好的数据复制到辅助数据库上,位置需要相同,oracle 11g据说可以免掉这步,这在迁移海量数据的时候确实很有优势,越来越智能了,回头也会在11g上测试下

 
  1. [oracle@primary ~]$ mkdir -p /home/oracle/backup  
  2. [oracle@primary ~]$ rman target /  
  3. Recovery Manager: Release 10.2.0.1.0 - Production on Sat Oct 8 14:28:23 2011  
  4. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  5. connected to target database: ORCL (DBID=1287906064)  
  6.  
  7. RMAN>  backup incremental level 0  
  8. 2> format '/home/oracle/backup/inr0_%U'  
  9. 3> tag 'inr0_bak20111008' database  
  10. 4> plus archivelog delete all input;  
  11. RMAN> backup current controlfile format '/home/oracle/backup/controlfile20111008' tag 'ctl20111008';  
  12. 备注:据实验结果显示,控制文件可以不备份也能成功!rman自动备份控制文件选项未开启  
  13.  
  14. [oracle@auxiliary ~]$ mkdir -p /home/oracle/backup  
  15. [oracle@auxiliary backup]$ scp -rvp oracle@192.168.227.20:/home/oracle/backup/* ./ 

4:在辅助数据库上配置tnsnames串

 
  1. [oracle@auxiliary ~]$ cd $ORACLE_HOME/network/admin  
  2. [oracle@auxiliary admin]$ cat tnsnames.ora  
  3. primary =  
  4.   (DESCRIPTION =  
  5.     (ADDRESS_LIST =  
  6.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.227.20)(PORT = 1521))  
  7.     )  
  8.    (CONNECT_DATA =  
  9.       (SERVICE_NAME = orcl.herostart.com)  
  10.     )  
  11.  
  12. orcl =  
  13.   (DESCRIPTION =  
  14.     (ADDRESS_LIST =  
  15.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.227.30)(PORT = 1521))  
  16.     )  
  17.    (CONNECT_DATA =  
  18.       (SERVICE_NAME = orcl.herostart.com)  
  19.     )  

5:启动辅助数据库到nomount状态

 
  1. [oracle@auxiliary ~]$ lsnrctl start   
  2. [oracle@auxiliary  ~]$ sqlplus /nolog  
  3. SQL*Plus: Release 10.2.0.1.0 - Production on Sat Oct 8 14:54:58 2011  
  4. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  5.  
  6. SQL> conn /as sysdba  
  7. Connected to an idle instance.  
  8. SQL> create spfile from pfile;  
  9. File created.  
  10.  
  11. SQL> startup nomount  
  12. ORACLE instance started.  
  13. Total System Global Area  167772160 bytes  
  14. Fixed Size                  1218316 bytes  
  15. Variable Size              62916852 bytes  
  16. Database Buffers          100663296 bytes  
  17. Redo Buffers                2973696 bytes    

6:在辅助数据库进行duplicate操作

 
  1. [oracle@auxiliary ~]$ rman target sys/123456@primary auxiliary /  
  2. Recovery Manager: Release 10.2.0.1.0 - Production on Sat Oct 8 15:07:21 2011  
  3. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  4. connected to target database: ORCL (DBID=1287906064)  
  5. connected to auxiliary database: ORCL (not mounted)  
  6.  
  7. RMAN> duplicate target database to orcl nofilenamecheck;  
  8. ……………………………………………………其他输出省略……………………………………………………  
  9. contents of Memory Script:  
  10. {  
  11.    Alter clone database open resetlogs;  
  12. }  
  13. executing Memory Script  
  14.  
  15. database opened  
  16. Finished Duplicate Db at 2011-10-08:15:10:29 

7:验证

 
  1. [oracle@auxiliary ~]$ sqlplus /nolog  
  2. SQL*Plus: Release 10.2.0.1.0 - Production on Sat Oct 8 15:11:55 2011  
  3. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  4.  
  5. SQL> conn /as sysdba  
  6. Connected.  
  7. SQL> select name,dbid,open_mode from v$database;  
  8.  
  9. NAME            DBID OPEN_MODE  
  10. --------- ---------- ----------  
  11. ORCL      1291784142 READ WRITE 

8:增量备份的异机恢复

 
  1. [oracle@primary ~]$ sqlplus /nolog  
  2. SQL*Plus: Release 10.2.0.1.0 - Production on Sat Oct 8 15:22:17 2011  
  3. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  4. SQL> conn /as sysdba  
  5. Connected.  
  6. SQL> create table hr.inr1_duplicate as select * from dba_source;  
  7. Table created.  
  8.  
  9. SQL> commit;  
  10. Commit complete.  
  11.  
  12. RMAN> backup incremental level 1   
  13. 2> format '/home/oracle/backup/inr1_%U'  
  14. 3> tag 'inr1_20111008'  
  15. 4> database plus archivelog delete all input;  
  16.  
  17. [oracle@auxiliary ~]$ cd /home/oracle/backup/  
  18. [oracle@auxiliary backup]$ scp -rvp oracle@192.168.227.20:/home/oracle/backup/inr1* ./  
  19. [oracle@auxiliary backup]$ ll -h inr1*  
  20. -rw-r----- 1 oracle oinstall  83K Oct  8 15:29 inr1_0emoji6b_1_1  
  21. -rw-r----- 1 oracle oinstall  60M Oct  8 15:30 inr1_0fmoji6d_1_1  
  22. -rw-r----- 1 oracle oinstall 6.9M Oct  8 15:30 inr1_0gmoji7s_1_1  
  23. -rw-r----- 1 oracle oinstall 7.5K Oct  8 15:30 inr1_0hmoji7u_1_1  
  24.  
  25. [oracle@auxiliary ~]$ sqlplus /nolog  
  26. SQL*Plus: Release 10.2.0.1.0 - Production on Sat Oct 8 15:34:03 2011  
  27. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  28. SQL> conn /as sysdba  
  29. Connected.  
  30. SQL> select count(*) from hr.inr1_duplicate;  
  31. select count(*) from hr.inr1_duplicate  
  32.                         *  
  33. ERROR at line 1:  
  34. ORA-00942: table or view does not exist  
  35.  
  36. SQL> shutdown immediate  
  37. SQL> startup nomount  
  38.  
  39. [oracle@auxiliary ~]$ rman target sys/123456@primary auxiliary /  
  40. Recovery Manager: Release 10.2.0.1.0 - Production on Sat Oct 8 15:35:43 2011  
  41. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  42. connected to target database: ORCL (DBID=1287906064)  
  43. connected to auxiliary database: ORCL (not mounted)  
  44. RMAN> duplicate target database to orcl nofilenamecheck;  
  45.  
  46. [oracle@auxiliary ~]$ sqlplus /nolog  
  47. SQL*Plus: Release 10.2.0.1.0 - Production on Sat Oct 8 15:38:26 2011  
  48. Copyright (c) 1982, 2005, Oracle.  All rights reserved.  
  49. SQL> conn /as sysdba  
  50. Connected.  
  51. SQL> select count(*) from hr.inr1_duplicate;  
  52.  
  53.   COUNT(*)  
  54. ----------  
  55.     292428 

 本文转自斩月博客51CTO博客,原文链接http://blog.51cto.com/ylw6006/682650如需转载请自行联系原作者


ylw6006

相关文章
|
数据库
rman 异机恢复
rman 异机恢复
102 0
|
Oracle 关系型数据库 数据库
|
Oracle 关系型数据库 数据库
oracle数据库控制文件的备份和恢复之三RMAN自动备份和恢复
使用RMAN自动备份的控制文件向数据库中恢复控制文件
308 0
|
SQL otter 关系型数据库
|
SQL Oracle 关系型数据库
|
Oracle 关系型数据库 数据库
|
SQL Oracle 关系型数据库
|
Oracle 关系型数据库 Shell
|
Oracle 关系型数据库 数据库

相关实验场景

更多