当前位置:Gxlcms > 数据库问题 > 基于 RMAN 的同机数据库克隆

基于 RMAN 的同机数据库克隆

时间:2021-07-01 10:21:17 帮助过:2人阅读

   print?
    1. --环境:  
    2. --目标数据库: sybo3      /u01/database/sybo3  
    3. --辅助数据库: sybo5      /u01/database/sybo5  
    4. --说明:  
    5. --对于下面描述过程中,如创建参数文件,密码文件,监听等等有不甚了解的,可参考下面链接中有关文章的描述。其次本次演示使用了备份文件并连接到target db  
    6. --http://blog.csdn.net/robinson_0612/article/category/827734  (体系结构相关)  
    7. --http://blog.csdn.net/robinson_0612/article/category/828434  (网络配置相关)   
    8.   
    9. [oracle@linux3 database]$ cat /etc/issue  
    10. Enterprise Linux Enterprise Linux Server release 5.5 (Carthage)  
    11. Kernel \r on an \m  
    12.   
    13. SQL> select * from v$version where rownum<2;  
    14.   
    15. BANNER  
    16. --------------------------------------------------------------------------------  
    17. Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production  
    18.   
    19.   
    20. a、备份目标数据库  
    21. --生成后续验证克隆成功的测试数据  
    22. SQL> insert into t select ‘Jackson‘,‘Transfer DB by rman‘ from dual;  
    23.   
    24. SQL> commit;  
    25.   
    26. SQL> select * from t;  
    27.   
    28. NAME       ACTION  
    29. ---------- --------------------  
    30. Robinson   Transfer DB  
    31. Jackson    Transfer DB by rman  
    32.   
    33. SQL> alter system archive log current;  
    34.   
    35. [oracle@linux3 ~]$ rman target /  
    36.   
    37. Recovery Manager: Release 11.2.0.1.0 - Production on Thu Jul 25 08:39:42 2013  
    38.   
    39. Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.  
    40.   
    41. connected to target database: SYBO3 (DBID=2347733014)  
    42.   
    43. RMAN> backup database include current controlfile plus archivelog delete input;  
    44.   
    45. piece handle=/u01/database/sybo3/flash_recovery_area/SYBO3/backupset/2013_07_25/o1_mf_annnn_TAG20130725T083957_8z0wyy9n_.bkp   
    46. tag=TAG20130725T083957 comment=NONE  
    47. channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01  
    48.   
    49. piece handle=/u01/database/sybo3/flash_recovery_area/SYBO3/backupset/2013_07_25/o1_mf_nnndf_TAG20130725T083959_8z0wz06c_.bkp   
    50. tag=TAG20130725T083959 comment=NONE  
    51. channel ORA_DISK_1: backup set complete, elapsed time: 00:01:30  
    52. Finished backup at 2013/07/25 08:41:29  
    53.   
    54. Starting Control File and SPFILE Autobackup at 2013/07/25 08:41:31  
    55. piece handle=/u01/database/sybo3/flash_recovery_area/SYBO3/autobackup/2013_07_25/o1_mf_s_821695291_8z0x1vsf_.bkp comment=NONE  
    56. Finished Control File and SPFILE Autobackup at 2013/07/25 08:41:34  
    57.   
    58.   
    59. b、创建相应的dump文件夹  
    60. [oracle@linux3 database]$ more sybo5.sh  
    61. #!/bin/sh  
    62. mkdir -p /u01/database  
    63. mkdir -p /u01/database/sybo5/adump  
    64. mkdir -p /u01/database/sybo5/controlf  
    65. mkdir -p /u01/database/sybo5/flash_recovery_area  
    66. mkdir -p /u01/database/sybo5/oradata  
    67. mkdir -p /u01/database/sybo5/redo  
    68. mkdir -p /u01/database/sybo5/dpdump  
    69. mkdir -p /u01/database/sybo5/pfile  
    70. [oracle@linux3 database]$ ./sybo5.sh   
    71.   
    72.   
    73. c、配置辅助实例参数文件  
    74. --在sqlplus下生成辅助实例的参数文件  
    75. SQL> create pfile=‘/u01/oracle/db_1/dbs/initsybo5.ora‘ from spfile;    
    76.     
    77. --修改辅助实例参数文件     
    78. $ sed -i ‘s/sybo3/sybo5/g‘ $ORACLE_HOME/dbs/initsybo5.ora    
    79. $ grep sybo3 $ORACLE_HOME/dbs/initsybo5.ora    -->校验是否还存在sybo3相关字符     
    80.   
    81. --下面是修改后最终的结果  
    82. [oracle@linux3 database]$ more $ORACLE_HOME/dbs/initsybo5.ora  
    83. sybo5.__db_cache_size=113246208  
    84. sybo5.__java_pool_size=4194304  
    85. sybo5.__large_pool_size=4194304  
    86. sybo5.__oracle_base=‘/u01/oracle‘#ORACLE_BASE set from environment  
    87. sybo5.__pga_aggregate_target=142606336  
    88. sybo5.__sga_target=234881024  
    89. sybo5.__shared_io_pool_size=0  
    90. sybo5.__shared_pool_size=104857600  
    91. sybo5.__streams_pool_size=0  
    92. *.audit_file_dest=‘/u01/database/sybo5/adump/‘  
    93. *.audit_trail=‘db‘  
    94. *.compatible=‘11.2.0.0.0‘  
    95. *.control_files=‘/u01/database/sybo5/controlf/control01.ctl‘,‘/u01/database/sybo5/controlf/control02.ctl‘  
    96. *.db_block_size=8192  
    97. *.db_domain=‘orasrv.com‘  
    98. *.db_name=‘sybo5‘  
    99. *.db_recovery_file_dest=‘/u01/database/sybo5/flash_recovery_area/‘  
    100. *.db_recovery_file_dest_size=4039114752  
    101. *.dg_broker_config_file1=‘/u01/database/sybo5/db_broker/dr1sybo5.dat‘  
    102. *.dg_broker_config_file2=‘/u01/database/sybo5/db_broker/dr2sybo5.dat‘  
    103. *.dg_broker_start=FALSE  
    104. *.diagnostic_dest=‘/u01/database/sybo5‘  
    105. *.log_archive_dest_1=‘‘          #此处未指定archive位置,使用缺省的闪回区  
    106. *.memory_target=374341632  
    107. *.open_cursors=300  
    108. *.processes=150  
    109. *.remote_login_passwordfile=‘EXCLUSIVE‘  
    110. *.undo_tablespace=‘UNDOTBS1‘  
    111.   
    112.   
    113. d、生成辅助实例密码文件  
    114. --直接使用orapwd命令完成  
    115. $ orapwd file=$ORACLE_HOME/dbs/orapwsybo5 password=oracle entries=10   
    116.   
    117.   
    118. e、配置辅助实例监听  
    119. --配置辅助实例的监听方式很多,如netca,netmgr,直接命令方式等等,下面直接给出的脚本  
    120. [oracle@linux3 ~]$ more $ORACLE_HOME/network/admin/listener.ora  
    121. # listener.ora Network Configuration File: /u01/oracle/db_1/network/admin/listener.ora  
    122. # Generated by Oracle configuration tools.  
    123.   
    124. SID_LIST_LISTENER_SYBO5 =  
    125.   (SID_LIST =  
    126.     (SID_DESC =  
    127.       (GLOBAL_DBNAME = sybo5.orasrv.com)  
    128.       (ORACLE_HOME = /u01/oracle/db_1)  
    129.       (SID_NAME = sybo5)  
    130.     )  
    131.   )  
    132.   
    133. SID_LIST_LISTENER_SYBO3 =  
    134.   (SID_LIST =  
    135.     (SID_DESC =  
    136.       (GLOBAL_DBNAME = sybo3.orasrv.com)  
    137.       (ORACLE_HOME = /u01/oracle/db_1)  
    138.       (SID_NAME = sybo3)  
    139.     )  
    140.   )  
    141.   
    142. LISTENER_SYBO5 =  
    143.   (DESCRIPTION =  
    144.     (ADDRESS = (PROTOCOL = TCP)(HOST = linux3.orasrv.com)(PORT = 1532))  
    145.   )  
    146.   
    147. ADR_BASE_LISTENER_SYBO5 = /u01/oracle  
    148.   
    149. LISTENER_SYBO3 =  
    150.   (DESCRIPTION =  
    151.     (ADDRESS = (PROTOCOL = TCP)(HOST = linux3.orasrv.com)(PORT = 1531))  
    152.   )  
    153.   
    154. ADR_BASE_LISTENER_SYBO3 = /u01/oracle  
    155.   
    156. [oracle@linux3 ~]$ more $ORACLE_HOME/network/admin/tnsnames.ora  
    157. # tnsnames.ora Network Configuration File: /u01/oracle/db_1/network/admin/tnsnames.ora  
    158. # Generated by Oracle configuration tools.  
    159.   
    160. SYBO5 =  
    161.   (DESCRIPTION =  
    162.     (ADDRESS_LIST =  
    163.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.25)(PORT = 1532))  
    164.     )  
    165.     (CONNECT_DATA =  
    166.       (SERVICE_NAME = SYBO5.ORASRV.COM)  
    167.     )  
    168.   )  
    169.   
    170. SYBO3 =  
    171.   (DESCRIPTION =  
    172.     (ADDRESS_LIST =  
    173.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.25)(PORT = 1531))  
    174.     )  
    175.     (CONNECT_DATA =  
    176.       (SERVICE_NAME = SYBO3.ORASRV.COM)  
    177.     )  
    178.   )  
    179.   
    180.   
    181. f、实施数据库克隆    
    182. --下面先启动辅助实例到nomount状态  
    183. [oracle@linux3 ~]$ export ORACLE_SID=sybo5  
    184. [oracle@linux3 ~]$ sqlplus / as sysdba  
    185. SQL> startup nomount pfile=/u01/oracle/db_1/dbs/initsybo5.ora;  
    186. ORACLE instance started.  
    187.   
    188. --调用RMAN连接到目标数据库与辅助数据库  
    189. [oracle@linux3 ~]$ rman target sys/oracle@sybo3 auxiliary sys/oracle@sybo5  
    190.   
    191. Recovery Manager: Release 11.2.0.1.0 - Production on Thu Jul 25 14:32:51 2013  
    192.   
    193. Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.  
    194.   
    195. connected to target database: SYBO3 (DBID=2347733014)  
    196. connected to auxiliary database: SYBO5 (not mounted)  
    197.   
    198. RMAN> run{  
    199. 2> set newname for datafile 1  to ‘/u01/database/sybo5/oradata/system01.dbf‘;                          
    200. 3> set newname for datafile 2  to ‘/u01/database/sybo5/oradata/sysaux01.dbf‘;                          
    201. 4> set newname for datafile 3  to ‘/u01/database/sybo5/oradata/undotbs01.dbf‘;                         
    202. 5> set newname for datafile 4  to ‘/u01/database/sybo5/oradata/users01.dbf‘;                           
    203. 6> set newname for datafile 5  to ‘/u01/database/sybo5/oradata/example01.dbf‘;                         
    204. 7> set newname for tempfile 1  to ‘/u01/database/sybo5/oradata/temp01.dbf‘;   
    205. 8> duplicate target database to sybo5  
    206. 9> logfile  
    207. 10> group 1 (‘/u01/database/sybo5/redo/redo01a.log‘,‘/u01/database/sybo5/redo/redo01b.log‘) size 10m,  
    208. 11> group 2 (‘/u01/database/sybo5/redo/redo02a.log‘,‘/u01/database/sybo5/redo/redo02b.log‘) size 10m,  
    209. 12> group 3 (‘/u01/database/sybo5/redo/redo03a.log‘,‘/u01/database/sybo5/redo/redo03b.log‘) size 10m;  
    210. 13> switch datafile all;  
    211. 14> }  
    212.   
    213. executing command: SET NEWNAME  
    214.   
    215. executing command: SET NEWNAME  
    216.   
    217. executing command: SET NEWNAME  
    218.   
    219. executing command: SET NEWNAME  
    220.   
    221. executing command: SET NEWNAME  
    222.   
    223. executing command: SET NEWNAME  
    224.   
    225. Starting Duplicate Db at 2013/07/25 14:33:14  
    226. using target database control file instead of recovery catalog   ---->使用了原数据库的控制文件  
    227. allocated channel: ORA_AUX_DISK_1  
    228. channel ORA_AUX_DISK_1: SID=134 device type=DISK  
    229.   
    230. contents of Memory Script:                  ------->Oracle会自动生成auxiliary db的spfile  
    231. {  
    232.    sql clone "create spfile from memory";  
    233. }  
    234. executing Memory Script  
    235.   
    236. sql statement: create spfile from memory       
    237.   
    238. contents of Memory Script:                   ------->下面的SQL使用spfile重启auxiliary db到nomount状态  
    239. {  
    240.    shutdown clone immediate;  
    241.    startup clone nomount;  
    242. }  
    243. executing Memory Script                    
    244.   
    245. Oracle instance shut down  
    246.   
    247. connected to auxiliary database (not started)  
    248. Oracle instance started  
    249.   
    250. Total System Global Area     376635392 bytes  
    251.   
    252. Fixed Size                     1336652 bytes  
    253. Variable Size                260049588 bytes  
    254. Database Buffers             109051904 bytes  
    255. Redo Buffers                   6197248 bytes  
    256.   
    257. contents of Memory Script:                  ----->下面的这段SQL完成了一系列任务,见后面的分解  
    258. {  
    259.    sql clone "alter system set  db_name =   
    260.  ‘‘SYBO3‘‘ comment=  
    261.  ‘‘Modified by RMAN duplicate‘‘ scope=spfile";  
    262.    sql clone "alter system set  db_unique_name =   
    263.  ‘‘SYBO5‘‘ comment=  
    264.  ‘‘Modified by RMAN duplicate‘‘ scope=spfile";  
    265.    shutdown clone immediate;  
    266.    startup clone force nomount  
    267.    restore clone primary controlfile;  
    268.    alter clone database mount;  
    269. }  
    270. executing Memory Script  
    271.   
    272. sql statement: alter system set  db_name =  ‘‘SYBO3‘‘ comment= ‘‘Modified by RMAN duplicate‘‘ scope=spfile -->修改db_name  
    273.   
    274. sql statement: alter system set  db_unique_name = ‘‘SYBO5‘‘ comment= ‘‘Modified by RMAN duplicate‘‘ scope=spfile -->修改db_unique_name  
    275.   
    276. Oracle instance shut down  
    277.   
    278. Oracle instance started  
    279.   
    280. Total System Global Area     376635392 bytes  
    281.   
    282. Fixed Size                     1336652 bytes  
    283. Variable Size                260049588 bytes  
    284. Database Buffers             109051904 bytes  
    285. Redo Buffers                   6197248 bytes  
    286.   
    287. Starting restore at 2013/07/25 14:33:29          --->开始restore  
    288. allocated channel: ORA_AUX_DISK_1  
    289. channel ORA_AUX_DISK_1: SID=134 device type=DISK  
    290.   
    291. channel ORA_AUX_DISK_1: starting datafile backup set restore  
    292. channel ORA_AUX_DISK_1: restoring control file     --->首先restore controlfile  
    293. channel ORA_AUX_DISK_1: reading from backup piece /u01/database/sybo3/flash_recovery_area/SYBO3/autobackup/2013_07_25/  
    294.     o1_mf_s_821695291_8z0x1vsf_.bkp  
    295. channel ORA_AUX_DISK_1: piece handle=/u01/database/sybo3/flash_recovery_area/SYBO3/autobackup/2013_07_25/  
    296.     o1_mf_s_821695291_8z0x1vsf_.bkp tag=TAG20130725T084131  
    297. channel ORA_AUX_DISK_1: restored backup piece 1  
    298. channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01   -->controlfile restore完成  
    299. output file name=/u01/database/sybo5/controlf/control01.ctl        -->output到的位置   
    300. output file name=/u01/database/sybo5/controlf/control02.ctl        -->注意此时的控制文件中记录的信息依旧是sybo3的,即target db      
    301. Finished restore at 2013/07/25 14:33:30  
    302.   
    303. database mounted                                                   -->数据库切换到mount状态,对应语句alter clone database mount  
    304.   
    305. contents of Memory Script:                                         -->这些SQL语句用于设置auxiliary db 数据文件位置  
    306. {  
    307.    set until scn  886687;                                          -->Oracle自动设定了相应的scn  
    308.    set newname for datafile  1 to   
    309.  "/u01/database/sybo5/oradata/system01.dbf";  
    310.    set newname for datafile  2 to   
    311.  "/u01/database/sybo5/oradata/sysaux01.dbf";  
    312.    set newname for datafile  3 to   
    313.  "/u01/database/sybo5/oradata/undotbs01.dbf";  
    314.    set newname for datafile  4 to   
    315.  "/u01/database/sybo5/oradata/users01.dbf";  
    316.    set newname for datafile  5 to   
    317.  "/u01/database/sybo5/oradata/example01.dbf";  
    318.    restore                                                         --> 发布restore命令            
    319.    clone database  
    320.    ;  
    321. }  
    322. executing Memory Script  
    323.   
    324. executing command: SET until clause  
    325.   
    326. executing command: SET NEWNAME  
    327.   
    328. executing command: SET NEWNAME  
    329.   
    330. executing command: SET NEWNAME  
    331.   
    332. executing command: SET NEWNAME  
    333.   
    334. executing command: SET NEWNAME  
    335.   
    336. Starting restore at 2013/07/25 14:33:35                            -->开始数据文件的restore  
    337. using channel ORA_AUX_DISK_1                                       -->根据控制文件的信息读取备份集并还原到set newname位置  
    338.   
    339. channel ORA_AUX_DISK_1: starting datafile backup set restore  
    340. channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set  
    341. channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/database/sybo5/oradata/system01.dbf  
    342. channel ORA_AUX_DISK_1: restoring datafile 00002 to /u01/database/sybo5/oradata/sysaux01.dbf  
    343. channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/database/sybo5/oradata/undotbs01.dbf  
    344. channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/database/sybo5/oradata/users01.dbf  
    345. channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/database/sybo5/oradata/example01.dbf  
    346. channel ORA_AUX_DISK_1: reading from backup piece /u01/database/sybo3/flash_recovery_area/SYBO3/backupset/2013_07_25/  
    347.   o1_mf_nnndf_TAG20130725T083959_8z0wz06c_.bkp  
    348. channel ORA_AUX_DISK_1: piece handle=/u01/database/sybo3/flash_recovery_area/SYBO3/backupset/2013_07_25/  
    349.   o1_mf_nnndf_TAG20130725T083959_8z0wz06c_.bkp tag=TAG20130725T083959  
    350. channel ORA_AUX_DISK_1: restored backup piece 1  
    351. channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:15     -->完成数据文件restore  
    352. Finished restore at 2013/07/25 14:34:50  
    353.   
    354. contents of Memory Script:                                           -->下面的脚本将新的数据文件全部更新到控制文件  
    355. {  
    356.    switch clone datafile all;  
    357. }  
    358. executing Memory Script  
    359.   
    360. datafile 1 switched to datafile copy  
    361. input datafile copy RECID=7 STAMP=821716490 file name=/u01/database/sybo5/oradata/system01.dbf  
    362. datafile 2 switched to datafile copy  
    363. input datafile copy RECID=8 STAMP=821716491 file name=/u01/database/sybo5/oradata/sysaux01.dbf  
    364. datafile 3 switched to datafile copy  
    365. input datafile copy RECID=9 STAMP=821716491 file name=/u01/database/sybo5/oradata/undotbs01.dbf  
    366. datafile 4 switched to datafile copy  
    367. input datafile copy RECID=10 STAMP=821716491 file name=/u01/database/sybo5/oradata/users01.dbf  
    368. datafile 5 switched to datafile copy  
    369. input datafile copy RECID=11 STAMP=821716491 file name=/u01/database/sybo5/oradata/example01.dbf  
    370.   
    371. contents of Memory Script:                                          -->下面的脚本Oracle自动设置了scn后发布recover命令  
    372. {  
    373.    set until scn  886687;  
    374.    recover  
    375.    clone database  
    376.     delete archivelog  
    377.    ;  
    378. }  
    379. executing Memory Script  
    380.   
    381. executing command: SET until clause  
    382.   
    383. Starting recover at 2013/07/25 14:34:51    -->下面使用archivelog进行recover  
    384. using channel ORA_AUX_DISK_1  
    385.   
    386. starting media recovery  
    387.   
    388. archived log for thread 1 with sequence 16 is already on disk as file /u01/database/sybo3/flash_recovery_area/SYBO3/  
    389.   archivelog/2013_07_25/o1_mf_1_16_8z16rk6o_.arc       -->此时运用到了一个sybo3已经存在的归档日志,sequence 为16  
    390. channel ORA_AUX_DISK_1: starting archived log restore to default destination  -->接下来还原归档日志到缺省位置  
    391. channel ORA_AUX_DISK_1: restoring archived log  
    392. archived log thread=1 sequence=15                      -->从备份的归档日志中读取 sequence为15 的   
    393. channel ORA_AUX_DISK_1: reading from backup piece /u01/database/sybo3/flash_recovery_area/SYBO3/backupset/2013_07_25/  
    394.   o1_mf_annnn_TAG20130725T084129_8z0x1syh_.bkp  
    395. channel ORA_AUX_DISK_1: piece handle=/u01/database/sybo3/flash_recovery_area/SYBO3/backupset/2013_07_25/  
    396.   o1_mf_annnn_TAG20130725T084129_8z0x1syh_.bkp tag=TAG20130725T084129  
    397. channel ORA_AUX_DISK_1: restored backup piece 1  
    398. channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01  
    399. archived log file name=/u01/database/sybo5/flash_recovery_area/SYBO5/archivelog/2013_07_25/o1_mf_1_15_8z1krh5x_.arc thread=1 sequence=15  
    400. channel clone_default: deleting archived log(s)      -->删除归档日志  
    401. archived log file name=/u01/database/sybo5/flash_recovery_area/SYBO5/archivelog/2013_07_25/o1_mf_1_15_8z1krh5x_.arc RECID=12 STAMP=821716495  
    402. archived log file name=/u01/database/sybo3/flash_recovery_area/SYBO3/archivelog/2013_07_25/o1_mf_1_16_8z16rk6o_.arc thread=1 sequence=16  
    403. media recovery complete, elapsed time: 00:00:04      -->介质恢复完成  
    404. Finished recover at 2013/07/25 14:35:00  
    405.   
    406. contents of Memory Script:                           -->下面的脚本用于还原恢复之后的后续工作  
    407. {                                                    -->包括重新设置db_name,db_unique_name  
    408.    shutdown clone immediate;  
    409.    startup clone nomount;  
    410.    sql clone "alter system set  db_name =   
    411.  ‘‘SYBO5‘‘ comment=  
    412.  ‘‘Reset to original value by RMAN‘‘ scope=spfile";  
    413.    sql clone "alter system reset  db_unique_name scope=spfile";  
    414.    shutdown clone immediate;  
    415.    startup clone nomount;  
    416. }  
    417. executing Memory Script  
    418.   
    419. database dismounted  
    420. Oracle instance shut down  
    421.   
    422. --Author: Robinson  
    423. --Blog  : http://blog.csdn.net/robinson_0612  
    424.   
    425. connected to auxiliary database (not started)  
    426. Oracle instance started  
    427.   
    428. Total System Global Area     376635392 bytes  
    429.   
    430. Fixed Size                     1336652 bytes  
    431. Variable Size                260049588 bytes  
    432. Database Buffers             109051904 bytes  
    433. Redo Buffers                   6197248 bytes  
    434.   
    435. sql statement: alter system set  db_name =  ‘‘SYBO5‘‘ comment= ‘‘Reset to original value by RMAN‘‘ scope=spfile  
    436.   
    437. sql statement: alter system reset  db_unique_name scope=spfile  
    438.   
    439. Oracle instance shut down  
    440.   
    441. connected to auxiliary database (not started)  
    442. Oracle instance started  
    443.   
    444. Total System Global Area     376635392 bytes  
    445.   
    446. Fixed Size                     1336652 bytes  
    447. Variable Size                260049588 bytes  
    448. Database Buffers             109051904 bytes  
    449. Redo Buffers                   6197248 bytes  
    450. sql statement: CREATE CONTROLFILE REUSE SET DATABASE "SYBO5" RESETLOGS ARCHIVELOG   -->注意这里,重新创建控制文件  
    451.   MAXLOGFILES     16  
    452.   MAXLOGMEMBERS      3  
    453.   MAXDATAFILES      100  
    454.   MAXINSTANCES     8  
    455.   MAXLOGHISTORY      292  
    456.  LOGFILE  
    457.   GROUP  1 ( ‘/u01/database/sybo5/redo/redo01a.log‘, ‘/u01/database/sybo5/redo/redo01b.log‘ ) SIZE 10 M ,  
    458.   GROUP  2 ( ‘/u01/database/sybo5/redo/redo02a.log‘, ‘/u01/database/sybo5/redo/redo02b.log‘ ) SIZE 10 M ,  
    459.   GROUP  3 ( ‘/u01/database/sybo5/redo/redo03a.log‘, ‘/u01/database/sybo5/redo/redo03b.log‘ ) SIZE 10 M   
    460.  DATAFILE  
    461.   ‘/u01/database/sybo5/oradata/system01.dbf‘  
    462.  CHARACTER SET AL32UTF8  
    463.   
    464. contents of Memory Script:                     
    465. {  
    466.    set newname for tempfile  1 to   
    467.  "/u01/database/sybo5/oradata/temp01.dbf";  
    468.    switch clone tempfile all;  
    469.    catalog clone datafilecopy  "/u01/database/sybo5/oradata/sysaux01.dbf",   
    470.  "/u01/database/sybo5/oradata/undotbs01.dbf",   
    471.  "/u01/database/sybo5/oradata/users01.dbf",   
    472.  "/u01/database/sybo5/oradata/example01.dbf";  
    473.    switch clone datafile all;  
    474. }  
    475. executing Memory Script  
    476.   
    477. executing command: SET NEWNAME  
    478.   
    479. renamed tempfile 1 to /u01/database/sybo5/oradata/temp01.dbf in control file  
    480.   
    481. cataloged datafile copy  
    482. datafile copy file name=/u01/database/sybo5/oradata/sysaux01.dbf RECID=1 STAMP=821716521  
    483. cataloged datafile copy  
    484. datafile copy file name=/u01/database/sybo5/oradata/undotbs01.dbf RECID=2 STAMP=821716521  
    485. cataloged datafile copy  
    486. datafile copy file name=/u01/database/sybo5/oradata/users01.dbf RECID=3 STAMP=821716521  
    487. cataloged datafile copy  
    488. datafile copy file name=/u01/database/sybo5/oradata/example01.dbf RECID=4 STAMP=821716521  
    489.   
    490. datafile 2 switched to datafile copy  
    491. input datafile copy RECID=1 STAMP=821716521 file name=/u01/database/sybo5/oradata/sysaux01.dbf  
    492. datafile 3 switched to datafile copy  
    493. input datafile copy RECID=2 STAMP=821716521 file name=/u01/database/sybo5/oradata/undotbs01.dbf  
    494. datafile 4 switched to datafile copy  
    495. input datafile copy RECID=3 STAMP=821716521 file name=/u01/database/sybo5/oradata/users01.dbf  
    496. datafile 5 switched to datafile copy  
    497. input datafile copy RECID=4 STAMP=821716521 file name=/u01/database/sybo5/oradata/example01.dbf  
    498.   
    499. contents of Memory Script:  
    500. {  
    501.    Alter clone database open resetlogs;  
    502. }  
    503. executing Memory Script  
    504.   
    505. database opened  
    506. Finished Duplicate Db at 2013/07/25 14:35:36  
    507.   
    508. --验证克隆的结果  
    509. [oracle@linux3 dbs]$ export ORACLE_SID=sybo5  
    510. [oracle@linux3 dbs]$ sqlplus / as sysdba  
    511.   
    512. SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 25 14:38:21 2013  
    513.   
    514. Copyright (c) 1982, 2009, Oracle.  All rights reserved.  
    515.   
    516. Connected to:  
    517. Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production  
    518. With the Partitioning, OLAP, Data Mining and Real Application Testing options  
    519.   
    520. SQL> select * from t;  
    521.   
    522. NAME       ACTION  
    523. ---------- --------------------  
    524. Robinson   Transfer DB  
    525. Jackson    Transfer DB by rman  
    526.   
    527. SQL> select name,dbid,open_mode from v$database;   -->使用了与之前数据库不同的dbid  
    528.   
    529. NAME            DBID OPEN_MODE  
    530. --------- ---------- --------------------  
    531. SYBO5     2292457546 READ WRITE  
    532. 转:http://blog.csdn.net/leshami/article/details/9497321

基于 RMAN 的同机数据库克隆

标签:

人气教程排行