SQL> startup nomount
ORACLE instance started.
Total System Global Area 1152450560 bytes
Fixed Size 2227704 bytes
Variable Size 687866376 bytes
Database Buffers 452984832 bytes
Redo Buffers 9371648 bytes
SQL> host
[oracle@lmocm192 db_back]$ rman target sys/oracle@DOMINIC auxiliary /
Recovery Manager: Release 11.2.0.3.0 - Production on Mon Sep 9 23:17:12 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: DOMINIC (DBID=1954767264)
connected to auxiliary database: DOMINIC (not mounted)
RMAN> duplicate target database to dominic ;
Starting Duplicate Db at 09-SEP-13
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=10 device type=DISK
contents of Memory Script:
{
sql clone "alter system set db_name =
''DOMINIC'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''DOMINIC'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone primary controlfile;
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''DOMINIC'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''DOMINIC'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 1152450560 bytes
Fixed Size 2227704 bytes
Variable Size 687866376 bytes
Database Buffers 452984832 bytes
Redo Buffers 9371648 bytes
Starting restore at 09-SEP-13
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=133 device type=DISK
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/db_back/20130909.CTL
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/db_back/20130909.CTL tag=TAG20130909T152516
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/u01/app/oracle/dominic/controlfile/current.260.825093345
output file name=/u01/app/oracle/oradata/controlfile/current.256.825093345
Finished restore at 09-SEP-13
database mounted
Using previous duplicated file /u01/app/oracle/oradata/dominic/system.256.825091903 for datafile 1 with checkpoint SCN of 2318677
Using previous duplicated file /u01/app/oracle/oradata/dominic/sysaux.257.825091907 for datafile 2 with checkpoint SCN of 2318677
Using previous duplicated file /u01/app/oracle/oradata/dominic/undotbs1.258.825091909 for datafile 3 with checkpoint SCN of 2318657
Using previous duplicated file /u01/app/oracle/oradata/dominic/users.259.825091909 for datafile 4 with checkpoint SCN of 2318657
Using previous duplicated file /u01/app/oracle/oradata/dominic/example.264.825093429 for datafile 5 with checkpoint SCN of 2318677
Using previous duplicated file /u01/app/oracle/oradata/dominic/undotbs2.265.825093865 for datafile 6 with checkpoint SCN of 2318657
Using previous duplicated file /u01/app/oracle/oradata/dominic/gta_dcsys_data.269.825163105 for datafile 7 with checkpoint SCN of 2318657
contents of Memory Script:
{
set until scn 2996999;
set newname for datafile 1 to
"/u01/app/oracle/oradata/dominic/system.256.825091903";
set newname for datafile 2 to
"/u01/app/oracle/oradata/dominic/sysaux.257.825091907";
set newname for datafile 3 to
"/u01/app/oracle/oradata/dominic/undotbs1.258.825091909";
set newname for datafile 4 to
"/u01/app/oracle/oradata/dominic/users.259.825091909";
set newname for datafile 5 to
"/u01/app/oracle/oradata/dominic/example.264.825093429";
set newname for datafile 6 to
"/u01/app/oracle/oradata/dominic/undotbs2.265.825093865";
set newname for datafile 7 to
"/u01/app/oracle/oradata/dominic/gta_dcsys_data.269.825163105";
}
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
contents of Memory Script:
{
catalog clone datafilecopy "/u01/app/oracle/oradata/dominic/system.256.825091903",
"/u01/app/oracle/oradata/dominic/sysaux.257.825091907",
"/u01/app/oracle/oradata/dominic/undotbs1.258.825091909",
"/u01/app/oracle/oradata/dominic/users.259.825091909",
"/u01/app/oracle/oradata/dominic/example.264.825093429",
"/u01/app/oracle/oradata/dominic/undotbs2.265.825093865",
"/u01/app/oracle/oradata/dominic/gta_dcsys_data.269.825163105";
switch clone datafile 1 to datafilecopy
"/u01/app/oracle/oradata/dominic/system.256.825091903";
switch clone datafile 2 to datafilecopy
"/u01/app/oracle/oradata/dominic/sysaux.257.825091907";
switch clone datafile 3 to datafilecopy
"/u01/app/oracle/oradata/dominic/undotbs1.258.825091909";
switch clone datafile 4 to datafilecopy
"/u01/app/oracle/oradata/dominic/users.259.825091909";
switch clone datafile 5 to datafilecopy
"/u01/app/oracle/oradata/dominic/example.264.825093429";
switch clone datafile 6 to datafilecopy
"/u01/app/oracle/oradata/dominic/undotbs2.265.825093865";
switch clone datafile 7 to datafilecopy
"/u01/app/oracle/oradata/dominic/gta_dcsys_data.269.825163105";
}
executing Memory Script
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dominic/system.256.825091903 RECID=10 STAMP=825722444
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dominic/sysaux.257.825091907 RECID=11 STAMP=825722444
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dominic/undotbs1.258.825091909 RECID=12 STAMP=825722444
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dominic/users.259.825091909 RECID=13 STAMP=825722444
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dominic/example.264.825093429 RECID=14 STAMP=825722444
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dominic/undotbs2.265.825093865 RECID=15 STAMP=825722444
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dominic/gta_dcsys_data.269.825163105 RECID=16 STAMP=825722444
datafile 1 switched to datafile copy
input datafile copy RECID=10 STAMP=825722444 file name=/u01/app/oracle/oradata/dominic/system.256.825091903
datafile 2 switched to datafile copy
input datafile copy RECID=11 STAMP=825722444 file name=/u01/app/oracle/oradata/dominic/sysaux.257.825091907
datafile 3 switched to datafile copy
input datafile copy RECID=12 STAMP=825722444 file name=/u01/app/oracle/oradata/dominic/undotbs1.258.825091909
datafile 4 switched to datafile copy
input datafile copy RECID=13 STAMP=825722444 file name=/u01/app/oracle/oradata/dominic/users.259.825091909
datafile 5 switched to datafile copy
input datafile copy RECID=14 STAMP=825722444 file name=/u01/app/oracle/oradata/dominic/example.264.825093429
datafile 6 switched to datafile copy
input datafile copy RECID=15 STAMP=825722444 file name=/u01/app/oracle/oradata/dominic/undotbs2.265.825093865
datafile 7 switched to datafile copy
input datafile copy RECID=16 STAMP=825722444 file name=/u01/app/oracle/oradata/dominic/gta_dcsys_data.269.825163105
contents of Memory Script:
{
set until scn 2996999;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 09-SEP-13
using channel ORA_AUX_DISK_1
starting media recovery
Oracle instance started
Total System Global Area 1152450560 bytes
Fixed Size 2227704 bytes
Variable Size 687866376 bytes
Database Buffers 452984832 bytes
Redo Buffers 9371648 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''DOMINIC'' comment=
''Reset to original value by RMAN'' scope=spfile";
sql clone "alter system reset db_unique_name scope=spfile";
shutdown clone immediate;
}
executing Memory Script
sql statement: alter system set db_name = ''DOMINIC'' comment= ''Reset to original value by RMAN'' scope=spfile
sql statement: alter system reset db_unique_name scope=spfile
Oracle instance shut down
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 09/09/2013 23:20:57
RMAN-05501: aborting duplication of target database
RMAN-03015: error occurred in stored script Memory Script
RMAN-06053: unable to perform media recovery because of missing log
RMAN-06025: no backup of archived log for thread 2 with sequence 46 and starting SCN of 2990968 found to restore
RMAN-06025: no backup of archived log for thread 2 with sequence 45 and starting SCN of 2990878 found to restore
RMAN-06025: no backup of archived log for thread 2 with sequence 44 and starting SCN of 2904738 found to restore
RMAN-06025: no backup of archived log for thread 2 with sequence 43 and starting SCN of 2811911 found to restore
RMAN-06025: no backup of archived log for thread 2 with sequence 42 and starting SCN of 2768543 found to restore
RMAN-06025: no backup of archived log for thread 2 with sequence 41 and starting SCN of 2698110 found to restore
RMAN-06025: no backup of archived log for thread 2 with sequence 40 and starting SCN of 2665715 found to restore
RMAN-06025: no backup of archived log for thread 2 with sequence 39 and starting SCN of 2561227 found to restore
RMAN-06025: no backup of archived log for thread 2 with sequence 38 and starting SCN of 2468986 found to restore
RMAN-06025: no backup of archived log for thread 2 with sequence 37 and starting SCN of 2380959 found to restore
RMAN-06025: no backup of archived log for thread 2 with sequence 36 and starting SCN of 2318917 found to restore
RMAN-06025: no backup of archived log for thread 2 with sequence 35 and starting SCN of 2318877 found to restore
RMAN-06025: no backup of archived log for thread 2 with sequence 34 and starting SCN of 2318176 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 72 and starting SCN of 2975716 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 71 and starting SCN of 2897150 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 70 and starting SCN of 2831168 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 69 and starting SCN of 2723427 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 68 and starting SCN of 2612996 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 67 and starting SCN of 2525003 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 66 and starting SCN of 2418165 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 65 and starting SCN of 2318921 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 64 and starting SCN of 2318880 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 63 and starting SCN of 2318172 found to restore
---这个报错,是应为在dominic2 目录下,而dominic1 不能访问dominic2 目录下的文件(不是aSM)。 这是说这几个归档数据文件丢失,如果这样的话,可以这样备(冷备)执行一样。就不会报这错了。
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/orcl/temp.263.736599505";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/orcl/undotbs1.258.736598599";
catalog clone datafilecopy "/u01/app/oracle/oradata/orcl/sysaux.257.736598563";
catalog clone datafilecopy "/u01/app/oracle/oradata/orcl/users.259.736598641";
catalog clone datafilecopy "/u01/app/oracle/oradata/orcl/undotbs2.264.736599805";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to /u01/app/oracle/oradata/orcl/temp.263.736599505 in control file
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/orcl/undotbs1.258.736598599 recid=1 stamp=737150639
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/orcl/sysaux.257.736598563 recid=2 stamp=737150640
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/orcl/users.259.736598641 recid=3 stamp=737150641
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/orcl/undotbs2.264.736599805 recid=4 stamp=737150642
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=737150639 filename=/u01/app/oracle/oradata/orcl/undotbs1.258.736598599
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=737150640 filename=/u01/app/oracle/oradata/orcl/sysaux.257.736598563
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=737150641 filename=/u01/app/oracle/oradata/orcl/users.259.736598641
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=737150642 filename=/u01/app/oracle/oradata/orcl/undotbs2.264.736599805
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 07-DEC-10
RMAN>
至此,RMAN的duplicate 已经完成。 迁移基本完成。
8,单实例后续扫尾工作。
8.1 :清除多余的undo文件
查看UNDO 信息:
SQL> select name from v$tablespace where name like 'UNDO%';
NAME
------------------------------
UNDOTBS1
UNDOTBS2
因为我们使用的是UNDOTBS1,在pfile里设置的,所以把UNDOTBS2删除掉。
SQL> show parameter undo_tablespace;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_tablespace string UNDOTBS1
SQL> drop tablespace undotbs2 including contents and datafiles;
Tablespace dropped.
SQL> select name from v$tablespace where name like 'UNDO%';
NAME
------------------------------
UNDOTBS1
8.2 :清除未使用线程的redo日志组
默认情况下,RAC 环境下,每个实例都有2个redo。 在单实例下,就没有必要了。 我们删除点线程2的redo 信息。
SQL> select thread#,status,enabled from v$thread;
THREAD# STATUS ENABLED
---------- ------ --------
1 OPEN PUBLIC
2 CLOSED PRIVATE
SQL> select group#,thread#,archived,status from v$log;
GROUP# THREAD# ARC STATUS
---------- ---------- --- ----------------
1 1 YES UNUSED
2 1 NO CURRENT
3 2 NO CURRENT
4 2 YES UNUSED
SQL> alter database disable thread 2;
Database altered.
SQL> alter database clear unarchived logfile group 3;
Database altered.
SQL> alter database drop logfile group 3;
Database altered.
SQL> alter database drop logfile group 4;
Database altered.
SQL> select group#,thread#,archived,status from v$log;
GROUP# THREAD# ARC STATUS
---------- ---------- --- ----------------
1 1 YES INACTIVE
2 1 NO CURRENT
现在就剩2个了。 一般的单实例是3个online redo。 我们在添加一组。
SQL> alter database add logfile group 3 ('/u01/app/oracle/oradata/orcl/redo03.log') size 10m;
Database altered.
SQL> select group#,thread#,archived,status from v$log;
GROUP# THREAD# ARC STATUS
---------- ---------- --- ----------------
1 1 YES INACTIVE
2 1 NO CURRENT
3 1 YES UNUSED
8.3: 重建临时表空间,并删除原来的数据文件
SQL> select file#,name from v$tempfile;
FILE# NAME
---------- ---------------------------------------------------------------------
1 /u01/app/oracle/oradata/orcl/temp.263.736599505
8.4: OEM 配置
(1)创建一个EM资料库
emca -reposcreate
(2)重建一个EM资料库
emca -reposrecreate
(3)删除一个EM资料库
emca -reposdrop
(4)配置数据库的DatabaseControl
emca -configdbcontrol db
(5)删除数据库的DatabaseControl配置
emca -deconfigdbcontrol db
(6)重新配置db control的端口,默认端口在1158
emca -reconfigports
emca -reconfigports -dbcontrol_http_port 1160
emca -reconfigports -agent_port 3940
(7)先设置ORACLE_SID环境变量后,启动EM console服务
emctl startdbconsole
(8)先设置ORACLE_SID环境变量后,停止EM console服务
emctl stopdbconsole
(9)先设置ORACLE_SID环境变量后,查看EM console服务的状态
emctl statusdbconsole
(10)配置dbconsole的步骤
emca -reposcreate
emca -configdbcontrol db
emctl startdbconsole
(11)重新配置dbconsole的步骤
emca -reposdrop
emca -reposcreate
emca -configdbcontrol db
emctl startdbconsole
我们的db是11.2.0.3的。
(1)删除dbcontrol 和repository:
<ORACLE_HOME>/bin/emca -deconfig dbcontrol db -repos drop
(2)重新创建dbcontrol 和repository:
<ORACLE_HOME>bin/emca -config dbcontrol db -repos create