1.检查Oracle的进程
ps -ef|grep "ora_"|grep -v grep
ora_dbw0_orcl
ora_lgwr_orcl
ora_ckpt_orcl
ora_smon_orcl
ora_reco_orcl
ora_pmon_orcl
ora_arc0_orcl
2.检查Oracle监听进程
lsnrctl status
3.检查Oracle实例状态
select instance_name,version,status,database_status from v$instance;
select name,log_mode,open_mode from v$database;
4.检查操作系统的日志文件
cat /var/log/messages|grep oracle
5.检查root用户和Oracle用户的email
more /var/mail/root
more /var/mail/oracle
6.检查Oracle日志文件
cat $ORACLE_BASE/admin/orcl/bdump/alert_ORCL.log|grep -i ora-
cat $ORACLE_BASE/admin/orcl/bdump/alert_orcl.log|grep -i err
cat $ORACLE_BASE/admin/orcl/bdump/alert_orcl.log|grep -i fail
7.检查Oracle核心转储目录
ls $ORACLE_BASE/admin/orcl/cdump/*.trc|wc -l
ls $ORACLE_BASE/admin/orcl/udump/*.trc|wc -l
8.检查控制文件状态
select * from v$controlfile;
9.检查Oracle在线日志状态
select * from v$logfile;
10.检查表空间状态
select tablespace_name,status from dba_tablespaces;
11.检查所有数据文件状态
select name,status from v$datafile;
12.检查对象的状态
select owner,object_name,object_type from dba_objects where status!='VALID'
13.检查Oracle所有回滚段的状态
select segment_name,status from dba_rollback_segs;
14.检查Oracle初始化文件中相关的参数值
select resource_name,max_utilization,initial_allocation,limit_value from v$resource_limit;
15.检查Oracle各个表空间的增长情况(当used_percent大于90%时得增加数据文件)
select A.tablespace_name,(1-(A.total)/B.total)*100 used_percent
from
(select tablespace_name,sum(bytes) total from dba_free_space group by tablespace_name) A,
(select tablespace_name,sum(bytes) total from dba_data_files group by tablespace_name) B
where A.tablespace_name=B.tablespace_name;
16.检查一些扩展异常的对象(如有记录返回,则需修改)
select Segment_Name, Segment_Type, TableSpace_Name, (Extents/Max_extents)*100 Percent
From sys.DBA_Segments
Where Max_Extents != 0 and (Extents/Max_extents)*100>=95 order By Percent;
17.检查system表空间内的内容
select distinct(owner) from dba_tables
where tablespace_name='SYSTEM' and owner!='SYS' and owner!='SYSTEM'
union
select distinct(owner) from dba_indexes
where tablespace_name='SYSTEM' and owner!='SYS' and owner!='SYSTEM';
18.检查对象的下一扩展与表空间的最大扩展值
select a.table_name, a.next_extent, a.tablespace_name
from all_tables a, (select tablespace_name, max(bytes) as big_chunk from dba_free_space group by tablespace_name ) f
where f.tablespace_name = a.tablespace_name and a.next_extent > f.big_chunk
union
select a.index_name, a.next_extent, a.tablespace_name from all_indexes a, (select tablespace_name, max(bytes) as big_chunk
from dba_free_space group by tablespace_name ) f where f.tablespace_name = a.tablespace_name
19.切换其它实例
export ORACLE_SID=orcl
20.检查数据库定时作业的完成情况
select job,log_user,last_date,failures from dba_jobs //如果FAILURES列是一个大于0的数的话,说明JOB运行失败,要进一步的检查
21.数据库坏块的处理
当Oracle数据库出现坏块时,Oracle会在警告日志文件(alert_SID.log)中记录坏块的信息
1.确定发生坏块的数据库对象
SELECT tablespace_name,segment_type,owner,segment_name
FROM dba_extents WHERE file_id = AND between block_id AND block_id+blocks-1;
2.决定修复方法
如果发生坏块的对象是一个索引,那么可以直接把索引DROP掉后,再根据表里的记录进行重建;
如果发生坏块的表的记录可以根据其它表的记录生成的话,那么可以直接把这个表DROP掉后重建;
如果有数据库的备份,则恢复数据库的方法来进行修复;
如果表里的记录没有其它办法恢复,那么坏块上的记录就丢失了,只能把表中其它数据块上的记录取出来,然后对这个表进行重建
3.用Oracle提供的DBMS_REPAIR包标记出坏块
exec DBMS_REPAIR.SKIP_CORRUPT_BLOCKS('','');
4.使用Create table as select命令将表中其它块上的记录保存到另一张表上
create table corrupt_table_bak as select * from corrupt_table;
5.用DROP TABLE命令删除有坏块的表
drop table corrupt_table;
6.用alter table rename命令恢复原来的表
alter table corrupt_table_bak rename to corrupt_table;
7.如果表上存在索引,则要重建表上的索引
22.当前数据库建立的会话情况
select sid,serial#,username,program,machine,status from v$session;
STATUS 当前这个会话的状态,ACTIVE表示会话正在执行某些任务,INACTIVE表示当前会话没有执行任何操作
alter system kill session 'SID,SERIAL#';
SID为1到7(USERNAME列为空)的会话,是Oracle的后台进程,不要对这些会话进行任何操作
23.Oracle在运行过程中,会在警告日志文件(alert_SID.log)中记录数据库的一些运行情况:
1 数据库的启动、关闭,启动时的非缺省参数;
2 数据库的重做日志切换情况,记录每次切换的时间,及如果因为检查点(checkpoint)操作没有执行完成造成不能切换,会记录不能切换的原因;
3 对数据库进行的某些操作,如创建或删除表空间、增加数据文件;
4 数据库发生的错误,如表空间不够、出现坏块、数据库内部错误(ORA-600)
24.数据库表空间使用情况监控(字典管理表空间)
select tablespace_name, count(*) chunks , max(bytes/1024/1024) max_chunk from dba_free_space group by tablespace_name;
CHUNKS列表示表空间中有多少可用的空闲块(每个空闲块是由一些连续的Oracle数据块组成),如果这样的空闲块过多,比如平均到每个
数据文件上超过了100个,那么该表空间的碎片状况就比较严重了,可以尝试用以下的SQL命令进行表空间相邻碎片的接合
alter tablespace 表空间名 coalesce;
MAX_CHUNK列的结果是表空间上最大的可用块大小
25.检查了dispatchers, servers, queue 和session的状态
select name,status,messages,idle,busy,bytes,breaks from v$dispatcher;
select name,status,messages,bytes,idle,busy,requests from v$shared_server;
select * from v$queue;
select username,program,server from v$session;
26.SGA内存管理
select * from v$sgainfo;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/658698/viewspace-254561/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/658698/viewspace-254561/