Disclaimer

Sunday 11 July 2021

Administration of ASM Parameter File (SPFILE)

In this post, we will see how to Backup, Copy and Move an Oracle ASM Initialization Parameter File. Here are some important asmcmd commands used to administer ASM SPFILE

spget        <=Retrieves the location of the Oracle ASM SPFILE
spbackup <=Backs up an Oracle ASM SPFILE to a backup file
spcopy     <=Copies an Oracle ASM SPFILE or an Oracle ASM backup file from source location to an Oracle ASM SPFILE in the destination location
spmove    <=Moves an Oracle ASM SPFILE from source to destination and automatically updates the GPnP profile or OLR

spset        <=Set the location of the ORACLE ASM SPFILE in Grid Plug and Play (GPnP) profile or OLR

How to Backup ASM SPFile

ASMCMD> spget
+DG_TEST_DATA/ASM/ASMPARAMETERFILE/registry.253.978021167

ASMCMD>spbackup +DG_TEST_DATA/ASM/ASMPARAMETERFILE/registry.253.978021167 +DG_TEST_FRA/spfileBackASM.bak

OR
ASMCMD>spcopy +DG_TEST_DATA/ASM/ASMPARAMETERFILE/registry.253.978021167 +DG_TEST_FRA/spfileBackASM.cpy

You can copy SPFILE or backup SPFILE from DG to file system as well

ASMCMD> spbackup +DG_TEST_DATA/ASM/ASMPARAMETERFILE/registry.253.978021167 /u01/oragrid/spfile/spfileBackASM.bak

ASMCMD> spcopy +DG_TEST_DATA/ASM/ASMPARAMETERFILE/registry.253.978021167 /u01/oragrid/spfile/spfileBackASM.cpy




How to Backup ASM SPFile as Text

Login to asm instance as sysasm, find the spfile and backup as text file as shown
SQL> show parameter spfile;
NAME                                 TYPE        VALUE
------------------------------------ ----------- ----------------

spfile                               string      +DG_TEST_DATA/ASM/ASMPARAMETER
                                                 FILE/registry.253.978021167

SQL>

SQL> create pfile='/u01/oragrid/spfile/spfile+ASM.ora' from spfile='+DG_TEST_DATA/ASM/ASMPARAMETERFILE/registry.253.978021167';

File created.




How to Migrate ASM SPfile

Migrating of ASM SPFile requires restart of ASM Instance and therefore leading to downtime

Migrating ASM SPfile  from Diskgroup to File System
$ asmcmd spget
+DG_TEST_FRA/spfileASM.ora

$ asmcmd spmove +DG_TEST_FRA/spfileASM.ora /u01/oragrid/spfile/spfileASM.ora
ORA-15032: not all alterations performed
ORA-15028: ASM file '+DG_TEST_FRA/spfileASM.ora' not dropped; currently being accessed (DBD ERROR: OCIStmtExecute)

Note:- Ignore the error message. Since ASM instance is using the SPFILE I am migrating its unable to move it. But if you check it has already created the target file and updated the OLR 

$ls -lrt /u01/oragrid/spfile/spfileASM.ora
-rw-r----- 1 oragrid oinstall 1536 Jun  8 13:41 /u01/oragrid/spfile/spfileASM.ora
$ asmcmd spget
/u01/oragrid/spfile/spfileASM.ora


Restart ASM instance to start with SPFILE located at file system



Note: You can also use asmcmd spcopy instead of spmove. while using asmcmd spcopy you need to specify -u to update the OLR or GPnP profile about the new location of the spfile. notice the difference in below pic




Migrating ASM SPfile File System to Diskgroup.

the procedure of migrating the ASMSPFILE from file system to ASM is same as from ASM to file system with the mandatory requirement that that COMPATIBLE.ASM attribute of Diskgroup going to hold the SPFILE must be =>11.2

How to Restore the ASM SPFILE from Backup

Note:- The steps will work only if the ASM instance is up and running.

If you have taken the SPFILE backup either of the ways described above (spcopy, spcopy or create pfile from spfile) you can restore the spfile back if you have lost or corrupted the current spfile
The procedure is very simple.
Find SPFILE backup known to ASM

$ asmcmd find --type ASMPARAMETERFILE '*' '*'

+DG_TEST_DATA/ASM/ASMPARAMETERFILE/REGISTRY.253.978270727
+DG_TEST_DATA/ASM/spfileASM.ora
+DG_TEST_FRA/ASM/ASMPARAMETERFILE/REGISTRY.253.978263057
+DG_TEST_FRA/spfileASM.ora



Decide the backup you want to use to restore spfile and ensure the file is physically present

$ asmcmd spset +DG_TEST_DATA/ASM/spfileASM.ora
$ asmcmd spget

+DG_TEST_DATA/ASM/spfileASM.ora


Bounce the ASM instance




How to Restore ASM SPFILE In case ASM is completely down

In this scenario even the backup available on ASM diskgroup will no more be accessible and you can recreate the spfile from pfile if you have one

Else you locate the ASM alert log and find the latest restart entry in alert log and copy the non default parameter. Create a Pfile with having these parameters and then create spfile from this pfile 






No comments:

Post a Comment

100 Oracle DBA Interview Questions and Answers

  Here are 100 tricky interview questions tailored for a Senior Oracle DBA role. These questions span a wide range of topics, including perf...