Restoring the SPFILE from Memory

Este artigo abordará a recuperação do arquivo SPFILE de um banco de dados que ainda está em execução, através dos valores usados em memória.

Vamos identificar o diretório e arquivo SPFILE usado em nosso ambiente:

[oracle@oel8 ~]$ sqlplus / as sysdba
 
SQL*Plus: Release 18.0.0.0.0 - Production on Wed Aug 11 21:15:22 2021
Version 18.13.0.0.0
 
Copyright (c) 1982, 2018, Oracle.  All rights reserved.
 
 
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.13.0.0.0
 
SQL> show parameter SPFILE
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /oracle/18.0.0/product/dbs/spf
                                                 ileRMANDB.ora

Deletando o arquivo:

SQL> ! rm /oracle/18.0.0/product/dbs/spfileRMANDB.ora

Apesar disso, o banco de dados ainda opera normalmente:

SQL> SELECT COUNT(*) FROM DBA_OBJECTS ;
 
  COUNT(*)
----------
     73798

Ao rodar um VALIDATE DATABASE, o problema é identificado:

channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
including current control file for validation
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of validate command on ORA_DISK_1 channel at 08/11/2021 21:21:32
ORA-01565: error in identifying file '/oracle/18.0.0/product/dbs/spfileRMANDB.ora'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7

Podemos recuperar o SPFILE com o comando abaixo, usando os valores em memória. Apesar do SPFILE original não existir mais, não é possível recuperar o arquivo com o mesmo nome original:

SQL> CREATE SPFILE='/oracle/18.0.0/product/dbs/spfileRMANDB.ora' FROM MEMORY;
CREATE SPFILE='/oracle/18.0.0/product/dbs/spfileRMANDB.ora' FROM MEMORY
*
ERROR at line 1:
ORA-32002: cannot create SPFILE already being used by the instance

Desse modo, vamos criar um novo SPFILE com um nome diferente, conforme exemplo abaixo:

SQL> CREATE SPFILE='/oracle/18.0.0/product/dbs/spfileRMANDB.BRUNO' FROM MEMORY;
 
File created.

Aí, quando possível, basta baixarmos o banco de dados, renomearmos o SPFILE novo para o nome antigo, e subir a instância:

SQL> SHU IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> ! mv /oracle/18.0.0/product/dbs/spfileRMANDB.BRUNO /oracle/18.0.0/product/dbs/spfileRMANDB.ora
 
SQL> STARTUP;
ORACLE instance started.
 
Total System Global Area 1610612016 bytes
Fixed Size                  8658224 bytes
Variable Size             520093696 bytes
Database Buffers         1073741824 bytes
Redo Buffers                8118272 bytes
Database mounted.
Database opened.
SQL> SHO PARAMETER SPFILE;
 
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /oracle/18.0.0/product/dbs/spf
                                                 ileRMANDB.ora

Obs: Este procedimento foi criado pelo senhor Ahmed Baraka (www.ahmedbaraka.com) e foi apenas reproduzido por mim em um laboratório pessoal para fins de aprendizado.

2 thoughts on “Restoring the SPFILE from Memory”

  1. Pingback: Restoring the SPFILE from the alert.log file – Bruno Santos da Silva

  2. Pingback: Restoring the SPFILE from the alert.log file – SWIV

Leave a Comment

Your email address will not be published.