Oracle Study之--通过RMAN克隆测试库
通过使用数据库备份,DBA可以在同一服务器或其它服务器上建立副本数据库。这个副本数据库可以和主数据库有相同的名称(拷贝)或与主数据库名称不同(克隆)。ORACLE在数据库拷贝和数据库克隆之间惟一不同的是拷贝的数据库不能更改名称。使用RMAN的复制数据库特性,可以从RMAN备份创建一个新的数据库,并为这个副本数据库保留已有的数据库名称或者赋予新的名称。
RMAN术语和命令:
A.辅助数据库(Auxiliary database):RMAN将目标数据库复制到该数据库实例。要创建该数据库的参数文件、路径和口令文件。必须在RMAN数据库复制之前以非加载(NOMOUNT)模式启动辅助数据库实例。
B.复制(Duplicate):从其它数据库的RMAN备份创建一个新的数据库。要在RMAN执行复制的位置配置数据库并启动Oracle的实例。从RMAN的角度来看,目标数据库被复制到副本数据库。
C.设置新名称(Set newname):在一个RMAN运行块内为数据文件设置新的名称,提供给该参数的文件名称覆盖任何该数据文件的辅助数据库名(用SET AUXNAME)或者辅助数据库参数(DB_FILE_NAME_CONVERT)。这个新名称的值只在运行块内有效。
D.设置辅助名称(Set auxname):为数据文件设置辅助名称,这个辅助名称将在RMAN会话之间存在。如果不希望以后的RMAN命令中使用这个设置的名称,则必须将该名称设置为NULL。
E.日志文件(log file):可以在Duplicate命令中作用这个关键词,以指定副本数据库创建的联机重做日志文件。如果没有特别指定这个关键词,则RMAN将在辅助参数文件中的LOG_FILE_NAME_CONVERT参数决定的路径中生成日志文件。如果没有这个RMAN关键词,而且也没有设置辅助参数,则RMAN将在目标数据库同样的位置创建日志(假设已指定了NOCHECKFILENAME选项)。
F.不检查文件名(Nocheckfilename):默认情况下,RMAN将检查在副本主机上被恢复到主目标数据文件路径下的数据文件,以确保不会被错误地覆盖。使用该选项可以覆盖这个默认的操作。这样就需要手工确保RMAN没有覆盖任何已存在的数据文件。应当谨慎使用这个命令,以防止覆盖数据文件。
在Duplicate命令执行的过程中,RMAN执行了一系列工作。当连接到目标、辅助和或选的目录数据库后,RMAN将进行以下操作:
1) 根据最近发生的或者是提供的恢复停止点来决定复制操作将使用哪个基本的备份。
2) 根据辅助数据库参数或RMAN设置的命令和选项来决定将数据文件保存在辅助数据库实例的什么位置。
3) 为辅助数据库读出备份片或映像拷贝并恢复数据文件。这个RMAN的功能与执行正常的数据库还原是一样的。
4) 根据恢复停止点将任何增量备份应用于还原数据文件。这个增量方式的应用与用RMAN发布恢复数据库命令的任务是一样的。
5) 根据恢复停止点从磁盘或备份将所有归档日志文件应用于还原数据文件。
6) 为辅助数据库创建新的控制文件。
7) 当重新设置联机重做日志文件时,打开副本数据库。新的联机重做日志文件将根据RMAN复制数据库命令中指定的或者根据转换的辅助参数文件进行创建。
系统环境:
环境: RedHat 4 + Oracle 10g
主库库名: db01
克隆库名: clonedb
1、主库db01 ,用rman进行备份(datafile、controlfile、archivelog file)
08:49:43 SQL> show parameter name ;
1
2
3
4
5
6
7
8
9
10
|
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert string
db_name string cuug
db_unique_name string cuug
global_names boolean FALSE
instance_name string cuug
lock_name_space string
log_file_name_convert string
service_names string cuug
|
08:49:53 SQL> select current_scn from v$database;
CURRENT_SCN
-----------
1139339
对数据库进行备份:
1
2
3
4
5
6
7
|
RMAN> run {
2
> allocate channel c1 type disk;
3
> allocate channel c2 type disk;
4
> backup full database format
'/disk2/rman/db01/hot_bak/%d_%s_%t.bak'
;
5
> backup archivelog all format
'/disk2/rman/db01/hot_bak/arch_%s.bak'
;
6
> backup current controlfile format
'/disk2/rman/db01/hot_bak/ctl_%s.bak'
;
7
> }
|
08:58:59 SQL> col file_namr for a50
1
2
3
4
5
6
7
8
9
10
11
12
|
08
:
59
:
19
SQL> select file_id,file_name,tablespace_name from dba_data_files;
FILE_ID FILE_NAME TABLESPACE_NAME
---------- -------------------------------------------------- ------------------------------
5
/u01/app/oracle/oradata/db01/lxtb1.dbf LXTBS1
4
/u01/app/oracle/oradata/db01/users01.dbf USERS
3
/u01/app/oracle/oradata/db01/sysaux01.dbf SYSAUX
2
/u01/app/oracle/oradata/db01/rtbs01.dbf RTBS
1
/u01/app/oracle/oradata/db01/system01.dbf SYSTEM
8
/u01/app/oracle/oradata/db01/undotbs1.dbf UNDOTBS1
11
/u01/app/oracle/oradata/db01/tbsbig.dbf TBS_BIG
12
/u01/app/oracle/oradata/db01/indx01.dbf INDX
6
/u01/app/oracle/oradata/db01/lxtbs2.dbf LXTBS2
|
2、建立pfile 文件
08:59:31 SQL> create pfile from spfile;
File created.
3、建立克隆库的目录
1
2
3
4
|
[oracle@RH4 dbs]$ mkdir -p $ORACLE_BASE/admin/clonedb/bdump
[oracle@RH4 dbs]$ mkdir -p $ORACLE_BASE/admin/clonedb/cdump
[oracle@RH4 dbs]$ mkdir -p $ORACLE_BASE/admin/clonedb/udump
[oracle@RH4 dbs]$ mkdir -p $ORACLE_BASE/oradata/clonedb
|
4、将主库pfile 拷贝生成clone 库的pfile,并生成clone库的口令文件
[oracle@RH4 dbs]$ orapwd file=orapwclonedb.ora password=oracle entries=3;
[oracle@RH4 dbs]$ cp initdb01.ora initclonedb.ora
[oracle@RH4 dbs]$ vi initclonedb.ora
1
2
|
将db01 替换为 clonedb,并增加以下内容:
db_file_name_convert = (
"/u01/app/oracle/oradata/db01"
,
"/u01/app/oracle/oradata/clonedb"
)log_file_name_convert = (
"/disk1/oradata/db01"
,
"/disk1/oradata/clonedb"
,
"/disk2/oradata/db01"
,
"/disk2/oradata/clonedb"
)
|
5、将clone 库启动到nomount
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[oracle
@RH4
dbs]$ export ORACLE_SID=clonedb
[oracle
@RH4
dbs]$ sqlsqlplus
'/as sysdba'
SQL*Plus: Release
10.2
.
0.1
.
0
- Production on Fri Mar
23
09
:
11
:
22
2012
Copyright (c)
1982
,
2005
, Oracle.
All rights reserved.
Connected to an idle instance.
09
:
11
:
22
SQL> startup pfile=$ORACLE_HOME/dbs/initclonedb.ora nomount
ORACLE instance started.
Total System Global Area
314572800
bytes
Fixed Size
1219160
bytes
Variable Size
113247656
bytes
Database Buffers
197132288
bytes
Redo Buffers
2973696
bytes
|
6、对主库的日志进行归档,并将归档日志拷贝到clone库的归档目录下
1
2
3
4
5
6
7
8
9
10
11
12
|
09
:
23
:
47
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- -------------------
1
1
14
10485760
2
YES INACTIVE
1134075
2012
-
03
-
23
05
:
23
:
36
2
1
15
10485760
2
NO CURRENT
1141263
2012
-
03
-
23
08
:
57
:
57
3
1
12
10485760
2
YES INACTIVE
1123738
2012
-
03
-
23
02
:
54
:
16
4
1
13
10485760
2
YES INACTIVE
1126370
2012
-
03
-
23
03
:
23
:
17
09
:
55
:
18
SQL> alter system archive log current;
System altered.
09
:
57
:
35
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- -------------------
1
1
14
10485760
2
YES INACTIVE
1134075
2012
-
03
-
23
05
:
23
:
36
2
1
15
10485760
2
YES ACTIVE
1141263
2012
-
03
-
23
08
:
57
:
57
3
1
16
10485760
2
NO CURRENT
1143553
2012
-
03
-
23
09
:
57
:
35
4
1
13
10485760
2
YES INACTIVE
1126370
2012
-
03
-
23
03
:
23
:
17
|
7、建立clone库的归档目录,并将主库的归档日志拷贝到clone 库下
1
2
3
4
5
6
7
|
[oracle
@RH4
dbs]$ mkdir /disk1/arch/clonedb
[oracle
@RH4
dbs]$ cd /disk1/arch/db01/
[oracle
@RH4
db01]$ ls
arch_1_10_778577586.log arch_1_13_778577586.log arch_1_5_778577586.log arch_1_8_778577586.log
arch_1_11_778577586.log arch_1_14_778577586.log arch_1_6_778577586.log arch_1_9_778577586.log
arch_1_12_778577586.log arch_1_15_778577586.log arch_1_7_778577586.log
[oracle
@RH4
db01]$ cp *.* ../clonedb/
|
[oracle@RH4 db01]$
8、用rman连接主库和clone库
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
|
[oracle@RH4 admin]$ export ORACLE_SID=clonedb
[oracle@RH4 admin]$ rman target sys/oracle@db01 auxiliary sys/oracle
Recovery Manager: Release
10.2.
0.1.
0
- Production
on
Fri Mar
23
10
:
03
:
55
2012
Copyright (c)
1982
,
2005
, Oracle. All rights reserved.
connected to target database: DB01 (DBID=
1408485026
)
connected to auxiliary database: CLONEDB (
not
mounted)
RMAN> list backup;
using target database control file instead of recovery catalog
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
67
Full
344.
21M DISK
00
:
01
:
44
23
-MAR
-12
BP Key:
67
Status: AVAILABLE Compressed: NO Tag: TAG20120323T085547 Piece Name: /disk2/rman/db01/hot_bak/DB01_75_778668947.bak List of Datafiles
in
backup set
67
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1
Full
1141202
23
-MAR
-12
/u01/app/oracle/oradata/db01/system01.dbf
2
Full
1141202
23
-MAR
-12
/u01/app/oracle/oradata/db01/rtbs01.dbf
5
Full
1141202
23
-MAR
-12
/u01/app/oracle/oradata/db01/lxtb1.dbf
8
Full
1141202
23
-MAR
-12
/u01/app/oracle/oradata/db01/undotbs1.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
68
Full
122.
17M DISK
00
:
02
:
03
23
-MAR
-12
BP Key:
68
Status: AVAILABLE Compressed: NO Tag: TAG20120323T085547 Piece Name: /disk2/rman/db01/hot_bak/DB01_74_778668947.bak List of Datafiles
in
backup set
68
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
3
Full
1141201
23
-MAR
-12
/u01/app/oracle/oradata/db01/sysaux01.dbf
4
Full
1141201
23
-MAR
-12
/u01/app/oracle/oradata/db01/users01.dbf6 Full
1141201
23
-MAR
-12
/u01/app/oracle/oradata/db01/lxtbs2.dbf
11
Full
1141201
23
-MAR
-12
/u01/app/oracle/oradata/db01/tbsbig.dbf
12
Full
1141201
23
-MAR
-12
/u01/app/oracle/oradata/db01/indx01.dbf
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
69
29.
16M DISK
00
:
00
:
03
23
-MAR
-12
BP Key:
69
Status: AVAILABLE Compressed: NO Tag: TAG20120323T085758 Piece Name: /disk2/rman/db01/hot_bak/arch_76.bak
List of Archived Logs
in
backup set
69
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1
10
1100972
22
-MAR
-12
1121178
23
-MAR
-12
1
11
1121178
23
-MAR
-12
1123738
23
-MAR
-12
1
12
1123738
23
-MAR
-12
1126370
23
-MAR
-12
1
13
1126370
23
-MAR
-12
1134075
23
-MAR
-12
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
70
7.
91M DISK
00
:
00
:
04
23
-MAR
-12
BP Key:
70
Status: AVAILABLE Compressed: NO Tag: TAG20120323T085758 Piece Name: /disk2/rman/db01/hot_bak/arch_77.bak
List of Archived Logs
in
backup set
70
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1
14
1134075
23
-MAR
-12
1141263
23
-MAR
-12
BS Key Size Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
71
5.
83M DISK
00
:
00
:
01
23
-MAR
-12
BP Key:
71
Status: AVAILABLE Compressed: NO Tag: TAG20120323T085758 Piece Name: /disk2/rman/db01/hot_bak/arch_78.bak
List of Archived Logs
in
backup set
71
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1
5
1095102
22
-MAR
-12
1100449
22
-MAR
-12
1
6
1100449
22
-MAR
-12
1100451
22
-MAR
-12
1
7
1100451
22
-MAR
-12
1100936
22
-MAR
-12
1
8
1100936
22
-MAR
-12
1100938
22
-MAR
-12
1
9
1100938
22
-MAR
-12
1100972
22
-MAR
-12
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
72
Full
7.
14M DISK
00
:
00
:
01
23
-MAR
-12
BP Key:
72
Status: AVAILABLE Compressed: NO Tag: TAG20120323T085810 Piece Name: /disk2/rman/db01/hot_bak/ctl_79.bak Control File Included: Ckp SCN:
1141277
Ckp time:
23
-MAR
-12
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
73
Full
7.
17M DISK
00
:
00
:
02
23
-MAR
-12
BP Key:
73
Status: AVAILABLE Compressed: NO Tag: TAG20120323T085812 Piece Name: /disk1/flash/DB01/autobackup/2012_03_23/o1_mf_s_778669092_7pqlo5fo_.bkp
Control File Included: Ckp SCN:
1141281
Ckp time:
23
-MAR
-12
SPFILE Included: Modification time:
23
-MAR
-12
|
9、用rman 克隆库
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
|
RMAN> duplicate target database to clonedb;
Starting Duplicate Db
at
23
-MAR-12allocated channel: ORA_AUX_DISK_1channel ORA_AUX_DISK_1: sid=
36
devtype=DISK
contents of Memory Script:
{
set until scn
1143553
;
set newname
for
datafile
1
to
"/u01/app/oracle/oradata/clonedb/system01.dbf"
;
set newname
for
datafile
2
to
"/u01/app/oracle/oradata/clonedb/rtbs01.dbf"
;
set newname
for
datafile
3
to
"/u01/app/oracle/oradata/clonedb/sysaux01.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/lxtb1.dbf"
;
set newname
for
datafile
6
to
"/u01/app/oracle/oradata/clonedb/lxtbs2.dbf"
;
set newname
for
datafile
8
to
"/u01/app/oracle/oradata/clonedb/undotbs1.dbf"
;
set newname
for
datafile
11
to
"/u01/app/oracle/oradata/clonedb/tbsbig.dbf"
;
set newname
for
datafile
12
to
"/u01/app/oracle/oradata/clonedb/indx01.dbf"
;
restore check
readonly
clone database ;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
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 restore
at
23
-MAR
-12
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1:
starting datafile backupset restore
channel ORA_AUX_DISK_1:
specifying datafile(s) to restore
from
backup set
restoring datafile
00001
to /u01/app/oracle/oradata/clonedb/system01.dbf
restoring datafile
00002
to /u01/app/oracle/oradata/clonedb/rtbs01.dbf
restoring datafile
00005
to /u01/app/oracle/oradata/clonedb/lxtb1.dbf
restoring datafile
00008
to /u01/app/oracle/oradata/clonedb/undotbs1.dbf
channel ORA_AUX_DISK_1:
reading
from
backup piece /disk2/rman/db01/hot_bak/DB01_75_778668947.bak
channel ORA_AUX_DISK_1: restored backup piece
1
piece handle=/disk2/rman/db01/hot_bak/DB01_75_778668947.bak tag=TAG20120323T085547
channel ORA_AUX_DISK_1: restore complete, elapsed time:
00
:
00
:
47
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore
from
backup set
restoring datafile
00003
to /u01/app/oracle/oradata/clonedb/sysaux01.dbf
restoring datafile
00004
to /u01/app/oracle/oradata/clonedb/users01.dbf
restoring datafile
00006
to /u01/app/oracle/oradata/clonedb/lxtbs2.dbf
restoring datafile
00011
to /u01/app/oracle/oradata/clonedb/tbsbig.dbf
restoring datafile
00012
to /u01/app/oracle/oradata/clonedb/indx01.dbf
channel ORA_AUX_DISK_1:
reading
from
backup piece /disk2/rman/db01/hot_bak/DB01_74_778668947.bak
channel ORA_AUX_DISK_1:
restored backup piece 1piece handle=/disk2/rman/db01/hot_bak/DB01_74_778668947.bak tag=TAG20120323T085547
channel ORA_AUX_DISK_1: restore complete, elapsed time:
00
:
00
:
25
Finished restore
at
23
-MAR
-12
sql statement:
CREATE CONTROLFILE REUSE SET DATABASE
"CLONEDB"
RESETLOGS ARCHIVELOG
MAXLOGFILES
10
MAXLOGMEMBERS
5
MAXDATAFILES
100
MAXINSTANCES
1
MAXLOGHISTORY
292
LOGFILE
GROUP
1
(
'/disk2/oradata/clonedb/redo01a.log'
,
'/disk1/oradata/clonedb/redo01b.log'
) SIZE
10
M REUSE,
GROUP
2
(
'/disk2/oradata/clonedb/redo02a.log'
,
'/disk1/oradata/clonedb/redo02b.log'
) SIZE
10
M REUSE,
GROUP
3
(
'/disk1/oradata/clonedb/redo03b.log'
,
'/disk2/oradata/clonedb/redo03a.log'
) SIZE
10
M REUSE,
GROUP
4
(
'/disk1/oradata/clonedb/redo04b.log'
,
'/disk2/oradata/clonedb/redo04a.log'
) SIZE
10
M REUSE
DATAFILE
'/u01/app/oracle/oradata/clonedb/system01.dbf'
CHARACTER SET ZHS16GBK
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
released channel:
ORA_AUX_DISK_1
datafile
2
switched to datafile copy
input datafile copy recid=
1
stamp=
778673170
filename=/u01/app/oracle/oradata/clonedb/rtbs01.dbf
datafile
3
switched to datafile copy
input datafile copy recid=
2
stamp=
778673170
filename=/u01/app/oracle/oradata/clonedb/sysaux01.dbf
datafile
4
switched to datafile copy
input datafile copy recid=
3
stamp=
778673170
filename=/u01/app/oracle/oradata/clonedb/users01.dbf
datafile
5
switched to datafile copy
input datafile copy recid=
4
stamp=
778673170
filename=/u01/app/oracle/oradata/clonedb/lxtb1.dbf
datafile
6
switched to datafile copy
input datafile copy recid=
5
stamp=
778673170
filename=/u01/app/oracle/oradata/clonedb/lxtbs2.dbf
datafile
8
switched to datafile copy
input datafile copy recid=
6
stamp=
778673171
filename=/u01/app/oracle/oradata/clonedb/undotbs1.dbf
datafile
11
switched to datafile copy
input datafile copy recid=
7
stamp=
778673171
filename=/u01/app/oracle/oradata/clonedb/tbsbig.dbf
datafile
12
switched to datafile copy
input datafile copy recid=
8
stamp=
778673171
filename=/u01/app/oracle/oradata/clonedb/indx01.dbf
contents of Memory Script:
{
set until scn
1143553
;
recover clone database
delete
archivelog ;
}
executing Memory Script
executing command: SET until clause
Starting recover
at
23
-MAR
-12
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=
36
devtype=DISK
starting media recovery
archive log thread
1
sequence
14
is already
on
disk
as
file /disk1/arch/db01/arch_1_14_778577586.log
archive log thread
1
sequence
15
is already
on
disk
as
file /disk1/arch/db01/arch_1_15_778577586.log
archive log filename=/disk1/arch/db01/arch_1_14_778577586.log thread=
1
sequence=
14
archive log filename=/disk1/arch/db01/arch_1_15_778577586.log thread=
1
sequence=
15
media recovery complete, elapsed time:
00
:
00
:
11
Finished recover
at
23
-MAR
-12
contents of Memory Script:
{
shutdown clone;
startup clone nomount ;
}
executing Memory Script
database dismountedOracle instance shut down
connected to auxiliary database (
not
started)
Oracle instance started
Total System Global Area
314572800
bytes
Fixed Size
1219160
bytes
Variable Size
113247656
bytes
Database Buffers
197132288
bytes
Redo Buffers
2973696
bytes
sql statement:
CREATE CONTROLFILE REUSE SET DATABASE
"CLONEDB"
RESETLOGS ARCHIVELOG
MAXLOGFILES
10
MAXLOGMEMBERS
5
MAXDATAFILES
100
MAXINSTANCES
1
MAXLOGHISTORY
292
LOGFILE
GROUP
1
(
'/disk2/oradata/clonedb/redo01a.log'
,
'/disk1/oradata/clonedb/redo01b.log'
) SIZE
10
M REUSE,
GROUP
2
(
'/disk2/oradata/clonedb/redo02a.log'
,
'/disk1/oradata/clonedb/redo02b.log'
) SIZE
10
M REUSE,
GROUP
3
(
'/disk1/oradata/clonedb/redo03b.log'
,
'/disk2/oradata/clonedb/redo03a.log'
) SIZE
10
M REUSE,
GROUP
4
(
'/disk1/oradata/clonedb/redo04b.log'
,
'/disk2/oradata/clonedb/redo04a.log'
) SIZE
10
M REUSE
DATAFILE
'/u01/app/oracle/oradata/clonedb/system01.dbf'
CHARACTER SET ZHS16GBK
contents of Memory Script:
{
set newname
for
tempfile
1
to
"/u01/app/oracle/oradata/clonedb/temp01.dbf"
;
set newname
for
tempfile
2
to
"/u01/app/oracle/oradata/clonedb/tmp01.dbf"
;
switch clone tempfile all;
catalog clone datafilecopy
"/u01/app/oracle/oradata/clonedb/rtbs01.dbf"
;
catalog clone datafilecopy
"/u01/app/oracle/oradata/clonedb/sysaux01.dbf"
;
catalog clone datafilecopy
"/u01/app/oracle/oradata/clonedb/users01.dbf"
;
catalog clone datafilecopy
"/u01/app/oracle/oradata/clonedb/lxtb1.dbf"
;
catalog clone datafilecopy
"/u01/app/oracle/oradata/clonedb/lxtbs2.dbf"
;
catalog clone datafilecopy
"/u01/app/oracle/oradata/clonedb/undotbs1.dbf"
;
catalog clone datafilecopy
"/u01/app/oracle/oradata/clonedb/tbsbig.dbf"
;
catalog clone datafilecopy
"/u01/app/oracle/oradata/clonedb/indx01.dbf"
;
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed temporary file
1
to /u01/app/oracle/oradata/clonedb/temp01.dbf
in
control file
renamed temporary file
2
to /u01/app/oracle/oradata/clonedb/tmp01.dbf
in
control file
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/clonedb/rtbs01.dbf recid=
1
stamp=
778673548
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/clonedb/sysaux01.dbf recid=
2
stamp=
778673548
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/clonedb/users01.dbf recid=
3
stamp=
778673549
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/clonedb/lxtb1.dbf recid=
4
stamp=
778673549
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/clonedb/lxtbs2.dbf recid=
5
stamp=
778673549
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/clonedb/undotbs1.dbf recid=
6
stamp=
778673549
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/clonedb/tbsbig.dbf recid=
7
stamp=
778673549
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/clonedb/indx01.dbf recid=
8
stamp=
778673549
datafile
2
switched to datafile copy
input datafile copy recid=
1
stamp=
778673548
filename=/u01/app/oracle/oradata/clonedb/rtbs01.dbf
datafile
3
switched to datafile copyinput datafile copy recid=
2
stamp=
778673548
filename=/u01/app/oracle/oradata/clonedb/sysaux01.dbf
datafile
4
switched to datafile copy
input datafile copy recid=
3
stamp=
778673549
filename=/u01/app/oracle/oradata/clonedb/users01.dbf
datafile
5
switched to datafile copy
input datafile copy recid=
4
stamp=
778673549
filename=/u01/app/oracle/oradata/clonedb/lxtb1.dbf
datafile
6
switched to datafile copy
input datafile copy recid=
5
stamp=
778673549
filename=/u01/app/oracle/oradata/clonedb/lxtbs2.dbf
datafile
8
switched to datafile copy
input datafile copy recid=
6
stamp=
778673549
filename=/u01/app/oracle/oradata/clonedb/undotbs1.dbf
datafile
11
switched to datafile copy
input datafile copy recid=
7
stamp=
778673549
filename=/u01/app/oracle/oradata/clonedb/tbsbig.dbf
datafile
12
switched to datafile copy
input datafile copy recid=
8
stamp=
778673549
filename=/u01/app/oracle/oradata/clonedb/indx01.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database openedFinished Duplicate Db
at
23
-MAR
-12
|
10、克隆成功,打开clone库,查看
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
|
10
:
13
:
28
SQL> select status
from
v$instance;
STATUS
------------
OPEN
10
:
13
:
33
SQL> select name
from
v$datafile;
NAME
------------------------------------------------------------------------------------------------------------------------------------------------------
/u01/app/oracle/oradata/clonedb/system01.dbf
/u01/app/oracle/oradata/clonedb/rtbs01.dbf
/u01/app/oracle/oradata/clonedb/sysaux01.dbf
/u01/app/oracle/oradata/clonedb/users01.dbf
/u01/app/oracle/oradata/clonedb/lxtb1.dbf
/u01/app/oracle/oradata/clonedb/lxtbs2.dbf
/u01/app/oracle/oradata/clonedb/undotbs1.dbf
/u01/app/oracle/oradata/clonedb/tbsbig.dbf
/u01/app/oracle/oradata/clonedb/indx01.dbf
9
rows selected.
10
:
13
:
40
SQL> select *
from
v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- -------------------
1
1
0
10485760
2
YES UNUSED
0
2
1
0
10485760
2
YES UNUSED
0
3
1
0
10485760
2
YES UNUSED
0
4
1
1
10485760
2
NO CURRENT
1143554
2012
-03
-23
10
:
12
:
30
10
:
13
:
49
SQL> alter system switch logfile;
System altered.
10
:
13
:
56
SQL> /
System altered.
10
:
13
:
57
SQL> /
System altered.
10
:
13
:
58
SQL> /
System altered.
10
:
14
:
03
SQL> select *
from
v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- -------------------
1
1
2
10485760
2
YES INACTIVE
1144304
2012
-03
-23
10
:
13
:
56
2
1
3
10485760
2
YES INACTIVE
1144306
2012
-03
-23
10
:
13
:
57
3
1
4
10485760
2
YES INACTIVE
1144308
2012
-03
-23
10
:
13
:
58
4
1
5
10485760
2
NO CURRENT
1144311
2012
-03
-23
10
:
14
:
03
10
:
14
:
10
SQL>
|