oracle監控常用語句



--數據庫實例查詢
select * from gv$version;


--RDBMS信息
select * from gv$version where Banner like '%Oracle%';


--SQL &Net版本信息
select * from gv$version where Banner like '%TNS%';




--SGA信息(Database Buffer)
select s.*,round(s.value/1024/1024) from gv$sga s where name = 'Database Buffers'


--SGA(Shared pool)
select s.*,round(s.bytes/1024/1024) from gv$sgainfo s where name = 'Shared Pool Size'


--SGA(LOG Buffers)
select s.*,round(s.bytes/1024/1024) from gv$sgastat s where s.name='log_buffer'


--DB_BLOCK Size
select p.value/1024,p.* from gv$parameter p where name = 'db_block_size'


--表空間信息
select * from dba_tablespaces;


--表空間使用率
select f.tablespace_name,
       a.total 總共M,
       f.free 空閒M,
       round((f.free / a.total) * 100) "空閒比率"
  from (select tablespace_name, sum(bytes / (1024 * 1024)) total
          from dba_data_files
         group by tablespace_name) a,
       (select tablespace_name, round(sum(bytes / (1024 * 1024))) free
          from dba_free_space
         group by tablespace_name) f
 WHERE a.tablespace_name = f.tablespace_name(+)
 order by "空閒比率";




--數據文件:
select * from dba_data_files;


--控制文件狀態:
select * from v$controlfile;


--在線日誌狀態
select group# as 日誌組,
       member 地址,
       status 狀態,
       is_recovery_dest_file
from v$logfile;


--相關參數查看(session,processes)
select resource_name,max_utilization,initial_allocation,limit_value from v$resource_limit;


--最大遊標(一個session執行語句數量)
select * from gv$parameter where name like '%cursor%';


--CPU使用率
SELECT round(t1.value*100/(t1.value+t2.value),4)||'%' 使用率,
       s.begin_interval_time 開始時間
       s.end_interval_time 結束時間
       t1.*,t2.*,
FROM dba_hist_osstat t1,dba_hist_snapshot s,dba_hist_osstat t2
WHERE t1.stat_name = 'BUSY_TICKS'
and t2.stat_name = 'IDLE_TICKS' 
and t1.snap_id = s.snap_id
and t2.snap_id = s.snap_id
and s.begin_interval_time >= TO_TIMESTAMP('2015-01-19 ', 'yyyy-mm-dd hh24')
and s.begin_interval_time < TO_TIMESTAMP('2015-01-19 20', 'yyyy-mm-dd hh24');


--最大內存
select * from gv$parameter p where name = 'sga_target'


--內存使用率
SELECT round(t.bytes*100/1073741824)||'%' 使用率,
       to_char(s.begin_interval_time,'yyyy-mm-dd hh24:mi:ss') 開始時間,
       to_char(s.end_interval_time,'yyyy-mm-dd hh24:mi:ss') 結束時間
FROM dba_hist_sgastat t,dba_hist_snapshot s
where t.snap_id = s.snap_id
and t.name  = 'free memory'
and t.pool = 'shared pool'
and s.begin_interval_time >= TO_TIMESTAMP('2015-01-19 08', 'yyyy-mm-dd hh24')
and s.begin_interval_time < TO_TIMESTAMP('2015-01-19 20', 'yyyy-mm-dd hh24')
order by s.begin_interval_time;


--歷史session 統計
select to_char(s.begin_interval_time,'yyyy-mm-dd hh24:mi:ss') 開始時間,
       to_char(s.end_interval_time,'yyyy-mm-dd hh24:mi:ss') 結束時間,
       count(session_id)
from dba_hist_active_sess_history h,dba_hist_snapshot s
where h.snap_id = s.snap_id
and s.begin_interval_time >= TO_TIMESTAMP('2015-01-19 08', 'yyyy-mm-dd hh24')
and s.begin_interval_time < TO_TIMESTAMP('2015-01-19 20', 'yyyy-mm-dd hh24')
and h.session_type = 'FOREGROUND'
and h.sql_id is not null
group by  to_char(s.begin_interval_time,'yyyy-mm-dd hh24:mi:ss'),to_char(s.end_interval_time,'yyyy-mm-dd hh24:mi:ss')
;


--具體運行sql語句查詢
select * from dba_hist_sqltext where sql_id = '';


--無效對象
select owner,object_name,object_type from dba_objects where status!='VALID' and owner!='SYS' and owner!='SYSTEM'; 


--IO查詢
select * from v$iostat_file;
select * from dba_hist_iostat_filetype;
發佈了22 篇原創文章 · 獲贊 29 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章