備份與恢復系列 十 引數檔案spfile的備份與恢復

snowdba發表於2014-10-02

當我們需要做資料庫遷移時,資料庫版本不變的情況下,備份原庫的spfile並在新的伺服器上恢復可以快速的將資料庫啟動到nomount狀態,並且所有例項引數和原庫保持一致。在單例項的環境下,不適用ASM的時候可以簡單的將spfile複製到新的伺服器,但是在RAC環境下spfile儲存在ASM磁碟組裡,雖然透過ASMCMD也可以進入該路徑下copy出檔案,但是這樣做比較麻煩,還是採用rman比較好。 下面透過一個實驗採用rman的方式在RAC狀態下備份與恢復spfile檔案。

1.使用RMAN備份spfile
[oracle@node1 ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Sep 29 02:25:41 2014

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PROD (DBID=271163854)

RMAN> backup spfile;

Starting backup at 2014-09-29 02:25:58
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=53 instance=PROD1 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 2014-09-29 02:25:58
channel ORA_DISK_1: finished piece 1 at 2014-09-29 02:25:59
piece handle=+ARCH/prod/backupset/2014_09_29/nnsnf0_tag20140929t022558_0.272.859515959 tag=TAG20140929T022558 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2014-09-29 02:25:59

備份路徑在快速恢復區的ASM磁碟組中,為了遷移到新的資料庫,我們可以採用format引數將其複製到到本地磁碟上。

RMAN> backup spfile tag='spfile_bak' format '/backup/spfile.bak';

Starting backup at 2014-09-29 02:29:56
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 2014-09-29 02:29:56
channel ORA_DISK_1: finished piece 1 at 2014-09-29 02:29:57
piece handle=/backup/spfile.bak tag=SPFILE_BAK comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2014-09-29 02:29:57

回引數檔案被複制到本地磁碟的/backup/目錄下就可以方便的複製到其他資料庫伺服器上了。注意RAC環境下不建議使用create pfile from spfile的方法。

2.複製spfile檔案到新伺服器
[oracle@node1 ~]$ scp /backup/spfile.bak oracle@172.16.228.103:/backup

3.在新伺服器上使用RMAN恢復spfile,並採用該spfile啟動資料庫到nomount狀態
確保新伺服器的資料庫是關閉狀態
srvctl stop database -d

在新伺服器還沒有spfile的時候sqlplus無法將例項啟動到nomount狀態,但是可以透過rman啟動到dummy狀態。
RMAN> startup nomount;

RMAN> restroe spfile from '/backup/spfile.bak';




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

相關文章