【RMAN】SPFILE的恢復方式有哪幾種?

【RMAN】SPFILE的恢復方式有哪幾種?


真題一、SPFILE的恢復方式有哪幾種?數據庫

答案:在數據庫尚未關閉的狀況下,能夠使用以下的SQL從內存中恢復數據庫的參數:oracle

create spfile from memory;app

create spfile='/home/oracle/spfileOCPLHR1.ora' from memory;dom

create pfile from memory;ide

create spfile from pfile;spa

除非必要,應該將如下劃線開頭的隱含參數刪掉:.net

grep -v '^(_|#).' initlhrdb.ora > initlhrdb.ora2rest

若是數據庫已經關閉,可是存在SPFILE的RMAN備份,那麼能夠使用以下的方式進行恢復:日誌

l  若是知道數據庫的DBID,那麼能夠按照以下步驟進行恢復:orm

startup nomount

set dbid 9815108;

restore spfile from autobackup;--已鏈接到了catalog恢復目錄數據庫

shutdown immediate

set dbid 9815108;

startup;

l  若是不知道數據庫的DBID,那麼能夠按照以下步驟進行恢復:

① startup nomount;

② restore spfile from '備份文件';

③ shutdown immediate;

④ startup;

l  若是沒有關於SPFILE的RMAN備份,那麼能夠從告警日誌中獲取數據庫啓動所須要的參數。

& 說明:

有關SPFILE的恢復能夠參考個人BLOG:http://blog.itpub.net/26736162/viewspace-2152507/

 

 





4.5.2  spfile 丟失

4.5.2.1  數據庫沒有掛掉

create spfile from memory;


create spfile='/home/oracle/spfileOCPLHR1.ora' from memory;


create pfile from memory;

create spfile from pfile;


 


除非必要,應該將如下劃線開頭的隱含參數刪掉:

grep -v '^(_|#).' initlhrdb.ora > initlhrdb.ora2



4.5.2.2  數據庫已經掛掉

1、 從rman的自動備份中找回


若是知道數據庫的DBID,那麼:

startup nomount

set dbid 9815108;

restore spfile from autobackup;--已鏈接到了catalog恢復目錄數據庫

shutdown immediate

set dbid 9815108;

startup;


若是不知道dbid能夠這樣作:

① startup nomount;

② restore spfile from '備份文件';

③ shutdown immediate;

④ startup;



restore spfile from autobackup; 能夠成功的前提是鏈接到了catalog恢復目錄數據庫。


[oracle@OCPLHR dbs]$ rman target /


Recovery Manager: Release 11.2.0.3.0 - Production on Sun Mar 25 20:29:42 2018


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


connected to target database (not started)


RMAN> startup 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/initOCPLHR1.ora'


starting Oracle instance without parameter file for retrieval of spfile

Oracle instance started


Total System Global Area     158662656 bytes


Fixed Size                     2226456 bytes

Variable Size                130025192 bytes

Database Buffers              20971520 bytes

Redo Buffers                   5439488 bytes


RMAN> restore spfile from autobackup; 


Starting restore at 2018-03-25 20:30:08

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=429 device type=DISK


RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of restore command at 03/25/2018 20:30:08

RMAN-06495: must explicitly specify DBID with SET DBID command


RMAN> SET DBID 2909198110


executing command: SET DBID


RMAN>  restore spfile from autobackup;


Starting restore at 2018-03-25 20:30:24

using channel ORA_DISK_1


channel ORA_DISK_1: looking for AUTOBACKUP on day: 20180325

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20180324

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20180323

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20180322

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20180321

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20180320

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20180319

channel ORA_DISK_1: no AUTOBACKUP in 7 days found

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of restore command at 03/25/2018 20:30:26

RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece


RMAN> exit



Recovery Manager complete.

[oracle@OCPLHR dbs]$ 

[oracle@OCPLHR dbs]$ rman target /  catalog rc_admin/rc_admin@ocplhr2


Recovery Manager: Release 11.2.0.3.0 - Production on Sun Mar 25 20:31:23 2018


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


connected to target database: DUMMY (not mounted)

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-00554: initialization of internal recovery manager package failed

RMAN-04004: error from recovery catalog database: ORA-01017: invalid username/password; logon denied

[oracle@OCPLHR dbs]$ 

[oracle@OCPLHR dbs]$ 

[oracle@OCPLHR dbs]$ rman target /  catalog rc_admin/lhr@ocplhr2     


Recovery Manager: Release 11.2.0.3.0 - Production on Sun Mar 25 20:31:32 2018


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


connected to target database: DUMMY (not mounted)

connected to recovery catalog database


RMAN> 


RMAN>  restore spfile from autobackup;


Starting restore at 2018-03-25 20:31:38

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=429 device type=DISK


channel ORA_DISK_1: looking for AUTOBACKUP on day: 20180325

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20180324

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20180323

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20180322

channel ORA_DISK_1: AUTOBACKUP found: /bak/cf_c-2909198110-20180322-0e.ctl

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /bak/cf_c-2909198110-20180322-0e.ctl

channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete

Finished restore at 2018-03-25 20:31:41


RMAN> exit



Recovery Manager complete.

[oracle@OCPLHR dbs]$ ll

total 9764

-rw-rw---- 1 oracle oinstall    1544 Mar 25 20:29 hc_OCPLHR1.dat

-rw-rw---- 1 oracle oinstall    1544 Mar 22 20:02 hc_OCPLHR2.dat

-rw-r----- 1 oracle oinstall      24 Mar 25 20:26 lkDUMMY

-rw-r----- 1 oracle oinstall      24 Jan 17 20:08 lkOCPLHR1

-rw-r----- 1 oracle oinstall      24 Jan 17 20:16 lkOCPLHR2

-rw-r----- 1 oracle oinstall    1536 Mar 25 20:09 orapwOCPLHR1

-rw-r----- 1 oracle oinstall    1536 Jan 17 20:25 orapwOCPLHR2

-rw-r----- 1 oracle oinstall 9945088 Mar 22 21:24 snapcf_OCPLHR1.f

-rw-r----- 1 oracle oinstall    3584 Mar 25 20:31 spfileOCPLHR1.ora

-rw-r----- 1 oracle oinstall    2560 Mar 25 19:54 spfileOCPLHR2.ora

[oracle@OCPLHR dbs]$ rman target /


Recovery Manager: Release 11.2.0.3.0 - Production on Sun Mar 25 20:32:26 2018


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


connected to target database: DUMMY (not mounted)


RMAN> shutdown abort


using target database control file instead of recovery catalog

Oracle instance shut down


RMAN> exit



Recovery Manager complete.

[oracle@OCPLHR dbs]$ echo $ORACLE_SID

OCPLHR1

[oracle@OCPLHR dbs]$ rman target /   


Recovery Manager: Release 11.2.0.3.0 - Production on Sun Mar 25 20:32:47 2018


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


connected to target database (not started)


RMAN> startup 


Oracle instance started

database mounted

database opened


Total System Global Area     521936896 bytes


Fixed Size                     2229944 bytes

Variable Size                297797960 bytes

Database Buffers             213909504 bytes

Redo Buffers                   7999488 bytes


RMAN> 



若是不知道dbid能夠這樣作:

⑤ startup nomount;

⑥ restore spfile from '備份文件';

⑦ shutdown immediate;

⑧ startup;


(一)startup nomount

 [oracle@OCPLHR dbs]$ rman target /


Recovery Manager: Release 11.2.0.3.0 - Production on Sun Mar 25 20:19:00 2018


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


connected to target database (not started)


RMAN> startup 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/initOCPLHR1.ora'


starting Oracle instance without parameter file for retrieval of spfile

Oracle instance started


Total System Global Area     158662656 bytes


Fixed Size                     2226456 bytes

Variable Size                130025192 bytes

Database Buffers              20971520 bytes

Redo Buffers                   5439488 bytes


RMAN> 


[oracle@OCPLHR oracle]$ rman target /


Recovery Manager: Release 11.2.0.3.0 - Production on Sun Mar 25 20:22:43 2018


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


connected to target database: DUMMY (not mounted)




[oracle@OCPLHR ~]$ ps -ef|grep pmon

oracle   13806     1  0 18:07 ?        00:00:00 ora_pmon_OCPLHR2

oracle   15930     1  0 20:19 ?        00:00:00 ora_pmon_OCPLHR1

oracle   15969 15657  0 20:19 pts/0    00:00:00 grep pmon


(二)restore spfile from '備份文件'

[oracle@OCPLHR oracle]$ rman target /


Recovery Manager: Release 11.2.0.3.0 - Production on Sun Mar 25 20:22:43 2018


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


connected to target database: DUMMY (not mounted)


RMAN> 


RMAN> 


RMAN> restore spfile from '/bak/OCPLHR1/spfile_OCPLHR1x_1ssuevao_1_1_20180322.bak';


Starting restore at 2018-03-25 20:23:55

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=429 device type=DISK


channel ORA_DISK_1: restoring spfile from AUTOBACKUP /bak/OCPLHR1/spfile_OCPLHR1x_1ssuevao_1_1_20180322.bak

channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete

Finished restore at 2018-03-25 20:23:57


RMAN> exit



Recovery Manager complete.



[oracle@OCPLHR dbs]$ rman target /   


Recovery Manager: Release 11.2.0.3.0 - Production on Sun Mar 25 20:27:03 2018


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


connected to target database: DUMMY (not mounted)


RMAN> shutdown abort


using target database control file instead of recovery catalog

Oracle instance shut down


RMAN> exit



Recovery Manager complete.

[oracle@OCPLHR dbs]$ rman target /


Recovery Manager: Release 11.2.0.3.0 - Production on Sun Mar 25 20:27:12 2018


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


connected to target database (not started)


RMAN> startup nomount


Oracle instance started


Total System Global Area     521936896 bytes


Fixed Size                     2229944 bytes

Variable Size                293603656 bytes

Database Buffers             218103808 bytes

Redo Buffers                   7999488 bytes


RMAN> 







2、 手動建立

手動建立,建立的時候參數的值能夠從告警日誌中找見。

Starting up:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options.

ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1

System name:    Linux

Node name:      OCPLHR

Release:        2.6.18-194.el5

Version:        #1 SMP Tue Mar 16 21:52:39 EDT 2010

Machine:        x86_64

VM name:        VMWare Version: 6

Using parameter settings in server-side spfile /u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileOCPLHR1.ora

System parameters with non-default values:

  processes                = 150

  sga_max_size             = 500M

  control_files            = "/u01/app/oracle/oradata/OCPLHR1/control01.ctl"

  control_files            = "/u01/app/oracle/fast_recovery_area/OCPLHR1/control02.ctl"

  db_block_size            = 8192

  compatible               = "11.2.0.0.0"

  log_archive_format       = "%t_%s_%r.dbf"

  db_recovery_file_dest    = "/u01/app/oracle/fast_recovery_area"

  db_recovery_file_dest_size= 4122M

  undo_tablespace          = "UNDOTBS1"

  remote_login_passwordfile= "EXCLUSIVE"

  db_domain                = ""

  dispatchers              = "(PROTOCOL=TCP) (SERVICE=OCPLHR1XDB)"

  audit_file_dest          = "/u01/app/oracle/admin/OCPLHR1/adump"

  audit_trail              = "DB"

  db_name                  = "OCPLHR1"

  open_cursors             = 300

  diagnostic_dest          = "/u01/app/oracle"

相關文章
相關標籤/搜索