Showing posts with label ASM. Show all posts
Showing posts with label ASM. Show all posts

Sunday, July 7, 2024

ASM QUERIES

ASM DISK SPACE REPORT


set lines 255
col path for a35
col Diskgroup for a15
col DiskName for a25
col disk# for 999
col total_mb for 999,999,999
col free_mb for 999,999,999
compute sum of total_mb on DiskGroup
compute sum of free_mb on DiskGroup
break on DiskGroup skip 1 on report -
 set pages 255
select a.name DiskGroup, b.disk_number Disk#, b.name DiskName, 
   b.total_mb, b.free_mb, 
   -- b.path, 
   b.header_status
from v$asm_disk b, v$asm_diskgroup a
where a.group_number (+) =b.group_number
order by b.group_number, b.disk_number, b.name;

DISK GROUP USAGE

set lines 120
col "Redundancy" for a15
col "Diskgroup" for a12
select a.name "Diskgroup" , round(sum(b.total_mb)/1024,1) "Size GB",  
       round(sum(b.free_mb)/1024,1) "Free GB", 
       decode (a.type, 'EXTERN',round(sum(b.free_mb)/1024,1),'NORMAL',round(sum(b.free_mb)/1024/2,1),'HIGH',round(sum(b.free_mb)/1024/3,1))  "Usable GB", 
       decode (a.type, 'EXTERN',round(sum(b.free_mb)/1024/1024,1),'NORMAL',round(sum(b.free_mb)/1024/1024/2,1),'HIGH',round(sum(b.free_mb)/1024/1024/3,1))  "Usable TB", 
       round((sum(b.total_mb)-sum(b.free_mb))/sum(b.total_mb)*1000)/10 "Use%",
       a.type "Redundancy"
from v$asm_disk b, v$asm_diskgroup a 
where  a.group_number (+) =b.group_number 
group by a.name, a.type order by 1;

GROUP BY USAGE

set pages 100
col database for a15
SELECT NVL(dbname, '-- TOTAL') database, round(SUM(space)/1024/1024) mb_used, 
       round(SUM(space) / AVG(total_mb * 1024 * 1024) * 100, 2) pct_used
FROM (
  SELECT gname, file_type, space, aname, system_created, alias_directory,
         regexp_substr(full_alias_path, '[[:alnum:]_]*',1,4) dbname, total_mb
    FROM (
      SELECT system_created, alias_directory, file_type,space, level, gname, aname,
          concat('+'||gname, sys_connect_by_path(aname, '/')) full_alias_path, total_mb
        FROM (
          SELECT b.name gname, b.total_mb, a.parent_index pindex, a.name aname,
                 a.reference_index rindex, a.system_created, a.alias_directory,
                 c.type file_type, c.space
            FROM v$asm_alias a 
            JOIN v$asm_diskgroup b ON a.group_number = b.group_number
       LEFT JOIN v$asm_file c ON a.group_number = c.group_number
             AND a.file_number = c.file_number
             AND a.file_incarnation = c.incarnation
        ) START WITH (mod(pindex, power(2, 24))) = 0 AND rindex IN (
          SELECT a.reference_index FROM v$asm_alias a, v$asm_diskgroup b
           WHERE a.group_number = b.group_number
             AND (mod(a.parent_index, power(2, 24))) = 0
        ) CONNECT BY prior rindex = pindex
    ) WHERE NOT file_type IS NULL AND system_created = 'Y' )
GROUP BY ROLLUP (dbname)
/
                                                    
Oracle ASM USAGE


select name, total_mb, free_mb, 
       round(100*(total_mb-free_mb)/greatest(1,total_mb),0) as used_pct 
  from v$asm_diskgroup;

Tuesday, November 9, 2021

ASM - Query to find the size of Databases on an ASM diskgroup

 

Query to find the size of Databases on an ASM diskgroup


Login as Grid user  -
sqlplus "/as sysasm"

Execute the Query -

column DATABASE format a25
col "GB" format 99,999.9
set pagesize 20
SELECT
disk_group_name
,SUBSTR(alias_path,2,INSTR(alias_path,'/',1,2)-2) Database
,ROUND(SUM(alloc_bytes)/1024/1024/1024,1) "GB"
,ROUND(SUM(alloc_bytes)/1024/1024,1) "MB"
FROM
(SELECT
SYS_CONNECT_BY_PATH(alias_name, '/') alias_path
,alloc_bytes, disk_group_name
FROM
(SELECT
g.name disk_group_name
, a.parent_index pindex
, a.name alias_name
, a.reference_index rindex
, f.space alloc_bytes
, f.type type
FROM
v$asm_file f RIGHT OUTER JOIN v$asm_alias a
USING (group_number, file_number)
JOIN v$asm_diskgroup g
USING (group_number)
)
WHERE type IS NOT NULL
START WITH (MOD(pindex, POWER(2, 24))) = 0
CONNECT BY PRIOR rindex = pindex
)
GROUP BY disk_group_name, SUBSTR(alias_path,2,INSTR(alias_path,'/',1,2)-2)
ORDER BY 1;

OUTPUT


DISK_GROUP_NAME                DATABASE                         GB         MB
------------------------------ ------------------------- --------- ----------
DATA01                                     ASM                           592.6         606792
DATA01                                     REPOST                          3.5           3596
DATA01                                     STDB                            3.4           3456

Friday, July 9, 2021

DBCA Does Not Display ASM Disk Groups

 

DBCA Does Not Display ASM Disk Groups



When DBCA is launched by the oracle user OS account, the process gets to the screen to select the ASM disk groups but no Disk Groups are available.

If we launch DBCA from Grid user account , the disk groups are available.


I get this problem when trying to create a database with a different user than grid user ie oracle

I’ve installed Grid infrastructure with user grid, and I was trying to create a database with user oracle (who’s the owner of oracle rdbms). But during this installation I wasn’t able to see any of my ASM disk.


Cause

File permissions in <Grid_home>/bin/oracle executable not set properly.


Solution

As root, change the file permissions of the oracle executable under Grid_Home/bin to 6751:
# cd <Grid_Home>/bin
# chmod 6751 oracle

# ls -l oracle

-rwsr-s–x 1 grid oinstall 173515905 May 21 17:04 oracle

This is the setuid bit, and this must be set in order for users, other than “Grid” user to have it work.


Oracle Notes 


ASM Diskgroup Can Not Be Shown When Creating Database With DBCA (Doc ID 1269734.1)

DBCA Does Not Display ASM Disk Groups In 11.2 (Doc ID 1177483.1)

Dbca Does Not Show ASM Diskgroup Information (Doc ID 1286434.1)

Monday, May 24, 2021

ASM Diskgroups not mounting ORA-15040

 
ORA-15032 , ORA-15017 , ORA- 15040 , ASM Disk-group not found


ISSUE  after rebooting the server (ASM Disk groups not able to find)
The ASM diskgroup was nowhere to be found while querying the v$asm_diskgroup and v$asm_disks es.

ERROR: diskgroup ASM_DATA was not mounted
ORA-15032: not all alterations performed
ORA-15017: diskgroup "DATA" cannot be mounted
ORA-15040: diskgroup is incomplete


when ASM restarted
ran asmcmd > lsdg
No mount-points were visible
and while mounting the disk-groups manually its failing with the Error

ORA-15032 , ORA-15017 , ORA- 15040




Execute the following commands

$ORACLE_HOME/bin/kfod status=TRUE asm_diskstring='ORCL:*' disks=ALL

so running kfod again
/u01/app/grid/product/12.2.0/grid/bin/kfod status=TRUE asm_diskstring='/dev/oracleasm/disks/*' disks=ALL
 
--------------------------------------------------------------------------------
 Disk          Size Header    Path                                     User     Group
================================================================================
   1:     102400 MB MEMBER    /dev/oracleasm/disks/DATA_01         grid     oinstall
   2:     102400 MB MEMBER    /dev/oracleasm/disks/DATA_02         grid     oinstall
   3:     102400 MB MEMBER    /dev/oracleasm/disks/DATA_03         grid     oinstall
   4:     102400 MB MEMBER    /dev/oracleasm/disks/DATA_04         grid     oinstall
   5:     102400 MB MEMBER    /dev/oracleasm/disks/DATA_05         grid     oinstall
   6:     102400 MB MEMBER    /dev/oracleasm/disks/FRA_01          grid     oinstall
   7:     102400 MB MEMBER    /dev/oracleasm/disks/FRA_02          grid     oinstall
   8:     102400 MB MEMBER    /dev/oracleasm/disks/FRA_03          grid     oinstall
   9:     102400 MB MEMBER    /dev/oracleasm/disks/FRA_04          grid     oinstall
--------------------------------------------------------------------------------
ORACLE_SID ORACLE_HOME
================================================================================
      +ASM /u01/app/grid/product/12.2.0/grid
 
this display the correct disks so we need to change the diskstring to /dev/oracleasm/disks/*

Log in to the ASM instance as sysasm and set the asm_diskstring to what it was:

SQL> alter system set asm_diskstring='/dev/oracleasm/disks/*' scope=memory;
SQL> select name, state from v$asm_diskgroup;

NAME                           STATE
------------------------------ -----------
DATA                           DISMOUNTED
FRA                            DISMOUNTED
SQL> alter diskgroup DATA mount;

Diskgroup altered.

SQL> alter diskgroup FRA mount;

Diskgroup altered.

SYS@+ASM> select name, state from v$asm_diskgroup;

NAME                           STATE
------------------------------ -----------
DATA                           MOUNTED
FRA                            MOUNTED
Stop and restart HAS

crsctl stop has
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'a04978'
CRS-2673: Attempting to stop 'ora.ASM_FRA.dg' on 'a04978'
CRS-2673: Attempting to stop 'ora.ASM_DATA.dg' on 'a04978'
CRS-2673: Attempting to stop 'ora.LISTENER.lsnr' on 'a04978'
CRS-2677: Stop of 'ora.ASM_FRA.dg' on 'a04978' succeeded
CRS-2677: Stop of 'ora.ASM_DATA.dg' on 'a04978' succeeded
CRS-2673: Attempting to stop 'ora.evmd' on 'a04978'
CRS-2673: Attempting to stop 'ora.asm' on 'a04978'
CRS-2677: Stop of 'ora.LISTENER.lsnr' on 'a04978' succeeded
CRS-2677: Stop of 'ora.evmd' on 'a04978' succeeded
CRS-2677: Stop of 'ora.asm' on 'a04978' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'a04978'
CRS-2677: Stop of 'ora.cssd' on 'a04978' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'a04978' has completed
CRS-4133: Oracle High Availability Services has been stopped.
Start HAS

$ crsctl start has
CRS-4123: Oracle High Availability Services has been started.
 
Now restart the database and check disks are visible