ASM+RAC spfile 恢复 改名

ASMCMD> cd +DATA/CDB/PARAMETERFILE
ASMCMD> ls
spfile.290.1148481317
ASMCMD> rm -rf *
ASMCMD> ls

 srvctl config database -db 'cdb'   ''不用也可以
[oracle@rac1 dbs]$  srvctl modify database -db cdb  -spfile ''----注释掉
[oracle@rac1 dbs]$  srvctl modify database -db cdb  -spfile '+DATA/CDB/PARAMETERFILE/spfile';


srvctl config database -d cdb |grep Spfile

– srvctl修改使用最新的spfile
srvctl modify database -db cdb -spfile ‘+DATA_DG/xxooQBQA/PARAMETERFILE/spfile.1123.1134548913’ 

-----------

– 环境: ORACLE RAC Version 19.15.0.0.0 ASM
– 背景: 因为修改错了sga参数 导致sga_target的值过小, 数据库启动不了报错信息如下
– 重点: 本过程适用于spfile存放在ASM里面的创建, 如果存放在文件系统中,会简单很多,这里不列举

– srvctl start database -d xxooqbqa 启动报错
PRCR-1079 : Failed to start resource ora.xxooqbqa.db
CRS-5017: The resource action “ora.xxooqbqa.db start” encountered the following error:
ORA-01078: failure in processing system parameters
. For details refer to “(:CLSN00107:)” in “/oracle_grid/app/oracle/diag/crs/xxoo180085/crs/trace/crsd_oraagent_ot12c.trc”.

CRS-2674: Start of ‘ora.xxooqbqa.db’ on ‘xxoo180085’ failed
CRS-2632: There are no more servers to try to place resource ‘ora.xxooqbqa.db’ on that would satisfy its placement policy
CRS-5017: The resource action “ora.xxooqbqa.db start” encountered the following error:
ORA-01078: failure in processing system parameters
. For details refer to “(:CLSN00107:)” in “/oracle_grid/app/oracle/diag/crs/xxoo180086/crs/trace/crsd_oraagent_ot12c.trc”.

CRS-2674: Start of ‘ora.xxooqbqa.db’ on ‘xxoo180086’ failed

– sqlplus / as sysdba
SYS@xxooqbqa1> startup
ORA-00821: Specified value of sga_target 10240M is too small, needs to be at least 13600M
ORA-01078: failure in processing system parameters

– 因为spfile存放在ASM,数据库启动不了的情况下, 不能通过下面这种方式进行创建pfile
SYS@xxooqbqa1> create pfile=’/tmp/initfgzcdb.ora.220101’ from spfile;
create pfile=’/tmp/initfgzcdb.ora.220101’ from spfile
*
ERROR at line 1:
ORA-01565: error in identifying file ‘?=/dbs/spfile@.ora’
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7

– 查看使用的spfile
[oracle@xxoo180085 ~]$ srvctl config database -d xxooqbqa|grep Spfile
Spfile: +DATA_DG/xxooQBQA/PARAMETERFILE/spfile.1035.1134491161

– 

 

– 在oracle里面可以读取ASM磁盘里面的二进制文件spfile,将其转为文本格式的pfile
SYS@xxooqbqa1> create pfile=’/tmp/initxxooqbqa1.ora’ from spfile=’+DATA_DG/xxooQBQA/PARAMETERFILE/spfile.1035.1134491161’;

File created.

SYS@xxooqbqa1> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.15.0.0.0
xxoo180085:xxooqbqa1 >

– 修改文本格式的pfile里面的sga_target为20g,原来是10g
vi /tmp/initxxooqbqa1.ora
*.sga_target=20g

– 这是oracle里面看spfile的值还是空值
SYS@xxooqbqa1> show parameter spfile

NAME TYPE VALUE


spfile string
SYS@xxooqbqa1>
SYS@xxooqbqa1>

– 关闭数据库实例
SYS@xxooqbqa1> shutdown immediate
ORA-01507: database not mounted

ORACLE instance shut down.

– 通过修改后的pfile启动
SYS@xxooqbqa1> startup pfile=’/tmp/initxxooqbqa1.ora’ nomount;

– 因为ASM是自动管理的 不能直接在ASM里面指定spfile的文件名
SYS@xxooqbqa1> create spfile=’+DATA_DG/xxooQBQA/PARAMETERFILE/spfile.1036.1134491161’ from pfile=’/tmp/initxxooqbqa1.ora’;
create spfile=’+DATA_DG/xxooQBQA/PARAMETERFILE/spfile.1036.1134491161’ from pfile=’/tmp/initxxooqbqa1.ora’
*
ERROR at line 1:
ORA-17502: ksfdcre:4 Failed to create file +DATA_DG/xxooQBQA/PARAMETERFILE/spfile.1036.1134491161
ORA-15046: ASM file name ‘+DATA_DG/xxooQBQA/PARAMETERFILE/spfile.1036.1134491161’ is not in single-file creation form

– 直接通过pfile创建spfile
SYS@xxooqbqa1> create spfile from pfile=’/tmp/initxxooqbqa1.ora’;

---啥都不带 自动命名

File created.

– 这时候在oracle里面spfile还是为空
SYS@xxooqbqa1> show parameter pfile

NAME TYPE VALUE


spfile string

– srvctl查看配置信息里的spfile还是旧的spfile文件
[oracle@xxoo180085 ~]$ srvctl config database -d xxooqbqa|grep Spfile
Spfile: +DATA_DG/xxooQBQA/PARAMETERFILE/spfile.1035.1134491161

– 实际在ASM里面已将创建了新的spfile文件
[grid@xxoo180085 ~]$ asmcmd ls -l +DATA_DG/xxooQBQA/PARAMETERFILE/
Type Redund Striped Time Sys Name
PARAMETERFILE UNPROT COARSE APR 19 08:00:00 Y spfile.1035.1134491161
PARAMETERFILE UNPROT COARSE APR 19 08:00:00 Y spfile.1123.1134548913

– srvctl修改使用最新的spfile
srvctl modify database -db xxooqbqa -spfile ‘+DATA_DG/xxooQBQA/PARAMETERFILE/spfile.1123.1134548913’ – 指定最新的参数文件

– 确认最新的spfile文件
[oracle@xxoo180085 ~]$ srvctl config database -d xxooqbqa|grep Spfile
Spfile: +DATA_DG/xxooQBQA/PARAMETERFILE/spfile.1123.1134548913

– 停实例
SYS@xxooqbqa1> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.

– srvctl 重启两个实例
srvctl start database xxooqbqa
xxoo180085:xxooqbqa1 > srvctl status database -d xxooqbqa
Instance xxooqbqa1 is running on node xxoo180085
Instance xxooqbqa2 is running on node xxoo180086

-----

 在Oracle中,有一个名叫DUMMY的假实例。

可以用作spfile恢复。

1、export ORACLE_SID=DUMMY

2、rman target /

3、RMAN>startup nomount;

4、使用srvctl工具查找spfile文化路径

      su - grid

      $srvctl config database -d orcl -a

5、su - oracle

      RMAN>restore spfile to '+ASMDATA/orcl/spfileorcl.ora'   from  '/rmanbak/spfile.bak';

6、恢复完成后,停止掉DUMMY实例

      RMAN>shutdown immediate;

      RMAN>quit

7、su - grid

       $srvctl start database -d orcl

8、正常启动,恢复完成。
 

[oracle@rac1 ~]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Sun Jun 2 16:04:01 2024
Version 19.20.0.0.0

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

connected to target database (not started)

RMAN> restore spfile from '+DATA1/CDB/AUTOBACKUP/2024_06_02/s_1170604877.496.1170561677';

Starting restore at 02-JUN-24
using target database control file instead of recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 06/02/2024 16:04:06
RMAN-12010: automatic channel allocation initialization failed
RMAN-06403: could not obtain a fully authorized session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Additional information: 4476
Additional information: -996112533

RMAN> exit


[oracle@rac1 ~]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Sun Jun 2 16:04:32 2024
Version 19.20.0.0.0

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

connected to target database: CDB (DBID=2265125454)

RMAN> shutdown abort

using target database control file instead of recovery catalog
Oracle instance shut down

RMAN> startup nomount pfile=dummy;

connected to target database (not started)
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 06/02/2024 16:05:00
RMAN-04014: startup failed: ORA-01078: failure in processing system parameters
RMAN-04017: startup error description: LRM-00109: could not open parameter file 'dummy'

RMAN> set dbid 2265125454

executing command: SET DBID

RMAN> restore spfile from autobackup;

Starting restore at 02-JUN-24
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 06/02/2024 16:05:51
RMAN-12010: automatic channel allocation initialization failed
RMAN-06403: could not obtain a fully authorized session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Additional information: 4476
Additional information: -996112533

RMAN> set dbid 2265125454

executing command: SET DBID

RMAN> set  CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '+DATA1/CDB/AUTOBACKUP/2024_06_02/s_1170604877.496.1170561677';

executing command: SET CONTROLFILE AUTOBACKUP FORMAT
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of set command at 06/02/2024 16:07:09
RMAN-06403: could not obtain a fully authorized session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Additional information: 4476
Additional information: -996112533

RMAN> show all;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of show command at 06/02/2024 16:07:35
RMAN-06403: could not obtain a fully authorized session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Additional information: 4476
Additional information: -996112533


[oracle@rac1 ~]$ export ORACLE_SID=DUMMY
[oracle@rac1 ~]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Sun Jun 2 16:09:33 2024
Version 19.20.0.0.0

Copyright (c) 1982, 2019, 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/19.0.0/db_1/dbs/initDUMMY.ora'

starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started

Total System Global Area    1073737776 bytes

Fixed Size                     8933424 bytes
Variable Size                276824064 bytes
Database Buffers             780140544 bytes
Redo Buffers                   7839744 bytes

RMAN>  restore spfile from autobackup;

Starting restore at 02-JUN-24
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=185 device type=DISK

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 06/02/2024 16:10:13
RMAN-06495: must explicitly specify DBID with SET DBID command

RMAN>  set dbid 2265125454

executing command: SET DBID

RMAN> exit


Recovery Manager complete.
[oracle@rac1 ~]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Sun Jun 2 16:10:27 2024
Version 19.20.0.0.0

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

connected to target database: DUMMY (not mounted)

RMAN>  restore spfile from '+DATA1/CDB/AUTOBACKUP/2024_06_02/s_1170604877.496.1170561677';

Starting restore at 02-JUN-24
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=162 device type=DISK

channel ORA_DISK_1: restoring spfile from AUTOBACKUP +DATA1/CDB/AUTOBACKUP/2024_06_02/s_1170604877.496.1170561677
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 02-JUN-24

RMAN> exit


Recovery Manager complete.
[oracle@rac1 ~]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Sun Jun 2 16:10:55 2024
Version 19.20.0.0.0

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

connected to target database: DUMMY (not mounted)

RMAN> set dbid 2265125454

executing command: SET DBID

RMAN> restore spfile from autobackup;

Starting restore at 02-JUN-24
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=185 device type=DISK

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20240602
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20240601
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20240531
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20240530
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20240529
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20240528
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20240527
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 06/02/2024 16:11:49
RMAN-06172: no AUTOBACKUP found or specified handle is not a valid copy or piece

RMAN> restore spfile from '+DATA1/CDB/AUTOBACKUP/2024_06_02/s_1170604877.496.1170561677';

Starting restore at 02-JUN-24
using channel ORA_DISK_1

channel ORA_DISK_1: restoring spfile from AUTOBACKUP +DATA1/CDB/AUTOBACKUP/2024_06_02/s_1170604877.496.1170561677
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 02-JUN-24

 

RMAN> show parameters spfile;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "identifier": expecting one of: "all, archivelog, auxiliary, auxname, backup, channel, compression, controlfile, datafile, db_unique_name, default, device, encryption, exclude, incremental, maxsetsize, retention, snapshot, "
RMAN-01008: the bad identifier was: parameters
RMAN-01007: at line 1 column 6 file: standard input

RMAN> restore spfile to '+DATA/CDB/PARAMETERFILE/spfile.290.1148481317'   from  '+DATA1/CDB/AUTOBACKUP/2024_06_02/s_1170604877.496.1170561677';

Starting restore at 02-JUN-24
using channel ORA_DISK_1

channel ORA_DISK_1: restoring spfile from AUTOBACKUP +DATA1/CDB/AUTOBACKUP/2024_06_02/s_1170604877.496.1170561677
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 06/02/2024 16:16:43
ORA-19870: error while restoring backup piece +DATA1/CDB/AUTOBACKUP/2024_06_02/s_1170604877.496.1170561677
ORA-32015: unable to restore SPFILE
ORA-17502: ksfdcre:4 Failed to create file +DATA/CDB/PARAMETERFILE/spfile.290.1148481317
ORA-15046: ASM file name '+DATA/CDB/PARAMETERFILE/spfile.290.1148481317' is not in single-file creation form

RMAN> restore spfile to '+DATA/CDB/PARAMETERFILE/'   from  '+DATA1/CDB/AUTOBACKUP/2024_06_02/s_1170604877.496.1170561677';

Starting restore at 02-JUN-24
using channel ORA_DISK_1

channel ORA_DISK_1: restoring spfile from AUTOBACKUP +DATA1/CDB/AUTOBACKUP/2024_06_02/s_1170604877.496.1170561677
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 02-JUN-24

 

 

 

RMAN> restore spfile to '+DATA/CDB/PARAMETERFILE/spfile'   from  '+DATA1/CDB/AUTOBACKUP/2024_06_02/s_1170604877.496.1170561677';

Starting restore at 02-JUN-24
using channel ORA_DISK_1

channel ORA_DISK_1: restoring spfile from AUTOBACKUP +DATA1/CDB/AUTOBACKUP/2024_06_02/s_1170604877.496.1170561677
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 06/02/2024 16:24:34
ORA-19870: error while restoring backup piece +DATA1/CDB/AUTOBACKUP/2024_06_02/s_1170604877.496.1170561677
ORA-32015: unable to restore SPFILE
ORA-17502: ksfdcre:4 Failed to create file +DATA/CDB/PARAMETERFILE/spfile
ORA-15129: entry 'PARAMETERFILE' does not refer to a valid directory

 ---手动创建folder

RMAN> restore spfile to '+DATA/CDB/PARAMETERFILE/spfile'   from  '+DATA1/CDB/AUTOBACKUP/2024_06_02/s_1170604877.496.1170561677';

Starting restore at 02-JUN-24
using channel ORA_DISK_1

channel ORA_DISK_1: restoring spfile from AUTOBACKUP +DATA1/CDB/AUTOBACKUP/2024_06_02/s_1170604877.496.1170561677
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 02-JUN-24

RMAN> exit


Recovery Manager complete.
[oracle@rac1 ~]$ s

SQL*Plus: Release 19.0.0.0.0 - Production on Sun Jun 2 16:26:30 2024
Version 19.20.0.0.0

Copyright (c) 1982, 2022, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.20.0.0.0

SQL> startup force;
ORA-39511: Start of CRS resource for instance '223' failed with error:[CRS-5702: Resource 'ora.cdb.db' is already running on 'rac1'
CRS-0223: Resource 'ora.cdb.db' has placement error.
clsr_start_resource:260 status:223
clsrapi_start_db:start_asmdbs status:223
]
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.20.0.0.0
[oracle@rac1 ~]$ ps -ef|grep pmon
grid      6394     1  0 15:50 ?        00:00:00 asm_pmon_+ASM1
oracle    8992     1  0 16:09 ?        00:00:00 ora_pmon_cdb1
oracle   11324 11928  0 16:27 pts/0    00:00:00 grep --color=auto pmon
[oracle@rac1 ~]$ kill -9 8992
[oracle@rac1 ~]$ ps -ef|grep cdb1
oracle   11495     1 22 16:27 ?        00:00:00 oraclecdb1 (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle   11512 11928  0 16:27 pts/0    00:00:00 grep --color=auto cdb1
[oracle@rac1 ~]$ srvctl stop database -d cdb
PRCC-1016 : cdb was already stopped
[oracle@rac1 ~]$ srvctl start database -d cdb
PRCC-1014 : cdb was already running
PRCR-1004 : Resource ora.cdb.db is already running
PRCR-1079 : Failed to start resource ora.cdb.db
CRS-2528: Unable to place an instance of 'ora.cdb.db' as all possible servers are occupied by the resource
[oracle@rac1 ~]$ exit
logout
[root@rac1 ~]# reboot

-----名字不好,自动命名来

ASMCMD> cd PARAMETERFILE
ASMCMD> ls
spfile
ASMCMD> ls -ltr
WARNING: option 'r' is deprecated for 'ls'
please use 'reverse'

Type           Redund  Striped  Time             Sys  Name
PARAMETERFILE  UNPROT  COARSE   JUN 02 04:00:00  N    spfile => +DATA/DUMMY/PARAMETERFILE/spfile.290.1170563129
ASMCMD> cd  +DATA/DUMMY
ASMCMD> ls
PARAMETERFILE/
ASMCMD> cd ..
ASMCMD> ls
ASM/
CDB/
DUMMY/
orapwasm
orapwasm_backup
rac-cluster/
ASMCMD> 

RMAN> create pfile='/tmp/pfile.ora' from spfile;

Statement processed

 

RMAN> create spfile from pfile='/tmp/pfile.ora';

Statement processed

RMAN> 

DUMMY/
orapwasm
orapwasm_backup
rac-cluster/
ASMCMD> ls -ltr
WARNING: option 'r' is deprecated for 'ls'
please use 'reverse'

Type           Redund  Striped  Time             Sys  Name
                                                 Y    ASM/
                                                 N    CDB/
                                                 Y    DUMMY/
                                                 Y    rac-cluster/
PASSWORD       UNPROT  COARSE   APR 23 2022      N    orapwasm => +DATA/ASM/PASSWORD/pwdasm.256.1102776155
PASSWORD       UNPROT  COARSE   APR 23 2022      N    orapwasm_backup => +DATA/ASM/PASSWORD/pwdasm.257.1102776607
PARAMETERFILE  UNPROT  COARSE   JUN 02 09:00:00  N    spfilecdb1.ora => +DATA/CDB/PARAMETERFILE/spfile.264.1170582229
ASMCMD>

---dummy 没有了

ASMCMD> rm spfile

ASMCMD> cd  +DATA/DUMMY
ASMCMD-8002: entry 'DUMMY' does not exist in directory '+DATA/'
ASMCMD> 


ASMCMD> pwd
+DATA/cdb/PARAMETERFILE
ASMCMD> ls -ltr
WARNING: option 'r' is deprecated for 'ls'
please use 'reverse'

Type           Redund  Striped  Time             Sys  Name
PARAMETERFILE  UNPROT  COARSE   JUN 02 09:00:00  Y    spfile.264.1170582229
ASMCMD> ls
spfile.264.1170582229
ASMCMD> 

 ------grid下为什么可以重启db 小心

 
[grid@rac1 ~]$ srvctl stop database -d cdb
[grid@rac1 ~]$ srvctl start database -d cdb
[grid@rac1 ~]$ srvctl config database -d cdb |grep Spfile
Spfile: +DATA/CDB/PARAMETERFILE/spfile
[grid@rac1 ~]$ asmcmd
 
ASMCMD> ls +DATA/CDB/PARAMETERFILE/spfile----没有了啊
ASMCMD-8002: entry 'spfile' does not exist in directory '+DATA/CDB/PARAMETERFILE/'
ASMCMD> exit
[grid@rac1 ~]$ srvctl stop database -d cdb
[grid@rac1 ~]$ ps -ef|grep pmon
grid      6379     1  0 16:32 ?        00:00:01 asm_pmon_+ASM1
grid     13079  4445  0 21:51 pts/1    00:00:00 grep --color=auto pmon

[root@rac1 ~]# reboot 看看

SQL> show parameters spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u01/app/oracle/product/19.0.0
                                                 /db_1/dbs/spfilecdb1.ora
SQL> 

ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/19.0.0/db_1/dbs/initcdb3.ora'
SQL> 

[oracle@rac1 ~]$ s

SQL*Plus: Release 19.0.0.0.0 - Production on Sun Jun 2 21:58:49 2024
Version 19.20.0.0.0

Copyright (c) 1982, 2022, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 1048573744 bytes
Fixed Size                  9172784 bytes
Variable Size             620756992 bytes
Database Buffers          411041792 bytes
Redo Buffers                7602176 bytes
Database mounted.
Database opened.
SQL> show parameters spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u01/app/oracle/product/19.0.0
                                                 /db_1/dbs/spfilecdb1.ora

SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.20.0.0.0
[oracle@rac1 ~]$ srvctl config database -d cdb |grep Spfile
Spfile: +DATA/CDB/PARAMETERFILE/spfile
[oracle@rac1 ~]$ srvctl modify database -db cdb -spfile '+data/cdb/PARAMETERFILE/spfile.264.1170582229';
[oracle@rac1 ~]$ s

SQL*Plus: Release 19.0.0.0.0 - Production on Sun Jun 2 22:01:50 2024
Version 19.20.0.0.0

Copyright (c) 1982, 2022, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.20.0.0.0

SQL> startup force;

 NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      +DATA/cdb/PARAMETERFILE/spfile
                                                 .264.1170582229

[oracle@rac1 ~]$ srvctl stop database -d cdb
[oracle@rac1 ~]$ srvctl start  database -d cdb

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

GOAL

 This documents explains the steps required to recover when the parameter files are lost. 

SOLUTION

 The parameter files are read at instance startup time to get instance specific characteristics. Refer Pfile vs SPfile (Doc ID 249664.1)

Following are the various scenarios of recovering from the lost parameter file

SPFILE is lost but the pfile is present.

Rename bad or corrupted spfile from the original location. Then shutdown and restart your database with pfile (init.ora)

SQL> STARTUP PFILE='location/init<SID>.ora‎';

Then finally create spfile from this pfile. The below command will automatically create spfile with its original name.

SQL> Create spfile from pfile='location/init<SID>.ora‎';

Both spfile as well as pfile is lost or corrupted and your database is up.

Parameter files are read while starting up the instance. Hence losing parameter files when the database is up and running wont have huge impact (till next shutdown).

Query V$parameter for the non default parameters

SQL> select name,value from v$parameter where ISDEFAULT=’FALSE’ order by name;

Create pfile with these parameters.

SQL> Create spfile from pfile='location/init<SID>.ora‎';

Restart the database with this newly created spfile.

From 11g, you can directly create the pfile or spfile using the FROM MEMORY clause.

CREATE PFILE [= 'pfile_name' ] FROM { { SPFILE [= 'spfile_name'] } | MEMORY } ;

CREATE SPFILE [= 'spfile_name' ] FROM { { PFILE [= 'pfile_name' ] } | MEMORY } ;

Example:

SQL>create pfile='$ORACLE_HOME/dbs/initdb11g.txt' from memory;

File created.

Refer: Easier Recovery from Loss of SPFILE, 11g new feature (Doc ID 464781.1)

Both spfile as well as pfile is lost or corrupted and your database is down.

In that case you have remaining option to create new pfile using the non-default parameters recorded in the the alert.log file. You can find this in the previous successful startup entries.

You can then start the database using this pfile (init.ora)

SQL> STARTUP PFILE='location/init<SID>.ora‎';

Then finally create spfile from this pfile. The below command will automatically create spfile with its original name.

SQL> Create spfile from pfile='location/init<SID>.ora‎';


IF RMAN autobackup is configured in any of the above situations, you can restore the same.

RMAN> RESTORE SPFILE FROM AUTOBACKUP;

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

  • 17
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值