Tuesday, January 29, 2013
Track RMAN Job Process via gv$session_longops
Nice way to track RMAN Channel worker progress
Also useful: watch -n 10 sqlplus -s usr/pwd [this script].sql
set linesize 120
column pct_done format '999.99'
column opname format a35
column time_left format a15
column started format a15
select
sid,
opname,
to_char(start_time,'DD-MON HH24:MI') started,
round(totalwork-sofar) blocks_left,
(sofar/totalwork) * 100 pct_done,
to_char(to_date(time_remaining,'sssss'),'hh24:mi:ss') time_left
from
gv$session_longops
where
totalwork > sofar
AND
opname NOT LIKE '%aggregate%'
AND
opname like 'RMAN%'
order by 2;
exit;
Historical Blocking Locks
To Investigate Recent Blocking Locks (after the dust settles)
set pagesize 50
set linesize 120
col sql_id format a15
col inst_id format '9'
col sql_text format a50
col module format a10
col blocker_ses format '999999'
col blocker_ser format '999999'
------------------------------------------------------------------
--IN CHRONOLOGICAL ORDER (which is probably what you want anyways)
------------------------------------------------------------------
SELECT distinct
a.sql_id ,
to_char(a.sql_exec_start,'DD-Mon HH24:MI') sql_start,
a.inst_id,
a.blocking_session blocker_ses,
a.blocking_session_serial# blocker_ser,
a.user_id,
s.sql_text,
a.module
FROM GV$ACTIVE_SESSION_HISTORY a,
gv$sql s
where a.sql_id=s.sql_id
and blocking_session is not null
and a.user_id <> 0 -- exclude SYS user
and a.sample_time > sysdate - 1
order by sql_start
set pagesize 50
set linesize 120
col sql_id format a15
col inst_id format '9'
col sql_text format a50
col module format a10
col blocker_ses format '999999'
col blocker_ser format '999999'
------------------------------------------------------------------
--IN CHRONOLOGICAL ORDER (which is probably what you want anyways)
------------------------------------------------------------------
SELECT distinct
a.sql_id ,
to_char(a.sql_exec_start,'DD-Mon HH24:MI') sql_start,
a.inst_id,
a.blocking_session blocker_ses,
a.blocking_session_serial# blocker_ser,
a.user_id,
s.sql_text,
a.module
FROM GV$ACTIVE_SESSION_HISTORY a,
gv$sql s
where a.sql_id=s.sql_id
and blocking_session is not null
and a.user_id <> 0 -- exclude SYS user
and a.sample_time > sysdate - 1
order by sql_start
Query ASM Disks and Diskgroups
List all ASM devices:
/etc/init.d/oracleasm querydisk -d `/etc/init.d/oracleasm listdisks -d` |
cut -f2,10,11 -d" " | perl -pe 's/"(.*)".*\[(.*), *(.*)\]/$1 $2 $3/g;'
List all AVAILABLE ASM disks:
col path format a20
col header_status format a13
col os_mb format 999,999,999 heading 'Size (MB)'
SELECT inst_id,
path,
header_status,
os_mb
FROM GV$ASM_DISK
WHERE header_status in ('FORMER','PROVISIONED')
ORDER BY path,
inst_id;
Sample Output:
INST_ID PATH HEADER_STATUS Size (MB)
-------- -------------------- ------------- ------------
1 ORCL:DISK25 FORMER 524,294
2 ORCL:DISK25 FORMER 524,294
1 ORCL:DISK26 FORMER 524,294
2 ORCL:DISK26 FORMER 524,294
1 ORCL:DISK30 FORMER 524,294
2 ORCL:DISK30 FORMER 524,294
1 ORCL:DISK33 PROVISIONED 524,294
2 ORCL:DISK33 PROVISIONED 524,294
List All ASM DISKGROUPS:
set pagesize 60
set linesize 132
column aa format 99999 heading "DiskGroup"
column ab format a15 heading "DiskGroup"
column ac format a20 heading "Disk"
column ad format a15 heading "DiskGroup State"
column ae format a15 heading "Disk State"
break on ab skip 1
select substr(to_char(a.group_number),1,5) aa, substr(a.name,1,15) ab, substr(b.name,1,20) ac , b.total_mb, b.free_mb, a.state ad, b.state ae from
v$asm_diskgroup a, v$asm_disk b
where a.group_number = b.group_number
--and a.group_number = 4
order by 2,3
/
Sample Output:
DiskG DiskGroup Disk TOTAL_MB FREE_MB DiskGroup State Disk State
----- --------------- --------------- ---------- ---------- --------------- ---------------
1 DATA DATA1 517893 183780 MOUNTED NORMAL
1 DATA2 517893 183783 MOUNTED NORMAL
1 DATA3 517893 183781 MOUNTED NORMAL
1 DATA4 517893 183781 MOUNTED NORMAL
1 DATA5 517893 183780 MOUNTED NORMAL
2 FRA FRA1 517893 426005 MOUNTED NORMAL
3 VOTING VOTING 8631 8235 MOUNTED NORMAL
Rebalance Operations:
11g
select inst_id,
operation,
state,
power,
sofar,
est_work,
est_rate,
est_minutes
from gv$asm_operation
order by inst_id, state
/
12c
select inst_id,
pass,
state,
power,
sofar,
est_work,
est_rate,
est_minutes
from gv$asm_operation
order by inst_id, state
/
12c added a "COMPACT" pass to improve disk seek performance.
Sample Output:
INST_ID OPERA STAT POWER SOFAR EST_WORK EST_RATE EST_MINUTES
---------- ----- ---- ---------- ---------- ---------- ---------- -----------
1 REBAL RUN 5 314121 314121 1029 0
1 REBAL WAIT 5
2 REBAL RUN 5 9724 188000 1289 138
2 REBAL WAIT 5
Query Disk Compatibility:
col COMPATIBILITY form a10
col DATABASE_COMPATIBILITY form a10
col NAME form a20
select group_number, name, compatibility, database_compatibility from v$asm_diskgroup;
Additional reference:
How To Gather & Backup ASM/ACFS Metadata In A Formatted Manner version 10.1, 10.2, 11.1, 11.2 and 12.1? (Doc ID 470211.1)
/etc/init.d/oracleasm querydisk -d `/etc/init.d/oracleasm listdisks -d` |
cut -f2,10,11 -d" " | perl -pe 's/"(.*)".*\[(.*), *(.*)\]/$1 $2 $3/g;'
List all AVAILABLE ASM disks:
col path format a20
col header_status format a13
col os_mb format 999,999,999 heading 'Size (MB)'
SELECT inst_id,
path,
header_status,
os_mb
FROM GV$ASM_DISK
WHERE header_status in ('FORMER','PROVISIONED')
ORDER BY path,
inst_id;
Sample Output:
INST_ID PATH HEADER_STATUS Size (MB)
-------- -------------------- ------------- ------------
1 ORCL:DISK25 FORMER 524,294
2 ORCL:DISK25 FORMER 524,294
1 ORCL:DISK26 FORMER 524,294
2 ORCL:DISK26 FORMER 524,294
1 ORCL:DISK30 FORMER 524,294
2 ORCL:DISK30 FORMER 524,294
1 ORCL:DISK33 PROVISIONED 524,294
2 ORCL:DISK33 PROVISIONED 524,294
List All ASM DISKGROUPS:
set pagesize 60
set linesize 132
column aa format 99999 heading "DiskGroup"
column ab format a15 heading "DiskGroup"
column ac format a20 heading "Disk"
column ad format a15 heading "DiskGroup State"
column ae format a15 heading "Disk State"
break on ab skip 1
select substr(to_char(a.group_number),1,5) aa, substr(a.name,1,15) ab, substr(b.name,1,20) ac , b.total_mb, b.free_mb, a.state ad, b.state ae from
v$asm_diskgroup a, v$asm_disk b
where a.group_number = b.group_number
--and a.group_number = 4
order by 2,3
/
Sample Output:
DiskG DiskGroup Disk TOTAL_MB FREE_MB DiskGroup State Disk State
----- --------------- --------------- ---------- ---------- --------------- ---------------
1 DATA DATA1 517893 183780 MOUNTED NORMAL
1 DATA2 517893 183783 MOUNTED NORMAL
1 DATA3 517893 183781 MOUNTED NORMAL
1 DATA4 517893 183781 MOUNTED NORMAL
1 DATA5 517893 183780 MOUNTED NORMAL
2 FRA FRA1 517893 426005 MOUNTED NORMAL
3 VOTING VOTING 8631 8235 MOUNTED NORMAL
Rebalance Operations:
11g
select inst_id,
operation,
state,
power,
sofar,
est_work,
est_rate,
est_minutes
from gv$asm_operation
order by inst_id, state
/
12c
select inst_id,
pass,
state,
power,
sofar,
est_work,
est_rate,
est_minutes
from gv$asm_operation
order by inst_id, state
/
12c added a "COMPACT" pass to improve disk seek performance.
Sample Output:
INST_ID OPERA STAT POWER SOFAR EST_WORK EST_RATE EST_MINUTES
---------- ----- ---- ---------- ---------- ---------- ---------- -----------
1 REBAL RUN 5 314121 314121 1029 0
1 REBAL WAIT 5
2 REBAL RUN 5 9724 188000 1289 138
2 REBAL WAIT 5
Query Disk Compatibility:
col COMPATIBILITY form a10
col DATABASE_COMPATIBILITY form a10
col NAME form a20
select group_number, name, compatibility, database_compatibility from v$asm_diskgroup;
Additional reference:
How To Gather & Backup ASM/ACFS Metadata In A Formatted Manner version 10.1, 10.2, 11.1, 11.2 and 12.1? (Doc ID 470211.1)
ASM Diskgroup Space Used / Free
SQL:
set linesize 140
col group_number heading 'Diskgroup|Number' format 999
col diskgroup heading 'Name' format a20
col total_mb heading 'Allocated (MB)' format 999,999,999
col free_mb heading 'Available (MB)' format 999,999,999
col tot_used heading 'Used (MB)' format 999,999,999
col pct_used heading '% Used' format 999
col pct_free heading '% Free' format 999
select group_number,
name diskgroup,
total_mb,
free_mb,
total_mb-free_mb tot_used,
pct_used,
pct_free
from (select group_number,name,total_mb,free_mb,
round(((total_mb-nvl(free_mb,0))/decode(total_mb,0,1,total_mb))*100) pct_used,
round((free_mb/total_mb)*100) pct_free
from v$asm_diskgroup
where total_mb >0
order by pct_free
)
/
SAMPLE OUTPUT:
Diskgroup
Number Name Allocated (MB) Available (MB) Used (MB) % Used % Free
--------- --------------- -------------- -------------- ----------- ------ ------
2 DATA2 5,767,234 1,860,008 3,907,226 68 32
1 DATA1 5,767,234 1,996,305 3,770,929 65 35
Objects in Data Buffers
Objects in Data Buffers:
set pages 50
set linesize 110
column c1 heading "Object|Name" format a30
--column c1a heading "Partition|Name" format a15
column c2 heading "Object|Type" format a16
column c3 heading "Number of|Blocks" format 999,999,999,999
column c3a heading "Size (MB)|32k blocks" format 999,999,999
column c4 heading "Percentage|of object|data blocks|in Buffer" format 999
Sample Output:
set pages 50
set linesize 110
spool blocks.lst
ttitle 'Contents of Data Buffers'
drop table t1;
create table t1 as
select
o.object_name object_name,
-- o.subobject_name subobject_name,
o.object_type object_type,
count(1) num_blocks
from
dba_objects o,
v$bh bh
where
o.object_id = bh.objd
and
o.owner not in ('SYS','SYSTEM')
group by
o.object_name,
-- o.subobject_name,
o.object_type
order by
count(1) desc
/
select
o.object_name object_name,
-- o.subobject_name subobject_name,
o.object_type object_type,
count(1) num_blocks
from
dba_objects o,
v$bh bh
where
o.object_id = bh.objd
and
o.owner not in ('SYS','SYSTEM')
group by
o.object_name,
-- o.subobject_name,
o.object_type
order by
count(1) desc
/
column c1 heading "Object|Name" format a30
--column c1a heading "Partition|Name" format a15
column c2 heading "Object|Type" format a16
column c3 heading "Number of|Blocks" format 999,999,999,999
column c3a heading "Size (MB)|32k blocks" format 999,999,999
column c4 heading "Percentage|of object|data blocks|in Buffer" format 999
select
object_name c1,
-- subobject_name c1a,
object_type c2,
num_blocks c3,
(num_blocks*32)/1024 c3a,
(num_blocks/decode(sum(blocks), 0, .001, sum(blocks)))*100 c4
from
t1,
dba_segments s
where
s.segment_name = t1.object_name
and
num_blocks > 10
group by
object_name,
-- subobject_name,
object_type,
num_blocks
order by
num_blocks desc
/
object_name c1,
-- subobject_name c1a,
object_type c2,
num_blocks c3,
(num_blocks*32)/1024 c3a,
(num_blocks/decode(sum(blocks), 0, .001, sum(blocks)))*100 c4
from
t1,
dba_segments s
where
s.segment_name = t1.object_name
and
num_blocks > 10
group by
object_name,
-- subobject_name,
object_type,
num_blocks
order by
num_blocks desc
/
exit
/
/
Sample Output:
Mon Aug
06 page
1
Contents of Data Buffers
Contents of Data Buffers
Percentage
of object
Object Object Number of Size (MB) data blocks
Name Type Blocks 32k blocks in Buffer
------------------------------ ---------------- ---------------- ------------ -----------
...
of object
Object Object Number of Size (MB) data blocks
Name Type Blocks 32k blocks in Buffer
------------------------------ ---------------- ---------------- ------------ -----------
...
38 rows selected.
SGA Usage Report
SGA Usage Report:
break on report
compute sum of mb on report
compute sum of inuse on report
set pagesize 50
col mb format 999,999
col inuse format 999,999
select name,
round(sum(mb),1) mb,
round(sum(inuse),1) inuse
from (select case when name = 'buffer_cache'
then 'db_cache_size'
when name = 'log_buffer'
then 'log_buffer'
else pool
end name,
bytes/1024/1024 mb,
case when name <> 'free memory'
then bytes/1024/1024
end inuse
from v$sgastat
)
group by name
order by mb desc
/
exit
/
Sample Output:
NAME MB INUSE
------------- --------
--------
db_cache_size 85,504 85,504
shared pool 6,144 3,879
streams pool 512 256
large pool 256 1
java pool 256
log_buffer 98 98
2 2
-------- --------
sum 92,773 89,741
db_cache_size 85,504 85,504
shared pool 6,144 3,879
streams pool 512 256
large pool 256 1
java pool 256
log_buffer 98 98
2 2
-------- --------
sum 92,773 89,741
Instance Memory Usage
Instance Memory Usage:
set linesize 100
set pagesize 50
col component format a35
col size_mb format 999,999
select component,
current_size/1024/1024 size_mb
from v$memory_dynamic_components
order by current_size desc
/
!free
exit
/
Sample Output:
COMPONENT SIZE_MB
----------------------------------- --------
SGA Target 92,160
DEFAULT buffer cache 85,504
PGA Target 30,720
shared pool 5,376
streams pool 256
java pool 256
large pool 256
RECYCLE buffer cache 0
DEFAULT 2K buffer cache 0
DEFAULT 4K buffer cache 0
DEFAULT 8K buffer cache 0
KEEP buffer cache 0
DEFAULT 32K buffer cache 0
Shared IO Pool 0
ASM Buffer Cache 0
DEFAULT 16K buffer cache 0
SGA Target 92,160
DEFAULT buffer cache 85,504
PGA Target 30,720
shared pool 5,376
streams pool 256
java pool 256
large pool 256
RECYCLE buffer cache 0
DEFAULT 2K buffer cache 0
DEFAULT 4K buffer cache 0
DEFAULT 8K buffer cache 0
KEEP buffer cache 0
DEFAULT 32K buffer cache 0
Shared IO Pool 0
ASM Buffer Cache 0
DEFAULT 16K buffer cache 0
16 rows selected.
Subscribe to:
Posts (Atom)