文章目錄
一、主機配置
1.主機名
hostname
2.os版本
cat /proc/version
3.CPU
個數:
cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l
AIX:
prtconf|grep Processors
核數
cat /proc/cpuinfo| grep "cpu cores"| uniq
AIX:
pmcycles -m
4.物理內存、虛擬內存
free -g Mem是物理內存 Swap是虛擬內存
5.主機型號
dmidecode | grep "Product Name"
AIX:
uname -M
二、操作系統內核參數
ulimit -a
三、操作系統資源利用率
top
CUP使用狀況: top 第三行 id
內存使用狀況:top 第四行內存 free/total
I/O使用狀況: top 第三行 wa I/O等待佔CPU百分比
磁盤使用情況: df -lh
四、數據庫運行情況
1.數據文件
select file_name,bytes/1048576,AUTOEXTENSIBLE,INCREMENT_BY , STATUS from dba_data_files;
2.表空間
select a.tablespace_name as tablespace_name,
round(a.bytes/(1024*1024),2) as "total(M)",
round(b.bytes/(1024*1024),2) as "used(M)",
round(c.bytes/(1024*1024),2) as "free(M)",
round((b.bytes * 100)/a.bytes,2) "% USED ",
round((c.bytes * 100)/a.bytes,2) "% FREE "
from sys.sm$ts_avail a, sys.sm$ts_used b, sys.sm$ts_free c
where a.tablespace_name = b.tablespace_name
and a.tablespace_name = c.tablespace_name;
select tablespace_name,round(maxbytes/1024/1024/1024,2) as "max(G)" from dba_data_files; --可擴展空間
3.內存使用情況
select name,bytes/1024/1024/1024 ,resizeable from v$sgainfo ;
select POOL ,NAME ,BYTES/1024/1024 from v$sgastat where name ='log_buffer';
4.檢查oracle實例狀態
select instance_name,host_name,startup_time,status,database_status from v$instance;
5.檢查oracle在線日誌狀態
select group#,status,type,member from v$logfile;
6.檢查oracle表空間狀態
select tablespace_name,status from dba_tablespaces;
7.檢查是否存在無效對象
select owner, object_name, object_type from dba_objects where status= 'INVALID';
8.檢查緩衝區命中率
select a.value + b.value logical_reads,c.value phys_reads,
round(100 * (1 - c.value / (a.value + b.value)), 4) hit_ratio
from v$sysstat a, v$sysstat b, v$sysstat c
where a.name = 'db block gets'
and b.name = 'consistent gets'
and c.name = 'physical reads';
9.檢查死鎖及處理狀態
select sid, serial#,username,schemaname,osuser,machine,terminal,program,owner,
object_name,object_type,o.object_id
from dba_objects o, v$locked_object l, v$session s
where o.object_id = l.object_id and s.sid = l.session_id;
10.檢查前10條性能差的sql
select * from (
select parsing_user_id executions, sorts, command_type,disk_reads, sql_text
from v$sqlarea order by disk_reads desc
) where rownum < 10;
11.查詢數據庫中佔用空間較大的表
select table_name,num_rows,avg_row_len,blocks, round(num_rows*avg_row_len/(1024*1024),2) as "daxiaooo(M)",blocks*8/1024
from user_tables order by num_rows desc;
12.表空間增長趨勢
select tablespace_name , sum(t.bytes / 1024 / 1024) "佔用空間(M)"
from dba_segments t
group by tablespace_name order by tablespace_name,sum(t.BYTES/1024/1024) desc;
13.數據量整數TOP10
select table_name,num_rows,avg_row_len,blocks, round(num_rows*avg_row_len/(1024*1024),2) as "daxiaooo(M)",blocks*8/1024
from user_tables order by num_rows desc;