[oracle@bock admin]$ mkdir -p /u01/app/admin/dp/adump
[oracle@bock admin]$ mkdir -p /u01/app/admin/dp/bdump
[oracle@bock admin]$ mkdir -p /u01/app/admin/dp/cdump
[oracle@bock admin]$ mkdir -p /u01/app/admin/dp/udump
[oracle@bock admin]$ ls -l /u01/app/admin/dp/
total 16
drwxr-xr-x 2 oracle oinstall 4096 Mar 13 09:01 adump
drwxr-xr-x 2 oracle oinstall 4096 Mar 13 09:01 bdump
drwxr-xr-x 2 oracle oinstall 4096 Mar 13 09:01 cdump
drwxr-xr-x 2 oracle oinstall 4096 Mar 13 09:01 udump
[oracle@bock dbs]$ mkdir -p /u01/app/oradata/dp
[oracle@bock dbs]$ ls -l /u01/app/oradata/dp/
total 0
[oracle@bock ~]$ mkdir /u01/app/flash_recovery_area/DP/archivelog
[oracle@bock ~]$ mkdir /u01/app/flash_recovery_area/DP/backupset
[oracle@bock ~]$ mkdir /u01/app/flash_recovery_area/DP/onlinelog
[oracle@bock ~]$ ls -l /u01/app/flash_recovery_area/DP
total 12
drwxr-xr-x 2 oracle oinstall 4096 Mar 13 09:08 archivelog
drwxr-xr-x 2 oracle oinstall 4096 Mar 13 09:08 backupset
drwxr-xr-x 2 oracle oinstall 4096 Mar 13 09:08 onlinelog
[oracle@bock admin]$ orapwd file=$ORACLE_HOME/dbs/orapwdp password=yvh entries=10;
[oracle@bock admin]$ ls -l /u01/app/oracle/dbs/orapwdp
-rw-r----- 1 oracle oinstall 2560 Mar 13 09:03 /u01/app/oracle/dbs/orapwdp
[oracle@bock dbs]$ cat initdp.ora
dp.__db_cache_size=599785472
dp.__java_pool_size=4194304
dp.__large_pool_size=4194304
dp.__shared_pool_size=306184192
dp.__streams_pool_size=0
*.audit_file_dest='/u01/app/admin/dp/adump'
*.background_dump_dest='/u01/app/admin/dp/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/app/oradata/dp/control01.ctl','/u01/app/oradata/dp/control02.ctl','/u01/app/oradata/dp/control03.ctl'
*.core_dump_dest='/u01/app/admin/dp/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='dp'
*.db_recovery_file_dest='/u01/app/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=dpXDB)'
*.job_queue_processes=10
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=307232768
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=921698304
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/admin/dp/udump'
db_file_name_convert=('/u01/app/oradata/orcl', '/u01/app/oradata/dp')
log_file_name_convert=('/u01/app/oradata/orcl', '/u01/app/oradata/dp')
e@bock dbs]$ export ORACLE_SID=dp
[oracle@bock dbs]$ rlwrap sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Mar 13 09:18:44 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
09:18:44 idle>startup nomount;
ORACLE instance started.
Total System Global Area 922746880 bytes
Fixed Size 1222624 bytes
Variable Size 314574880 bytes
Database Buffers 599785472 bytes
Redo Buffers 7163904 bytes
09:18:51 idle>exit
[oracle@bock dbs]$ rlwrap rman target sys/yvh@orcl auxiliary
sys/yvh@dp
Recovery Manager: Release 10.2.0.1.0 - Production on Wed Mar 13 09:21:08 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1337200742)
connected to auxiliary database: DP (not mounted)
RMAN>duplicate target database to dp nofilenamecheck;
Starting restore at 13-MAR-13
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/oradata/dp/system01.dbf
restoring datafile 00002 to /u01/app/oradata/dp/undotbs01.dbf
restoring datafile 00003 to /u01/app/oradata/dp/sysaux01.dbf
restoring datafile 00004 to /u01/app/oradata/dp/users01.dbf
restoring datafile 00005 to /u01/app/oradata/dp/example01.dbf
restoring datafile 00006 to /u01/app/oradata/rman/tbs_rman01.dbf
restoring datafile 00007 to /tmp/test01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/backup/rman/inc0_ORCL_0ko4c95i_1_1
ORA-19870: error reading backup piece /u01/backup/rman/inc0_ORCL_0ko4c95i_1_1
ORA-19504: failed to create file "/u01/app/oradata/rman/tbs_rman01.dbf"
ORA-27086: unable to lock file - already in use
Linux Error: 11: Resource temporarily unavailable
Additional information: 8
Additional information: 5631
failover to previous backup
失败原因:有个catalog表空间已经在使用了,不能取得句柄,所以restore失败,用skip tablespace tbs_rman(rman表空间)
RMAN> duplicate target database to dp nofilenamecheck skip tablespace TBS_RMAN;
Starting Duplicate Db at 13-MAR-13
using channel ORA_AUX_DISK_1
Datafile 6 skipped by request
contents of Memory Script.:
{
set until scn 788844;
set newname for datafile 1 to
"/u01/app/oradata/dp/system01.dbf";
set newname for datafile 2 to
"/u01/app/oradata/dp/undotbs01.dbf";
set newname for datafile 3 to
"/u01/app/oradata/dp/sysaux01.dbf";
set newname for datafile 4 to
"/u01/app/oradata/dp/users01.dbf";
set newname for datafile 5 to
"/u01/app/oradata/dp/example01.dbf";
set newname for datafile 7 to
"/tmp/test01.dbf";
restore
check readonly
clone database
skip tablespace TBS_RMAN ;
}
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
Starting restore at 13-MAR-13
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/oradata/dp/system01.dbf
restoring datafile 00002 to /u01/app/oradata/dp/undotbs01.dbf
restoring datafile 00003 to /u01/app/oradata/dp/sysaux01.dbf
restoring datafile 00004 to /u01/app/oradata/dp/users01.dbf
restoring datafile 00005 to /u01/app/oradata/dp/example01.dbf
restoring datafile 00007 to /tmp/test01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/backup/rman/inc0_ORCL_0ko4c95i_1_1
ORA-19870: error reading backup piece /u01/backup/rman/inc0_ORCL_0ko4c95i_1_1
ORA-19504: failed to create file "/tmp/test01.dbf"
ORA-27086: unable to lock file - already in use
Linux Error: 11: Resource temporarily unavailable
Additional information: 8
Additional information: 5631
failover to previous backup
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 03/13/2013 09:29:57
RMAN-03015: error occurred in stored script. Memory Script
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 7 found to restore
RMAN-06023: no backup or copy of datafile 5 found to restore
RMAN-06023: no backup or copy of datafile 4 found to restore
RMAN-06023: no backup or copy of datafile 3 found to restore
RMAN-06023: no backup or copy of datafile 2 found to restore
RMAN-06023: no backup or copy of datafile 1 found to restore
失败原因:备份时/tmp/test01.dbf也备份了,没法转换,所以失败.
解决办法:在主库上执行:
09:32:20 idle>drop tablespace test including contents and datafiles;
Tablespace dropped.
RMAN> duplicate target database to dp nofilenamecheck skip tablespace tbs_rman;
Starting Duplicate Db at 13-MAR-13
using channel ORA_AUX_DISK_1
Datafile 6 skipped by request
contents of Memory Script.:
{
set until scn 788844;
set newname for datafile 1 to
"/u01/app/oradata/dp/system01.dbf";
set newname for datafile 2 to
"/u01/app/oradata/dp/undotbs01.dbf";
set newname for datafile 3 to
"/u01/app/oradata/dp/sysaux01.dbf";
set newname for datafile 4 to
"/u01/app/oradata/dp/users01.dbf";
set newname for datafile 5 to
"/u01/app/oradata/dp/example01.dbf";
restore
check readonly
clone database
skip tablespace TBS_RMAN ;
}
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
Starting restore at 13-MAR-13
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/oradata/dp/system01.dbf
restoring datafile 00002 to /u01/app/oradata/dp/undotbs01.dbf
restoring datafile 00003 to /u01/app/oradata/dp/sysaux01.dbf
restoring datafile 00004 to /u01/app/oradata/dp/users01.dbf
restoring datafile 00005 to /u01/app/oradata/dp/example01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/backup/rman/inc0_ORCL_0ko4c95i_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/backup/rman/inc0_ORCL_0ko4c95i_1_1 tag=INC0
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 13-MAR-13
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DP" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/app/oradata/dp/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/u01/app/oradata/dp/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/u01/app/oradata/dp/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/u01/app/oradata/dp/system01.dbf'
CHARACTER SET AL32UTF8
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=809948014 filename=/u01/app/oradata/dp/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=809948014 filename=/u01/app/oradata/dp/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=809948014 filename=/u01/app/oradata/dp/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=809948014 filename=/u01/app/oradata/dp/example01.dbf
contents of Memory Script.:
{
set until scn 788844;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 13-MAR-13
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=156 devtype=DISK
datafile 6 not processed because file is offline
starting media recovery
channel ORA_AUX_DISK_1: starting archive log restore to default destination
channel ORA_AUX_DISK_1: restoring archive log
archive log thread=1 sequence=15
channel ORA_AUX_DISK_1: reading from backup piece /u01/backup/rman/inc0_ORCL_0mo4c96n_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/backup/rman/inc0_ORCL_0mo4c96n_1_1 tag=INC0
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
archive log filename=/u01/app/flash_recovery_area/DP/archivelog/2013_03_13/o1_mf_1_15_8mzovhwy_.arc thread=1 sequence=15
channel clone_default: deleting archive log(s)
archive log filename=/u01/app/flash_recovery_area/DP/archivelog/2013_03_13/o1_mf_1_15_8mzovhwy_.arc recid=1 stamp=809948015
media recovery complete, elapsed time: 00:00:03
Finished recover at 13-MAR-13
contents of Memory Script.:
{
shutdown clone;
startup clone nomount ;
}
executing Memory Script
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 922746880 bytes
Fixed Size 1222624 bytes
Variable Size 314574880 bytes
Database Buffers 599785472 bytes
Redo Buffers 7163904 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DP" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/app/oradata/dp/redo01.log' ) SIZE 50 M REUSE,
GROUP 2 ( '/u01/app/oradata/dp/redo02.log' ) SIZE 50 M REUSE,
GROUP 3 ( '/u01/app/oradata/dp/redo03.log' ) SIZE 50 M REUSE
DATAFILE
'/u01/app/oradata/dp/system01.dbf'
CHARACTER SET AL32UTF8
contents of Memory Script.:
{
set newname for tempfile 1 to
"/u01/app/oradata/dp/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oradata/dp/undotbs01.dbf";
catalog clone datafilecopy "/u01/app/oradata/dp/sysaux01.dbf";
catalog clone datafilecopy "/u01/app/oradata/dp/users01.dbf";
catalog clone datafilecopy "/u01/app/oradata/dp/example01.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to /u01/app/oradata/dp/temp01.dbf in control file
cataloged datafile copy
datafile copy filename=/u01/app/oradata/dp/undotbs01.dbf recid=1 stamp=809948038
cataloged datafile copy
datafile copy filename=/u01/app/oradata/dp/sysaux01.dbf recid=2 stamp=809948038
cataloged datafile copy
datafile copy filename=/u01/app/oradata/dp/users01.dbf recid=3 stamp=809948038
cataloged datafile copy
datafile copy filename=/u01/app/oradata/dp/example01.dbf recid=4 stamp=809948038
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=809948038 filename=/u01/app/oradata/dp/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=809948038 filename=/u01/app/oradata/dp/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=809948038 filename=/u01/app/oradata/dp/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=809948038 filename=/u01/app/oradata/dp/example01.dbf
contents of Memory Script.:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
contents of Memory Script.:
{
# drop offline and skipped tablespaces
sql clone "drop tablespace TBS_RMAN including contents cascade constraints";
}
executing Memory Script
sql statement: drop tablespace TBS_RMAN including contents cascade constraints
Finished Duplicate Db at 13-MAR-13
备库:
09:44:36 sys@DP>select dbid,name from v$database;
DBID NAME
---------- ---------
855520645 DP
09:44:48 sys@DP>select name from v$tablespace;
NAME
------------------------------
SYSTEM
TEMP
UNDOTBS1
SYSAUX
USERS
EXAMPLE
TEST
7 rows selected.
test表空间在备库出现,那么/tmp/test01.dbf文件属于备库的数据文件
主库:
09:32:31 idle>select dbid,name from v$database;
DBID NAME
---------- ---------
1337200742 ORCL
09:50:36 idle>select name from v$tablespace;
NAME
------------------------------
SYSTEM
UNDOTBS1
SYSAUX
USERS
TEMP
EXAMPLE
TBS_RMAN
7 rows selected.
因为test表空间被删除了,所以没有出现
结论:
1.把不方便转换的表空间删除后再备份,这样在restore时不会报错
2.对于不需要还原的表空间,用skip tablespace xxx跳过
问题,能否同时跳过多个表空间?如上例我同时跳过两个表空间:test,tbs_rman,应该怎么写?
尝试过两种写法,均失败:
duplicate target database to dp nofilenamecheck skip tablespace tbs_rman,test;
duplicate target database to dp nofilenamecheck skip tablespace tbs_rman,skip tablespace test;
RMAN> duplicate target database to dp nofilenamecheck skip tablespace tbs_rman,test;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "test": expecting one of: "double-quoted-string, identifier, single-quoted-string"
RMAN-01007: at line 1 column 75 file: standard input
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found ";": expecting one of: "allocate, alter, backup, beginline, blockrecover, catalog, change, connect, copy, convert, create, crosscheck, configure, duplicate, debug, delete, drop, exit, endinline, flashback, host, {, library, list, mount, open, print, quit, recover, register, release, replace, report, renormalize, reset, restore, resync, rman, run, rpctest, set, setlimit, sql, switch, spool, startup, shutdown, send, show, test, transport, upgrade, unregister, validate"
RMAN-01007: at line 1 column 79 file: standard input
RMAN> duplicate target database to dp nofilenamecheck skip tablespace tbs_rman,skip tablespace test;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "skip": expecting one of: "double-quoted-string, identifier, single-quoted-string"
RMAN-01007: at line 1 column 75 file: standard input