资源描述
数据库日常检查
内容
数据库是否处于归档模式
检查方法
sqlplus sys/......
SQL>archive log list;
看数据库是否处于归档模式,并启动了自动归档进程
检查结果
◆ 正常 □ 异常
备注
内容
文件系统使用情况
检查方法
执行df –k,检查有没有使用率超过80%的文件系统,特别是存放归档日志的文件系统
检查结果
◆ 正常 □ 异常
备注
内容
alert_SID.log文件
检查方法
检查alert_SID.log有无报错信息(ORA-600、ORA-1578)、ORA-60
检查结果
◆ 正常 □ 异常
备注
内容
备份文件是否正常
检查方法
检查文件大小及生成日期
检查export的日志文件
用imp工具生成建表脚本,看能否正常完成
imp system/.... rows=n index
检查结果
◆ 正常 □ 异常
备注
内容
表空间使用情况
检查方法
col tablespace_name form a25
select tablespace_name,
count(*) chunks,
max(bytes)/1024/1024 max_chunk,
sum(bytes)/1024/1024 total_space
from dba_free_space
group by tablespace_name;
如果最大可用块(max_chunk)及总大小(total_space)相比太小,要考虑接合表空间碎片或重建某些数据库对象。
碎片接合的方法:
alter tablespace 表空间名 coalesce;
检查结果
◆ 正常 □ 异常
备注
内容
数据库对象的存储参数设置
检查方法
select segment_name,
next_extent,
tablespace_name
from dba_segments
where next_extent >[上一个检查中的最小的max_chunk]
如果有结果返回,说明有些对象的下一次扩展(从表空间的空闲区中分配空间的操作)会失败
检查结果
◆ 正常 □ 异常
备注
内容
检查是否有超过200个extent的对象
检查方法
select segment_name,
tablespace_name,
extents
from dba_segments
where owner not in ('SYS','SYSTEM')
and extents >200;
如果有结果返回,说明这些对象分配了太多的extent,可以考虑重建这些对象。
检查结果
◆ 正常 □ 异常
备注
内容
检查是否有失效的索引
检查方法
select index_name,
owner,
table_name,
tablespace_name
from dba_indexes
where owner not in ('SYS','SYSTEM')
and status != 'VALID';
如果有记录返回,考虑重建这些索引
检查结果
◆ 正常 □ 异常
备注
内容
检查是否有无效的对象
检查方法
select object_name,
object_type,
owner,
status
from dba_objects
where status !='VALID'
and owner not in ('SYS','SYSTEM')
and object_type in
('TRIGGER','VIEW','PROCEDURE','FUNCTION');
如果存在无效的对象,手工重新编译一下。
检查结果
□ 正常 □ 异常
备注
内容
检查Sequence的使用
检查方法
select sequence_owner,
sequence_name,
min_value,
max_value,
increment_by,
last_number,
cache_size,
cycle_flag
from dba_sequences;
检查是否存在即将达到max_value的sequence
检查结果
◆ 正常 □ 异常
备注
内容
检查有无运行失败的JOB
检查方法
select job,
this_date,
this_sec,
next_date,
next_sec,
failures,
what
from dba_jobs
where failures !=0 or failures is not null;
检查结果
◆ 正常 □ 异常
备注
内容
检查SGA使用情况
检查方法
select * from v$sga;
检查SGA各部份的分配情况,及实际内存比较是否合理
检查结果
□ 正常 □ 异常
备注
内容
检查SGA各部分占用内存情况
检查方法
select * from v$sgastat;
检查有无占用大量Shared pool的对象,及是否有内存浪费情况
检查结果
□ 正常 □ 异常
备注
内容
检查回滚段使用情况
检查方法
select n.name,
wraps,
extends,
shrinks,
optsize,
waits,
xacts,
aveactive,
hwmsize
from v$rollstat r, v$rollname n
where r.usn=n.usn;
检查回滚段的shrink和extends次数是否过多。
检查optimal设置是否合理,是否占用了过多的回滚段表空间
检查结果
□ 正常 □ 异常
备注
内容
检查数据库用户情况
检查方法
col default_tablespace form a25
col temporary_tablespace form a25
col username form a15
select username,
default_tablespace,
temporary_tablespace
from dba_users;
检查是否有用户的缺省表空间和临时表空间设置为SYSTEM表空间。
检查结果
□ 正常 □ 异常
备注
内容
检查数据文件的自动增长是否关闭
检查方法
select
from dba_data_files
where autoextensible='YES';
如果存在这样的数据文件就要关闭自动增长
检查结果
□ 正常 □ 异常
备注
内容
表空间的总容量和总空闲:
检查方法
select t.tablespace_name,tmb ,fmb from
(select tablespace_name,round(sum(bytes/1024/1024)) fmb from
dba_free_space group by tablespace_name) f,
(select tablespace_name,round(sum(bytes/1024/1024)) tmb from
dba_data_files group by tablespace_name) t
where t.tablespace_name=f.tablespace_name order by tmb;
检查结果
◆ 正常 □ 异常
备注
内容
大表的信息:
检查方法
select SEGMENT_NAME,TABLESPACE_NAME,BLOCKS,EXTENTS
from dba_segments
where (EXTENTS>50 or BLOCKS>10000) and
SEGMENT_TYPE='TABLE' AND tablespace_name='USERS01'
order by BLOCKS desc;
检查结果
◆ 正常 □ 异常
备注
内容
大索引的信息:
检查方法
select SEGMENT_NAME,TABLESPACE_NAME,BLOCKS,EXTENTS
from dba_segments
where (EXTENTS>50 or BLOCKS>10000) and
SEGMENT_TYPE='INDEX' AND tablespace_name='USERS01'
order by BLOCKS desc;
检查结果
◆ 正常 □ 异常
备注
内容
数据库的统计:
检查方法
select NAME,value from v$sysstat where value>1000 order by 2;
检查结果
◆ 正常 □ 异常
备注
内容
数据库前几位的等待事件
检查方法
select event,TOTAL_WAITS from V$system_event where TOTAL_WAITS>1000 order by 2;
检查结果
◆ 正常 □ 异常
备注
内容
数据库内的运行量大的SQL语句:
检查方法
select max(EXECUTIONS),max(DISK_READS),max(BUFFER_GETS), max(ROWS_PROCESSED) from v$sqlarea;
检查结果
◆ 正常 □ 异常
备注
内容
运行次数多的语句
检查方法
select sql_text ,EXECUTIONS from v$sqlarea where EXECUTIONS>1409607 order by 2;
检查结果
◆ 正常 □ 异常
备注
内容
数据库统计信息的收集
检查方法
select table_name,num_rows from dba_tables where owner='XA_USER' order by 2;
检查结果
□ 正常 □ 异常
备注
内容
数据库的参数设置:
检查方法
select NAME,VALUE from v$parameter where value is not null order by 1;
检查结果
◆ 正常 □ 异常
备注
内容
排序的统计:
检查方法
Select name,value from v$sysstat where name like ‘%sort%’;
检查结果
◆ 正常 □ 异常
备注
内容
数据内存的命中率:
检查方法
SELECT 1 - (phy.value -lob.value -dir.value) / ses.value
"CACHE HIT RATIO" FROM v$sysstat ses, v$sysstat lob,
v$sysstat dir, v$sysstat phy
WHERE ses.name = 'session logical reads'
AND dir.name = 'physical reads direct'
AND lob.name = 'physical reads direct (lob)'
AND phy.name = 'physical reads';
检查结果
□ 正常 □ 异常
备注
内容
SQL语句的内存命中率:
检查方法
select NAMESPACE,GETHITRATIO from V$LIBRARYCACHE;
检查结果
□ 正常 □ 异常
备注
内容
IO的信息:
检查方法
select name,PHYRDS,PHYWRTS from v$ f,v$datafile d
where f. order by PHYRDS;
检查结果
□ 正常 □ 异常
备注
内容
LATCH的应用状况评估和建议
检查方法
select NAME,GETS,MISSES from V$latch where MISSES>100;
检查结果
□ 正常 □ 异常
备注
内容
关于长查询的对象
检查方法
col MESSAGE for a80
select MESSAGE,count(*) from v$session_longops
group by MESSAGE;
检查结果
□ 正常 □ 异常
备注
13 / 13
展开阅读全文