從控制檔案自動備份還原引數檔案

skyin_1603發表於2016-11-08

----從控制檔案自動備份還原伺服器引數檔案:

---前提:檢視快速恢復區的引數:

sys@PROD>show parameter recovery

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_recovery_file_dest                string      /u01/app/oracle/fast_recovery_

                                                 area

db_recovery_file_dest_size           big integer 4182M

recovery_parallelism                 integer     0

sys@PROD>

---修改快速恢復區的路徑:

sys@PROD>alter system set db_recovery_file_dest='/u01/app/FRA';

System altered.

sys@PROD>show parameter recovery

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_recovery_file_dest                string      /u01/app/FRA

db_recovery_file_dest_size           big integer 4182M

recovery_parallelism                 integer     0

sys@PROD>

 

---備份系統表空間:#因為上面是剛剛修改了快速恢復區,這裡需要為了生成一個控制檔案與引數檔案的自動備份檔案#

RMAN>  backup tablespace system;

 

Starting backup at 07-NOV-16

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=17 device type=DISK

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00001 name=/u01/app/oracle/oradata/PROD/system01.dbf

channel ORA_DISK_1: starting piece 1 at 07-NOV-16

channel ORA_DISK_1: finished piece 1 at 07-NOV-16

piece handle=/u01/app/backup/db_0frkarjn_1_1.rmn tag=TAG20161107T143223 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:01:50

Finished backup at 07-NOV-16

 

Starting Control File and SPFILE Autobackup at 07-NOV-16

piece handle=/u01/app/FRA/PROD/autobackup/2016_11_07/o1_mf_s_927297253_d20836cs_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 07-NOV-16

#完成備份。

 

---刪除spfile引數檔案:

[oracle@enmo ~]$ cd $ORACLE_HOME/dbs

[oracle@enmo dbs]$ ls

hc_PROD.dat  init.ora  lkPROD  orapwPROD  snapcf_PROD.f  spfilePROD.ora

[oracle@enmo dbs]$ rm spfilePROD.ora

[oracle@enmo dbs]$ ls

hc_PROD.dat  init.ora  lkPROD  orapwPROD  PROD.ora.bck  snapcf_PROD.f

[oracle@enmo dbs]$ ls spfile*

ls: spfile*: No such file or directory

 

---強行關庫:

sys@PROD>shutdown abort;

ORACLE instance shut down.

sys@PROD>

 

---恢復引數檔案:

[oracle@enmo ~]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Mon Nov 7 14:40:42 2016

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

connected to target database (not started)

RMAN>

RMAN> startup force nomount;

startup failed: ORA-01078: failure in processing system parameters

LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initPROD.ora'

starting Oracle instance without parameter file for retrieval of spfile

Oracle instance started

Total System Global Area    1068937216 bytes

Fixed Size                     2260088 bytes

Variable Size                281019272 bytes

Database Buffers             780140544 bytes

Redo Buffers                   5517312 bytes

RMAN> 

RMAN> run {

2> restore spfile from autobackup

3> recovery area ='/u01/app/FRA'   #指定快速恢復區的路徑#

4> DB_NAME='PROD';  #指定庫名#

5> }

Starting restore at 07-NOV-16

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=19 device type=DISK

 

recovery area destination: /u01/app/FRA

database name (or database unique name) used for search: PROD

channel ORA_DISK_1: AUTOBACKUP /u01/app/FRA/PROD/autobackup/2016_11_07/o1_mf_s_927297253_d20836cs_.bkp found in the recovery area

AUTOBACKUP search with format "%F" not attempted because DBID was not set

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/FRA/PROD/autobackup/2016_11_07/o1_mf_s_927297253_d20836cs_.bkp

channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete

Finished restore at 07-NOV-16

RMAN>

#恢復完成。

--系統檢視生成的引數檔案:

[oracle@enmo dbs]$ ll

total 9560

-rw-rw---- 1 oracle oinstall    1544 Nov  7 14:42 hc_PROD.dat

-rw-r--r-- 1 oracle oinstall    2851 May 15  2009 init.ora

-rw-r----- 1 oracle oinstall      24 Oct 30 21:30 lkPROD

-rw-r----- 1 oracle oinstall    1536 Oct 30 21:36 orapwPROD

-rw-r----- 1 oracle oinstall    2560 Nov  7 14:38 PROD.ora.bck

-rw-r----- 1 oracle oinstall 9748480 Nov  7 14:34 snapcf_PROD.f

-rw-r----- 1 oracle oinstall    2560 Nov  7 14:44 spfilePROD.ora

[oracle@enmo dbs]$

#已經生產新的spfile引數檔案。


--校驗:
sys@PROD>select status from v$instance;

select status from v$instance

*

ERROR at line 1:

ORA-01034: ORACLE not available

Process ID: 14307

Session ID: 1 Serial number: 5

 

sys@PROD>shutdown abort;

ORACLE instance shut down.

sys@PROD>

---重新啟動資料庫:

sys@PROD>startup

ORACLE instance started.

Total System Global Area  835104768 bytes

Fixed Size                  2257840 bytes

Variable Size             507513936 bytes

Database Buffers          322961408 bytes

Redo Buffers                2371584 bytes

Database mounted.

Database opened.

sys@PROD>

sys@PROD>select status from v$instance;

STATUS

------------

OPEN

#引數檔案恢復成功。

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

相關文章