Oracle数据库日常检查

内容
数据库是否处于归档模式
检查方法
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/.... file=backup.dmp rows=n indexfile=backup.sql
检查结果
正常     异常
备注
 
 
内容
表空间使用情况
检查方法
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 file_name,autoextensible
from dba_data_files
where autoextensible='YES';
如果存在这样的数据文件就要关闭自动增长
检查结果
正常     异常
备注
 

 

所有表空间检查SQL

select a.tablespace_name,
       totalspace,      
       round((totalspace - nvl(freespace, 0)),3) USERSPACE,
       round(((totalspace - nvl(freespace, 0)) / totalspace),3) * 100 useratio,
    nvl(freespace, 0) freespace
  from (select tablespace_name, sum(bytes) / 1048576 totalspace
          from dba_data_files
         group by tablespace_name) a,
       (select tablespace_name, sum(Bytes) / 1048576 freespace
          from dba_free_space
         group by tablespace_name) b
 where a.tablespace_name = b.tablespace_name(+)
   --and ((totalspace - nvl(freespace, 0)) / totalspace) * 100 > 90
--and nvl(freespace,0) < 1000  -- only list TSs < 1GB free
 order BY TABLESPACE_NAME;

 

所有数据文件检查SQL

SELECT /*+ ordered no_merge(v) */
 v.status "Status",
 d.file_name "Name",
 d.tablespace_name "Tablespace",
 TO_CHAR(NVL(d.bytes / 1024 / 1024, 0), '99999990.000') "Size (M)",
 TO_CHAR(NVL((d.bytes - NVL(s.bytes, 0)) / 1024 / 1024, 0), '99999999.999') || '/' ||
 TO_CHAR(NVL(d.bytes / 1024 / 1024, 0), '99999999.999') || '/' ||
 NVL(d.autoextensible, 'NO') "Used (M)",
 TO_CHAR(NVL((d.bytes - NVL(s.bytes, 0)) / d.bytes * 100, 0), '990.00') "Used %"
  FROM sys.dba_data_files d,
       v$datafile v,
       (SELECT file_id, SUM(bytes) bytes
          FROM sys.dba_free_space
         GROUP BY file_id) s
 WHERE (s.file_id(+) = d.file_id)
   AND (d.file_name = v.name)
UNION ALL
SELECT /*+ ordered no_merge(v) */
 v.status "Status",
 d.file_name "Name",
 d.tablespace_name "Tablespace",
 TO_CHAR(NVL(d.bytes / 1024 / 1024, 0), '99999990.000') "Size (M)",
 TO_CHAR(NVL(t.bytes_cached / 1024 / 1024, 0), '99999999.999') || '/' ||
 TO_CHAR(NVL(d.bytes / 1024 / 1024, 0), '99999999.999') || '/' ||
 NVL(d.autoextensible, 'NO') "Used (M)",
 TO_CHAR(NVL(t.bytes_cached / d.bytes * 100, 0), '990.00') "Used %"
  FROM sys.dba_temp_files d, v$temp_extent_pool t, v$tempfile v
 WHERE (t.file_id(+) = d.file_id)
   AND (d.file_id = v.file#)

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值