Oracle SPFILE的恢复方式有哪几种?

0    340    1

Tags:

👉 本文共约5315个字,系统预计阅读时间或需20分钟。

目录

    SPFILE的恢复方式有哪几种?

    答案:在数据库还没有关闭的情况下,可以使用如下的SQL从内存中恢复数据库的参数:

    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

    如果数据库已经关闭,但是存在SPFILE的RMAN备份,那么可以使用如下的方式进行恢复:

    l 如果知道数据库的DBID,那么可以按照如下步骤进行恢复:

    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备份,那么可以从告警日志中获取数据库启动所需要的参数。



    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 数据库已经挂掉

    一、 从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

    本人提供Oracle(OCP、OCM)、MySQL(OCP)、PostgreSQL(PGCA、PGCE、PGCM)等数据库的培训和考证业务,私聊QQ646634621或微信dbaup66,谢谢!
    AiDBA后续精彩内容已被站长无情隐藏,请输入验证码解锁本文!
    验证码:
    获取验证码: 请先关注本站微信公众号,然后回复“验证码”,获取验证码。在微信里搜索“AiDBA”或者“dbaup6”或者微信扫描右侧二维码都可以关注本站微信公众号。

    标签:

    Avatar photo

    小麦苗

    学习或考证,均可联系麦老师,请加微信db_bao或QQ646634621

    您可能还喜欢...

    发表回复