[20121108]关于克隆数据库的问题.txt
前几天在克隆数据库生产系统数据库时,遇到一个非常奇怪的问题,记录一下:
克隆的机器口令文件,以及spfile以前都存在,实际上很简单,先停止旧数据库,然后改安装目录名(害怕还要使用!),再安装数据库:
startup nomount;
SQL> startup nomount
ORACLE instance started.
Total System Global Area 1.2885E+10 bytes
Fixed Size 2105920 bytes
Variable Size 1660947904 bytes
Database Buffers 1.1207E+10 bytes
Redo Buffers 14667776 bytes
SQL> quit
$ rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on Thu Nov 8 10:32:39 2012
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database: orcl (not mounted)
RMAN> restore controlfile from '/mnt/xxx.backup/controls/xxx_ORCL_20121103_9410_controls';
Starting restore at 2012-11-08 10:32:46
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=814 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output filename=/data/orcl/control01.ctl
output filename=/data/orcl/control02.ctl
output filename=/data/orcl/control03.ctl
Finished restore at 2012-11-08 10:32:49
RMAN> alter database mount;
database mounted
RMAN> restore database until time '2012-11-04 06:00:00';
Starting restore at 2012-11-08 10:30:27
Starting implicit crosscheck backup at 2012-11-08 10:30:27
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=814 devtype=DISK
Crosschecked 138 objects
Finished implicit crosscheck backup at 2012-11-08 10:30:35
Starting implicit crosscheck copy at 2012-11-08 10:30:35
using channel ORA_DISK_1
Finished implicit crosscheck copy at 2012-11-08 10:30:35
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /data/log/ORCL/archivelog/0001_0000000001_793708270.dbf
....
using channel ORA_DISK_1
creating datafile fno=1 name=/data/orcl/system01.dbf
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 11/08/2012 10:30:37
ORA-01180: can not create datafile 1
ORA-01110: data file 1: '/data/orcl/system01.dbf'
--如果restore datafile 6.
RMAN> restore datafile 6;
RMAN-06064: creating datafile fno=6 name=/data/orcl/tools.dbf
RMAN-06177: restore not done; all files readonly, offline, or already restored
RMAN-03091: Finished restore at 10-JUN-10
--奇怪!/data/orcl/tools.dbf根本不存在!
--仔细看前面的信息,可以发现如下:
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /data/log/ORCL/archivelog/0001_0000000001_793708270.dbf
--原来数据库的闪回区有archivelog存在.这样会catalog克隆数据里面的archivelog,使用list incarnation检查:
RMAN> list incarnation ;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 ORCL 1155815272 PARENT 1 2007-07-15 22:02:16
2 2 ORCL 1155815272 CURRENT 3004540661 2012-09-11 10:31:10
--可以发现生产了新的incarnation 2.
--看了一些文档要正确执行:
--reset incarnation database to 1;
--再restore database until time '2012-11-04 06:00:00';估计就可以了.
--我没有采用这个方法,而是rm删除了/data/log/ORCL/archivelog/里面的内容,再重复以上过程,克隆正常!
--看来以后采用这种方式克隆后,一定要nid修改数据库的dbid.避免archivelog混淆在一起.避免不必要的问题.