[20121108]關於克隆資料庫的問題.txt

lfree發表於2012-11-08
[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混淆在一起.避免不必要的問題.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-748676/,如需轉載,請註明出處,否則將追究法律責任。

相關文章