ASM Instance ORA-04031: unable to allocate 232 bytes of shared memory (“shared pool”,”select ks.inst_id,ksuxsins,k…”,”KKSSP^2431″,”kglpn”)

One of the +ASM instance alert log has ORA-04031 errors:

2025-07-17T23:00:48.475567+10:00
Errors in file /u01/app/grid/diag/asm/+asm/+ASM1/trace/+ASM1_ppa7_64031.trc (incident=160513):
ORA-04031: unable to allocate 2072 bytes of shared memory ("shared pool","unknown object","sga heap(1,0)","parameter table block")
Incident details in: /u01/app/grid/diag/asm/+asm/+ASM1/incident/incdir_160513/+ASM1_ppa7_64031_i160513.trc
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
2025-07-17T23:00:48.550908+10:00
ORA-04031 heap dump being written to trace file /u01/app/grid/diag/asm/+asm/+ASM1/incident/incdir_160513/+ASM1_ppa7_64031_i160513.trc

CAUSES

The SGA_TARGET or MEMORY_TARGET parameter setting is too small.


SQL> SELECT INST_ID, POOL, NAME, BYTES/1024/1024 "SPACE MB"
FROM gv$sgastat
WHERE name = 'free memory'
AND POOL = 'shared pool'
ORDER BY INST_ID;


INST_ID POOL NAME SPACE MB
---------- -------------- ------------------------------ ----------
1 shared pool free memory 195.44057
2 shared pool free memory 115.6167
3 shared pool free memory 92.235062

RESOLUTION

Increase size of parameter SGA_TARGET or MEMORY_TARGET.

OPW-00021: Failed to retrieve DB password file location from the CRS resource

When create Oracle password file in ASM, the following errors occur:

$ orapwd file='+DATA1/TESTDB/PASSWORD/pwdTESTDB' dbuniquename='TESTDB'

Enter password for SYS:

OPW-00021: Failed to retrieve DB password file location from the CRS resource

RESOLUTION

Add database and instances into CRS by running ‘srvctl’, but do not specify “-pwfile ‘+DATA1/TESTDB/PASSWORD/pwdTESTDB’:

$ srvctl add database -d TESTDB  -oraclehome /u01/app/oracle/product/19.0.0/dbhome_1  -dbtype RAC  -domain world  -spfile +DATA1/TESTDB/PARAMETERFILE/spfileTESTDB.ora   -role PRIMARY  -startoption OPEN  -stopoption IMMEDIATE

then

$  orapwd file='+DATA1/TESTDB/PASSWORD/pwdTESTDB' dbuniquename='TESTDB'

Enter password for SYS:
SQL> select * from v$pwfile_users;

Run the following commnad, we can see ‘-pwfile ‘+DATA1/TESTDB/PASSWORD/pwdTESTDB’ has been added into configuration automatically when we create password file.

$ srvctl config database -d TESTDB
...
Database unique name: TESTDB
Database name:
Oracle home: /u01/app/oracle/product/19.0.0/dbhome_1
Oracle user: oracle
Spfile: +DATA1/TESTDB/PARAMETERFILE/spfileTESTDB.ora
Password file: +DATA1/TESTDB/PASSWORD/pwdTESTDB
Domain: world
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
...
..
.

Oracle ASM Thin Provisioned Attribute and Reclaim Storage Space

ASMFD Installation & Configuration

Verify the ASM Filer Driver (AFD) Kernel module has been loaded.

$ lsmod | grep afd
oracleafd 226702 1

To confirm ASM Filter Driver has already been installed, loaded, is supported and versions, use afddriverstate installed | loaded | supported | version.

$ afddriverstate installed
AFD-9203: AFD device driver installed status: 'true'

$ afddriverstate loaded
AFD-9205: AFD device driver loaded status: 'true'

$ afddriverstate supported
AFD-9200: Supported

$ afddriverstate version
AFD-9325: Driver OS kernel version = 3.10.0-862.el7.x86_64.
AFD-9326: Driver build number = RELEASE.
AFD-9231: Driver build version = 19.0.0.0.0 (19.24.0.0.0).
AFD-9547: Driver available build number = RELEASE.
AFD-9232: Driver available build version = 19.0.0.0.0 (19.24.0.0.0).

To check the ASMFD filtering status:

$ asmcmd afd_state
ASMCMD-9526: The AFD state is 'LOADED' and filtering is 'ENABLED' on host 'RACNODE1'

Check and list ASMFD disks.

$ asmcmd afd_lsdsk

Oracle ASM Thin Provisioned Attribute

The ASM Thin Provisioned attribute enables or disables the functionality to discard unused storage space after a diskgroup rebalance is completed.

Note: the ASM Thin Provisioned attribute only works with the ASM Filter Driver, setting it on non-ASMFD diskgroups has no effect.

The attribute value can be true to enable or false to disable the functionality. The default value is false.

Oracle ASM informs the storage array which space is no longer used and can be repurposed. If a rebalance is not running, a rebalance can be triggered manually with the ALTER DISKGROUP … REBALANCE SQL statement.

How to check ASM ‘thin_provisioned’ attribute ?

set linesize 250

column diskgroup heading 'Diskgroup' format a15
column name heading 'Attribute Name' format a25
column value heading 'Value' format a15
column read_only heading 'Read Only' format a15

SELECT
SUBSTR(dg.name,1,12) AS diskgroup, SUBSTR(a.name,1,24) AS name,
SUBSTR(a.value,1,24) AS value, read_only
FROM
V$ASM_DISKGROUP dg,
V$ASM_ATTRIBUTE a
WHERE
dg.group_number = a.group_number AND
a.name NOT LIKE '%template%' AND
a.name LIKE '%thin%'
/

Diskgroup Attribute Name Value Read Only
--------------- ------------------------- --------------- ---------------
DATA2 thin_provisioned true N
FRA thin_provisioned FALSE N
OCR thin_provisioned FALSE N
REDO thin_provisioned true N

OR

$ asmcmd lsattr -G FRA | grep thin
thin_provisioned

We can easily change the ‘thin_provisioned’ attribute using ASMCA or using ‘alter disk group <DISK_GROUP> set attribute ‘thin_provisioned’=’TRUE’;’

SQL> alter diskgroup FRA set attribute 'thin_provisioned'='TRUE';
Diskgroup altered.

Since Oracle 18c the phase option includes the keywords WITH or WITHOUT, removing the need to use the underscore parameters, check your version documentation for limitations.

SQL> ALTER DISKGROUP DATA REBALANCE WITHOUT COMPACT;
Diskgroup altered.
SQL > alter diskgroup data2 rebalance with balance compact;
Diskgroup altered.
SQL> ALTER DISKGROUP DATA REBALANCE WITH BALANCE COMPACT POWER 1024 WAIT;
Diskgroup altered.
SQL>select INST_ID, OPERATION, STATE, POWER, SOFAR, EST_WORK, EST_RATE, EST_MINUTES from gv$asm_operation;

INST_ID OPERA STAT POWER SOFAR EST_WORK EST_RATE EST_MINUTES
------- ----- ---- ----- ------ ---------- ---------- -----------
2 REBAL WAIT 1
2 REBAL WAIT 1
2 REBAL WAIT 1
1 REBAL RUN 1 1951 8634894 2475 3488
1 REBAL DONE 1 1017 1017 0 0
1 REBAL DONE 1 0 0 0 0

6 rows selected.

ORA-15099: disk is larger than maximum size of 2097152 MBs

The following errors occur when creating a new ASM diskgroup:

SQL> CREATE DISKGROUP DATA1 EXTERNAL REDUNDANCY disk 'AFD:DATA1_DISK1' NAME DATA1_DISK1;
CREATE DISKGROUP DATA1 EXTERNAL REDUNDANCY disk 'AFD:DATA1_DISK1' NAME DATA1_DISK1;
*
ERROR at line 1:
ORA-15018: diskgroup cannot be created
ORA-15099: disk 'AFD:DATA1_DISK1' is larger than maximum size of 2097152 MBs

SOLUTION

SQL> CREATE DISKGROUP DATA1 EXTERNAL REDUNDANCY disk 'AFD:DATA1_DISK1' NAME DATA1_DISK1 ATTRIBUTE 'compatible.rdbms' = '19.0', 'compatible.asm' = '19.0';

Diskgroup created.

ORA-15046: ASM file name ‘+DATA2/TESTDB/PASSWORD/pwdtestdb.256.1157213397’ is not in single-file creation form

When relocating an ASM password file, the following errors occur:

ASMCMD>  pwcopy --dbuniquename TESTDB '+DATA1/TESTDB/PASSWORD/pwdtestdb.256.1157213397' '+DATA2/TESTDB/PASSWORD/' -f
...
..
.
ORA-15046: ASM file name '+DATA2/TESTDB/PASSWORD/pwdtestdb.256.1157213397' is not in single-file creation form
...
..
.

The destination name cannot be an OMF format. so the command should be like :

ASMCMD>  pwcopy --dbuniquename TESTDB '+DATA1/TESTDB/PASSWORD/pwdtestdb.256.1157213397' '+DATA2/TESTDB/PASSWORD/pwdtestdb.pwfile' -f