DisplayAdd1

TechnoTechDB is a platform, which will help to grow your carrier in Information sector. Having 15 years of Experience in Oracle/MongoDB/Postgres/Mysql databases, along with having good expertise level of knowledge in Scripting to automate database task. Our goal to start with zero to hero level expertise in Database. You can access/refer my some blogs on https://mrorcldba.blogspot.com link and post your comments and your suggestion to motive us.

Saturday, 23 January 2016

Some Useful ASM commands and Query.

chk_asm_mapping.sh

The following is a script I found somewhere on the web. Unfortunately it was not totally correct for newer asm libraries. The script itself:
/etc/init.d/oracleasm querydisk -d `/etc/init.d/oracleasm listdisks -d` |
cut -f2,10,11 -d" " | perl -pe 's/"(.*)".*\[(.*), *(.*)\]/$1 $2 $3/g;' |
while read v_asmdisk v_minor v_major
do
v_device=`ls -la /dev | grep " $v_minor, *$v_major " | awk '{print $10}'`
echo "ASM disk $v_asmdisk based on /dev/$v_device [$v_minor, $v_major]"
done
When started it produces the following output:
ASM disk DISK001A based on /dev/sdc1 [8, 33]
ASM disk DISK001B based on /dev/sdb1 [8, 17]
ASM disk DISK002A based on /dev/sdd1 [8, 49]
ASM disk DISK002B based on /dev/sde1 [8, 65]
ASM disk DISK003A based on /dev/sdg1 [8, 97]
ASM disk DISK003B based on /dev/sdf1 [8, 81]

Disk Group Information

set pages 40000 lines 120
col NAME for a15
select GROUP_NUMBER DG#, name, ALLOCATION_UNIT_SIZE AU_SZ, STATE,
TYPE, TOTAL_MB, FREE_MB, OFFLINE_DISKS from v$asm_diskgroup;
DG# NAME  AU_SZ   STATE    TYPE   TOTAL_MB FREE_MB OFFLINE_DISKS
--- ----- ------- -------- ------ ------   ------- -------------
 1  DATA2 4194304 MOUNTED  NORMAL 40952    4168    0
 2  DATA  1048576 MOUNTED  NORMAL 30717    25667   0

ASM Disk Information

set pages 40000 lines 120
col PATH for a30
select DISK_NUMBER,MOUNT_STATUS,HEADER_STATUS,MODE_STATUS,STATE,
PATH FROM V$ASM_DISK;

DISK_NUMBER MOUNT_S HEADER_STATU MODE_ST STATE    PATH
----------- ------- ------------ ------- -------- -------------
0           CLOSED  MEMBER       ONLINE  NORMAL   ORCL:DISK001A
3           CLOSED  MEMBER       ONLINE  NORMAL   ORCL:DISK003B
1           CACHED  MEMBER       ONLINE  NORMAL   ORCL:DISK001B
2           CACHED  MEMBER       ONLINE  NORMAL   ORCL:DISK002A
3           CACHED  MEMBER       ONLINE  NORMAL   ORCL:DISK002B

Combined ASM Disk and ASM Diskgroup information

The following query combines ASM disk and diskgroup information. You can edit this query to suit your needs easily. If you use ASM files instead of disks you have to use v$asm_file instead of v$asm_disk. If you use ASM files you have to add v$asm_file to the query.
col PATH for a15
col DG_NAME for a15
col DG_STATE for a10
col FAILGROUP for a10

select dg.name dg_name, dg.state dg_state, dg.type, d.disk_number dsk_no,
d.path, d.mount_status, d.FAILGROUP, d.state 
from v$asm_diskgroup dg, v$asm_disk d
where dg.group_number=d.group_number
order by dg_name, dsk_no;

DG_NAME  DG_STATE TYPE   DSK_NO PATH          MOUNT_S FAILGROUP  STATE
-------- -------- ------ ------ ------------- ------- ---------- --------
DATA     MOUNTED  NORMAL 1      ORCL:DISK001B CACHED  DISK001B   NORMAL
DATA     MOUNTED  NORMAL 2      ORCL:DISK002A CACHED  DISK002A   NORMAL
DATA     MOUNTED  NORMAL 3      ORCL:DISK002B CACHED  DISK002B   NORMAL
DATA2    MOUNTED  NORMAL 1      ORCL:DISK003A CACHED  DISK003A   NORMAL
DATA2    MOUNTED  NORMAL 2      ORCL:DISK003B CACHED  DISK003B   NORMAL

Monitoring ASM disk operations

select GROUP_NUMBER, OPERATION, STATE, ACTUAL, SOFAR, EST_MINUTES from v$asm_operation;
If there is a operating going on (like rebalancing) the query will return some rows. For instance for our just added disk the query yields:
GROUP_NUMBER OPERA STAT    ACTUAL  SOFAR      EST_MINUTES
------------ ----- ---- ---------- ---------- -----------
2            REBAL RUN           1         49          16
 
 
 
 
 
 

***********************  On ASMCMD **********************************************lsdg --> list diskgroup
lsdg -g  ---> for RAC to check the 
lsct : which particual DG is accessed or connected with database
lsattr -G DG_NAME -l   ---> it will show the attribues with values of Disk Group
lsof -G DG_NAME --> will show all the DB and DB file wihch are used in this DG group
ls -s  --> size of file
du   --> size details disk used
lsdsk -g DG_NAME -k --> the disk name which is attached to with this disk group
 
 
 
 
===>change the attributes of DiskGroup
export ORACLE_SID=+ASM
sqlplus /as sysdba
alter diskgr DG_NAME attribute='compatible.rdbms'='11.2.0'; 



==> to add the disk in the diskgroup
export ORACLE_SID=+ASM
sqlplus / as sysdba
alter diskgriup DG_NAME disk 'path_disk';

*********************************************************************

==> Rename the diskgroup and the datafile
export ORACLE_SID=orcl
sqlplus / as sysdba
select name frmo v$datafile;  --Note the file path

export ORACLE_SID=+ASM
$asmcmd
lsdg
umount DG_NAME  (OLD_DG_NAME)
renamedg dgname=OLD_DG_NAME newdgname='NEW_DG_NAME'
mount NEW_DG_NAME

export ORACLE_SID=orcl
sqlplus / as sysdba
alter datafile rename file '+OLD_DG_NAME/filename' to new '+NEW_DG_NAME/filename';
select name frmo v$datafile;

No comments:

Post a Comment

Steps to Rename Host in Oracle RESTART (ASM) in Linux

  oracle@localhost ] asmcmd ASMCMD> lsdg State    Type    Rebal  Sector  Logical_Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_...