通过RMAN克隆11g数据库(基于active database)

简介:

11g的RMAN duplicate 可以通过Active databaseduplicate和Backup-based duplicate两种方法实现。这里的测试使用的是Active databaseduplicate,因为Active database duplicate 功能强大,不需要先把目标数据库进行rman备份,只要目标数据库处于归档模式下即可直接通过网络对数据库进行copy,且copy完成后自动open数据库。这对于大数据特别是T级别的数据库来说优点非常明显,复制前不需要进行备份,减少了备份和传送备份的时间,同时节省备份空间。下面来进行具体的duplicate操作。

 

 

 

 

监听,口令文件配置,pfile配置,创建clone库相关目录等过程同基于备份的RMAN复制一样

 

1
2
3
4
5
6
7
8
SQL>startup pfile=$ORACLE_HOME /dbs/initclonedb .ora nomount;
ORACLEinstance started.
  
TotalSystem Global Area  630501376 bytes
FixedSize                    2215984 bytes
VariableSize                  184553424 bytes
DatabaseBuffers          440401920 bytes
RedoBuffers                    3330048 bytes

 

 

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
[oracle@HE4~]$ rman target sys /MANAGER @orcl auxiliarysys /MANAGER @clonedb
  
RecoveryManager: Release 11.2.0.1.0 - Production on Thu Jan 28 19:57:31 2016
  
Copyright(c) 1982, 2009, Oracle and /or  its affiliates. All rights reserved.
  
connectedto target database: ORCL (DBID=1426154421)
connectedto auxiliary database: CLONEDB (not mounted)
RMAN> duplicate target database to clonedb from active database;  (这里是异机异构恢复,如果是同结构的参数会报错,需添加nofilenamecheck,谨慎使用,防止文件被覆盖)
Starting DuplicateDb at 28-JAN-16
using targetdatabase control  file  instead of recovery catalog
allocated channel:ORA_AUX_DISK_1
channelORA_AUX_DISK_1: SID=20 device  type =DISK
  
contents of MemoryScript:
{
    sql clone  "create spfile frommemory" ;
}
executing MemoryScript
  
sql statement:create spfile from memory
  
contents of MemoryScript:
{
    shutdown  clone immediate;
    startup clone nomount;
}
executing MemoryScript
  
Oracle instance  shutdown
  
connected toauxiliary database (not started)
Oracle instancestarted
  
Total System GlobalArea     630501376 bytes
  
Fixed Size                     2215984 bytes
Variable Size                188747728 bytes
DatabaseBuffers             436207616 bytes
Redo Buffers                   3330048 bytes
  
contents of MemoryScript:
{
    sql clone "alter system  set   db_name =
  '' ORCL ''  comment=
  '' Modified by RMAN duplicate '' scope=spfile";
    sql clone "alter system  set   db_unique_name =
  '' CLONEDB ''  comment=
  '' Modified by RMAN duplicate '' scope=spfile";
    shutdown  clone immediate;
    startup clone force nomount
    backup as copy current controlfile auxiliaryformat  '/u01/app/oracle/oradata/clonedb/control01.ctl' ;
    restore clone controlfile to  '/u01/app/oracle/oradata/clonedb/control02.ctl'  from
  '/u01/app/oracle/oradata/clonedb/control01.ctl' ;
    alter clone database  mount ;
}
executing MemoryScript
  
sql statement: altersystem  set   db_name =   '' ORCL ''  comment=  '' Modified by RMANduplicate ''  scope=spfile
  
sql statement: altersystem  set   db_unique_name =   '' CLONEDB ''  comment=  '' Modified by RMANduplicate ''  scope=spfile
  
Oracle instance  shutdown
  
Oracle instancestarted
  
Total System GlobalArea     630501376 bytes
  
Fixed Size                     2215984 bytes
Variable Size                188747728 bytes
DatabaseBuffers             436207616 bytes
Redo Buffers                   3330048 bytes
  
Starting backup at28-JAN-16
allocated channel:ORA_DISK_1
channel ORA_DISK_1:SID=36 device  type =DISK
channel ORA_DISK_1:starting datafile copy
copying currentcontrol  file
output filename= /u01/app/oracle/product/11gr2/db_1/dbs/snapcf_orcl .ftag=TAG20160128T204953 RECID=5 STAMP=902350193
channel ORA_DISK_1:datafile copy complete, elapsed  time : 00:00:03
Finished backup at28-JAN-16
  
Starting restore at28-JAN-16
allocated channel:ORA_AUX_DISK_1
channelORA_AUX_DISK_1: SID=18 device  type =DISK
  
channelORA_AUX_DISK_1: copied control  file  copy
Finished restore at28-JAN-16
  
database mounted
  
contents of MemoryScript:
{
    set  newname  for  datafile  1 to
  "/u01/app/oracle/oradata/clonedb/system01.dbf" ;
    set  newname  for  datafile  2 to
  "/u01/app/oracle/oradata/clonedb/sysaux01.dbf" ;
    set  newname  for  datafile  3 to
  "/u01/app/oracle/oradata/clonedb/undotbs01.dbf" ;
    set  newname  for  datafile  4 to
  "/u01/app/oracle/oradata/clonedb/users01.dbf" ;
    set  newname  for  datafile  5 to
  "/u01/app/oracle/oradata/clonedb/example01.dbf" ;
    set  newname  for  datafile  6 to
  "/u01/app/oracle/oradata/clonedb/heleitbs01.dbf" ;
    backup as copy reuse
    datafile 1 auxiliary  format
  "/u01/app/oracle/oradata/clonedb/system01.dbf"    datafile
  2 auxiliary  format
  "/u01/app/oracle/oradata/clonedb/sysaux01.dbf"    datafile
  3 auxiliary  format
  "/u01/app/oracle/oradata/clonedb/undotbs01.dbf"    datafile
  4 auxiliary  format
  "/u01/app/oracle/oradata/clonedb/users01.dbf"    datafile
  5 auxiliary  format
  "/u01/app/oracle/oradata/clonedb/example01.dbf"    datafile
  6 auxiliary  format
  "/u01/app/oracle/oradata/clonedb/heleitbs01.dbf"    ;
    sql  'alter system archive log current' ;
}
executing MemoryScript
  
executing  command :SET NEWNAME
  
executing  command :SET NEWNAME
  
executing  command :SET NEWNAME
  
executing  command :SET NEWNAME
  
executing  command :SET NEWNAME
  
executing  command :SET NEWNAME
  
Starting backup at28-JAN-16
using channelORA_DISK_1
channel ORA_DISK_1:starting datafile copy
input datafile filenumber=00001 name= /u01/app/oracle/oradata/orcl/system01 .dbf
output filename= /u01/app/oracle/oradata/clonedb/system01 .dbf tag=TAG20160128T205002
channel ORA_DISK_1:datafile copy complete, elapsed  time : 00:00:59
channel ORA_DISK_1:starting datafile copy
input datafile filenumber=00002 name= /u01/app/oracle/oradata/orcl/sysaux01 .dbf
output filename= /u01/app/oracle/oradata/clonedb/sysaux01 .dbf tag=TAG20160128T205002
channel ORA_DISK_1:datafile copy complete, elapsed  time : 00:00:35
channel ORA_DISK_1:starting datafile copy
input datafile filenumber=00006 name= /u01/app/oracle/oradata/orcl/heleitbs01 .dbf
output filename= /u01/app/oracle/oradata/clonedb/heleitbs01 .dbf tag=TAG20160128T205002
channel ORA_DISK_1:datafile copy complete, elapsed  time : 00:00:16
channel ORA_DISK_1:starting datafile copy
input datafile filenumber=00005 name= /u01/app/oracle/oradata/orcl/example01 .dbf
output filename= /u01/app/oracle/oradata/clonedb/example01 .dbf tag=TAG20160128T205002
channel ORA_DISK_1:datafile copy complete, elapsed  time : 00:00:15
channel ORA_DISK_1:starting datafile copy
input datafile filenumber=00003 name= /u01/app/oracle/oradata/orcl/undotbs01 .dbf
output filename= /u01/app/oracle/oradata/clonedb/undotbs01 .dbf tag=TAG20160128T205002
channel ORA_DISK_1:datafile copy complete, elapsed  time : 00:00:08
channel ORA_DISK_1:starting datafile copy
input datafile filenumber=00004 name= /u01/app/oracle/oradata/orcl/users01 .dbf
output filename= /u01/app/oracle/oradata/clonedb/users01 .dbf tag=TAG20160128T205002
channel ORA_DISK_1:datafile copy complete, elapsed  time : 00:00:01
Finished backup at28-JAN-16
  
sql statement: altersystem archive log current
  
contents of MemoryScript:
{
    backup as copy reuse
    archivelog like  "/u01/archivelog/1_13_898373685.dbf"  auxiliary  format
  "/u01/archivelog/1_13_898373685.dbf"    ;
    catalog clone archivelog  "/u01/archivelog/1_13_898373685.dbf" ;
    switch clone datafile all;
}
executing MemoryScript
  
Starting backup at28-JAN-16
using channelORA_DISK_1
channel ORA_DISK_1:starting archived log copy
input archived logthread=1 sequence=13 RECID=9 STAMP=902350337
output filename= /u01/archivelog/1_13_898373685 .dbf RECID=0 STAMP=0
channel ORA_DISK_1:archived log copy complete, elapsed  time : 00:00:01
Finished backup at28-JAN-16
  
cataloged archivedlog
archived log filename= /u01/archivelog/1_13_898373685 .dbf RECID=9 STAMP=902350338
  
datafile 1 switchedto datafile copy
input datafile copyRECID=5 STAMP=902350338  file  name= /u01/app/oracle/oradata/clonedb/system01 .dbf
datafile 2 switchedto datafile copy
input datafile copyRECID=6 STAMP=902350338  file  name= /u01/app/oracle/oradata/clonedb/sysaux01 .dbf
datafile 3 switchedto datafile copy
input datafile copyRECID=7 STAMP=902350338  file  name= /u01/app/oracle/oradata/clonedb/undotbs01 .dbf
datafile 4 switchedto datafile copy
input datafile copyRECID=8 STAMP=902350338  file  name= /u01/app/oracle/oradata/clonedb/users01 .dbf
datafile 5 switchedto datafile copy
input datafile copyRECID=9 STAMP=902350338  file  name= /u01/app/oracle/oradata/clonedb/example01 .dbf
datafile 6 switchedto datafile copy
input datafile copyRECID=10 STAMP=902350338 filename= /u01/app/oracle/oradata/clonedb/heleitbs01 .dbf
  
contents of MemoryScript:
{
    set  until  scn  1028975;
    recover
    clone database
     delete archivelog
    ;
}
executing MemoryScript
  
executing  command :SET  until  clause
  
Starting recover at28-JAN-16
using channelORA_AUX_DISK_1
  
starting mediarecovery
  
archived log forthread 1 with sequence 13 is already on disk as  file /u01/archivelog/1_13_898373685 .dbf
archived log filename= /u01/archivelog/1_13_898373685 .dbf thread=1 sequence=13
media recoverycomplete, elapsed  time : 00:00:00
Finished recover at28-JAN-16
  
contents of MemoryScript:
{
    shutdown  clone immediate;
    startup clone nomount;
    sql clone "alter system  set   db_name =
  '' CLONEDB ''  comment=
  '' Reset to original value by RMAN '' scope=spfile";
    sql clone  "alter system reset  db_unique_name scope=spfile" ;
    shutdown  clone immediate;
    startup clone nomount;
}
executing MemoryScript
  
database dismounted
Oracle instance  shutdown
  
connected toauxiliary database (not started)
Oracle instancestarted
  
Total System GlobalArea     630501376 bytes
  
Fixed Size                     2215984 bytes
Variable Size                188747728 bytes
DatabaseBuffers             436207616 bytes
Redo Buffers                   3330048 bytes
  
sql statement: altersystem  set   db_name =   '' CLONEDB ''  comment=  '' Reset to originalvalue by RMAN ''  scope=spfile
  
sql statement: altersystem reset  db_unique_name scope=spfile
  
Oracle instance  shutdown
  
connected toauxiliary database (not started)
Oracle instancestarted
  
Total System GlobalArea     630501376 bytes
  
Fixed Size                     2215984 bytes
Variable Size                188747728 bytes
DatabaseBuffers             436207616 bytes
Redo Buffers                   3330048 bytes
sql statement:CREATE CONTROLFILE REUSE SET DATABASE  "CLONEDB"  RESETLOGS ARCHIVELOG
   MAXLOGFILES     16
   MAXLOGMEMBERS      3
   MAXDATAFILES      100
   MAXINSTANCES     8
   MAXLOGHISTORY      292
  LOGFILE
   GROUP 1 (  '/u01/app/oracle/oradata/clonedb/redo01.log'  ) SIZE 50 M  REUSE,
   GROUP 2 (  '/u01/app/oracle/oradata/clonedb/redo02.log'  ) SIZE 50 M  REUSE,
   GROUP 3 (  '/u01/app/oracle/oradata/clonedb/redo03.log'  ) SIZE 50 M  REUSE
  DATAFILE
  '/u01/app/oracle/oradata/clonedb/system01.dbf'
  CHARACTER SET ZHS16GBK
  
  
contents of MemoryScript:
{
    set  newname  for  tempfile  1 to
  "/u01/app/oracle/oradata/clonedb/temp01.dbf" ;
    switch clone tempfile all;
    catalog clone datafilecopy  "/u01/app/oracle/oradata/clonedb/sysaux01.dbf" ,
  "/u01/app/oracle/oradata/clonedb/undotbs01.dbf" ,
  "/u01/app/oracle/oradata/clonedb/users01.dbf" ,
  "/u01/app/oracle/oradata/clonedb/example01.dbf" ,
  "/u01/app/oracle/oradata/clonedb/heleitbs01.dbf" ;
    switch clone datafile all;
}
executing MemoryScript
  
executing  command :SET NEWNAME
  
renamed tempfile 1to  /u01/app/oracle/oradata/clonedb/temp01 .dbf  in  control  file
  
cataloged datafilecopy
datafile copy filename= /u01/app/oracle/oradata/clonedb/sysaux01 .dbf RECID=1 STAMP=902350346
cataloged datafilecopy
datafile copy filename= /u01/app/oracle/oradata/clonedb/undotbs01 .dbf RECID=2 STAMP=902350346
cataloged datafilecopy
datafile copy filename= /u01/app/oracle/oradata/clonedb/users01 .dbf RECID=3 STAMP=902350346
cataloged datafilecopy
datafile copy filename= /u01/app/oracle/oradata/clonedb/example01 .dbf RECID=4 STAMP=902350346
cataloged datafilecopy
datafile copy filename= /u01/app/oracle/oradata/clonedb/heleitbs01 .dbf RECID=5 STAMP=902350346
  
datafile 2 switchedto datafile copy
input datafile copyRECID=1 STAMP=902350346  file  name= /u01/app/oracle/oradata/clonedb/sysaux01 .dbf
datafile 3 switchedto datafile copy
input datafile copyRECID=2 STAMP=902350346  file  name= /u01/app/oracle/oradata/clonedb/undotbs01 .dbf
datafile 4 switchedto datafile copy
input datafile copyRECID=3 STAMP=902350346  file  name= /u01/app/oracle/oradata/clonedb/users01 .dbf
datafile 5 switchedto datafile copy
input datafile copyRECID=4 STAMP=902350346  file  name= /u01/app/oracle/oradata/clonedb/example01 .dbf
datafile 6 switchedto datafile copy
input datafile copyRECID=5 STAMP=902350346 filename= /u01/app/oracle/oradata/clonedb/heleitbs01 .dbf
  
contents of MemoryScript:
{
    Alter clone database  open  resetlogs;
}
executing MemoryScript
  
database opened
Finished DuplicateDb at 28-JAN-16





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


相关文章
|
1月前
|
SQL 关系型数据库 MySQL
|
28天前
|
NoSQL 关系型数据库 MySQL
AWS Database Migration Service 助力数据库搬迁
AWS Database Migration Service 助力数据库搬迁
|
4月前
|
Oracle 安全 关系型数据库
|
4月前
|
SQL 关系型数据库 MySQL
云服务器 ECS产品使用问题之出现“1044 - Access denied for user ‘root‘@‘%‘ to database ‘数据库名称‘”这样的错误,该怎么办
云服务器ECS(Elastic Compute Service)是各大云服务商阿里云提供的一种基础云计算服务,它允许用户租用云端计算资源来部署和运行各种应用程序。以下是一个关于如何使用ECS产品的综合指南。
|
4月前
|
存储 Oracle 关系型数据库
|
4月前
|
SQL Oracle 关系型数据库
关系型数据库Oracle设置 RMAN 环境:
【7月更文挑战第25天】
67 2
|
4月前
|
监控 Oracle 算法
|
4月前
|
SQL Oracle 关系型数据库
关系型数据库Oracle结束 RMAN 会话:
【7月更文挑战第25天】
82 1
|
6月前
|
SQL Oracle 关系型数据库
WARNING: Too Many Parse Errors With error=911 When Running a JDBC Application Connected to an Oracle 19c database
WARNING: Too Many Parse Errors With error=911 When Running a JDBC Application Connected to an Oracle 19c database (
89 2
|
6月前
|
Oracle 关系型数据库
19c 开启Oracle Database Vault
19c 开启Oracle Database Vault
162 1