建立STANDBY数据库时,在ASM上恢复主库的数据文件出现了ORA-15173错误。
主库和备库都是单实例数据库,不过都使用ASM作为存储方式。
在备库上利用主库的备份进行restore database操作,碰到了这个错误:
[oracle@localhost data]$ rman target /
Recovery Manager: Release 10.2.0.3.0 - Production on Sat Feb 12 14:43:29 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: MOBILEDB (DBID=3009911466, not open)
RMAN> restore database;
Starting restore at 12-FEB-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1086 devtype=DISK
file 22 is excluded from whole database backup
file 25 is excluded from whole database backup
file 28 is excluded from whole database backup
file 30 is excluded from whole database backup
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to +ORADG/mobiledb/datafile/system.260.649168943
restoring datafile 00002 to +ORADG/mobiledb/datafile/undotbs1.261.649168949
restoring datafile 00003 to +ORADG/mobiledb/datafile/sysaux.262.649168951
restoring datafile 00004 to +ORADG/mobiledb/datafile/users.264.649168953
restoring datafile 00005 to +ORAG2/mobiledb/datafile/club_stat.dbf
restoring datafile 00006 to +ORAG2/mobiledb/datafile/club_statindx.dbf
.
.
.
restoring datafile 00068 to +ORADG/mobiledb/datafile/users.328.652899937
channel ORA_DISK_1: reading from backup piece /rman_backup/data/df_MOBILEDB_5042_1_1
ORA-19870: error reading backup piece /rman_backup/data/df_MOBILEDB_5042_1_1
ORA-19504: failed to create file "+ORAG2/mobiledb/datafile/club_stat.dbf"
ORA-17502: ksfdcre:4 Failed to create file +ORAG2/mobiledb/datafile/club_stat.dbf
ORA-15173: entry 'mobiledb' does not exist in directory '/'
failover to previous backup
creating datafile fno=1 name=+ORADG/mobiledb/datafile/system.260.649168943
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 02/12/2011 14:50:44
ORA-01180: can not create datafile 1
ORA-01110: data file 1: '+ORADG/mobiledb/datafile/system.260.649168943'
导致这个错误的原因是RESTORE操作不会自动创建非数据库所属的目录,虽然根据控制文件中存储的位置,控制文件应该恢复到mobiledb目录中,但是由于standby数据库和primary数据库的db_unique_name并不相同,因此实际RESTORE之后,数据文件会放在standby数据库db_unique_name对应的名称MOBILEDB_N目录下,对于MOBILEDB_N目录以及其下的DATAFILE、ONLINELOG等目录,RESTORE操作会自动创建,但是mobiledb及其下的目录,RESTORE并不会自动创建,即使这个目录并不会写入内容。
解决方法也很简单,只需要通过asmcmd手工创建对应的目录结构即可:
[oracle@localhost ~]$ export ORACLE_SID=+ASM
[oracle@localhost ~]$ asmcmd
ASMCMD> cd +oradg
ASMCMD> mkdir mobiledb
ASMCMD> cd mobiledb
ASMCMD> mkdir datafile
ASMCMD> ls
datafile/
ASMCMD> cd ..
ASMCMD> ls
MOBILEDB_N/
mobiledb/
ASMCMD> cd +orag2
ASMCMD> mkdir mobiledb
ASMCMD> cd mobiledb
ASMCMD> mkdir datafile
ASMCMD> exit
再次运行RESTORE DATABASE命令,问题解决。
RMAN> restore database;
Starting restore at 12-FEB-11
using channel ORA_DISK_1
file 22 is excluded from whole database backup
file 25 is excluded from whole database backup
file 28 is excluded from whole database backup
file 30 is excluded from whole database backup
本文URL:http://www.bianceng.cn/database/Oracle/201410/45637.htm
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to +ORADG/mobiledb/datafile/system.260.649168943
restoring datafile 00002 to +ORADG/mobiledb/datafile/undotbs1.261.649168949
restoring datafile 00003 to +ORADG/mobiledb/datafile/sysaux.262.649168951
restoring datafile 00004 to +ORADG/mobiledb/datafile/users.264.649168953
restoring datafile 00005 to +ORAG2/mobiledb/datafile/club_stat.dbf
restoring datafile 00006 to +ORAG2/mobiledb/datafile/club_statindx.dbf
.
.
.
restoring datafile 00068 to +ORADG/mobiledb/datafile/users.328.652899937
channel ORA_DISK_1: reading from backup piece /rman_backup/data/df_MOBILEDB_5042_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/rman_backup/data/df_MOBILEDB_5042_1_1 tag=TAG20110212T113309
channel ORA_DISK_1: restore complete, elapsed time: 01:28:47
failover to previous backup
Finished restore at 12-FEB-11