linux下oracle日常维护

linux中oracle的日常维护命令2008-04-08 10:171 检查Oracle的进程
[oracle@mzl ~]$ ps -ef|grep "ora_"|grep -v grep
oracle    2791     1 0 17:22 ?        00:00:00 ora_pmon_ORCL
oracle    2793     1 0 17:22 ?        00:00:00 ora_psp0_ORCL
oracle    2795     1 0 17:22 ?        00:00:00 ora_mman_ORCL
oracle    2797     1 0 17:22 ?        00:00:00 ora_dbw0_ORCL
......
在检查Oracle的进程命令输出后,输出显示至少应包括以下一些进程:
• Oracle写数据文件的进程,输出显示为:“ora_dbw0_ORCL”
• Oracle写日志文件的进程,输出显示为:“ora_lgwr_ORCL”
• Oracle监听实例状态的进程,输出显示为:“ora_smon_ORCL”
• Oracle监听客户端连接进程状态的进程,输出显示为:“ora_pmon_ORCL”
• Oracle进行归档的进程,输出显示为:“ora_arc0_ORCL”
• Oracle进行检查点的进程,输出显示为:“ora_ckpt_ORCL”
• Oracle进行恢复的进程,输出显示为:“ora_reco_ORCL”


2  
查看数据库的实例:
SQL> select instance_name,status,version,database_status from v$instance;

INSTANCE_NAME    STATUS       VERSION           DATABASE_STATUS
---------------- ------------ ----------------- -----------------
ORCL             OPEN         10.2.0.1.0        ACTIVE

   其中“STATUS”表示Oracle当前的实例状态,必须为“OPEN”;“DATABASE_STATUS”表
示Oracle当前数据库的状态,必须为“ACTIVE”。

3 查看数据库的日志模式,打开模式
SQL> select name,log_mode,open_mode from v$database;

NAME      LOG_MODE     OPEN_MODE
--------- ------------ ----------
ORCL      ARCHIVELOG   READ WRITE
其中“LOG_MODE”表示Oracle当前的归档方式。“ARCHIVELOG”表示数据库运行在归档
模式下,“NOARCHIVELOG”表示数据库运行在非归档模式下。在我们的系统中数据库必须运
行在归档方式下。

4 查看数据库alert_SID.log 中的ora-的错误信息:
[oracle@mzl ~]$ cat /u01/app/oracle/admin/orcl/bdump/alert_ORCL.log|grep -i ora-
ORA-1126 signalled during: alter database archivelog ...
ORA-1126 signalled during: alter database archivelog...
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/u01/app/oracle/oradata/orcl/users01.dbf'

查alert_SID.log中的err的信息:
[oracle@mzl ~]$ cat $ORACLE_BASE/admin/orcl/bdump/alert_ORCL.log|grep -i err
Mem# 0 errs 0: /u01/app/oracle/oradata/orcl/redo01.log
Mem# 0 errs 0: /u01/app/oracle/oradata/orcl/redo02.log


查alert_SID.log的fail的信息:
[oracle@mzl ~]$ cat $ORACLE_BASE/admin/orcl/bdump/alert_ORCL.log|grep -i fail
PMON failed to acquire latch, see PMON dump
PMON failed to acquire latch, see PMON dump
PMON failed to acquire latch, see PMON dump


5
检查控制文件状态:
SQL> select status,name from v$controlfile;

STATUS NAME
------- --------------------------------------------------
        /u01/app/oracle/oradata/orcl/control01.ctl
        /u01/app/oracle/oradata/orcl/control02.ctl
        /u01/app/oracle/oradata/orcl/control03.ctl
输出结果应该有3条以上(包含3条)的记录,“STATUS”应该为空。状态为空表示控制
文件状态正常。

6 查询日志状态
SQL> select group#,status,member from v$logfile;

    GROUP# STATUS MEMBER
---------- ------- --------------------------------------------------
         2         /u01/app/oracle/oradata/orcl/redo02.log
         1 STALE   /u01/app/oracle/oradata/orcl/redo01.log
         3 STALE   /u01/app/oracle/oradata/orcl/redo03.log
    输 出结 果应该 有 3 条以上 (包 含 3 条)记 录, “ STATUS ” 应该为 非 “ INVALID” , 非“DELETED”。

7   查询数据状态:
SQL> select file#,status,name from v$datafile;

     FILE# STATUS NAME
---------- ------- --------------------------------------------------
         1 SYSTEM /u01/app/oracle/oradata/orcl/system01.dbf
         2 ONLINE /u01/app/oracle/oradata/orcl/undotbs01.dbf
         3 ONLINE /u01/app/oracle/oradata/orcl/sysaux01.dbf
         4 ONLINE /u01/app/oracle/oradata/orcl/users01.dbf
         5 ONLINE /u01/app/oracle/oradata/orcl/example01.dbf
         6 ONLINE /u01/app/oracle/oradata/orcl/perfstat.dbf
         7 ONLINE /u01/app/oracle/oradata/orcl/risenet.dbf

7 rows selected.
“ONLINE"表示正常在线状态

8 查询表空间状态:
SQL> select tablespace_name,status from dba_tablespaces;

TABLESPACE_NAME                STATUS
------------------------------ ---------
SYSTEM                         ONLINE
UNDOTBS1                       ONLINE
SYSAUX                         ONLINE
TEMP                           ONLINE
USERS                          ONLINE
EXAMPLE                        ONLINE
PERFSTAT                       ONLINE
RISENET                        ONLINE

8 rows selected.
“ONLINE”表示正常在线状态


      检查Oracle所有回滚段的状态

SQL> select segment_name,status from dba_rollback_segs;

SEGMENT_NAME                   STATUS
------------------------------ ----------------
SYSTEM                         ONLINE
_SYSSMU10$                     ONLINE
_SYSSMU9$                      ONLINE
_SYSSMU8$                      ONLINE
_SYSSMU7$                      ONLINE
_SYSSMU6$                      ONLINE
_SYSSMU5$                      ONLINE
_SYSSMU4$                      ONLINE
_SYSSMU3$                      ONLINE
_SYSSMU2$                      ONLINE
_SYSSMU1$                      ONLINE

11 rows selected.


10         检查Oracle初始化文件中相关的参数值



SQL> l
1* select resource_name,current_utilization,max_utilization,initial_allocation,limit_value from v$resource_limit
SQL> /

RESOURCE_NAME   CURRENT_UTILIZATION MAX_UTILIZATION INITIAL_AL LIMIT_VALU
--------------- ------------------- --------------- ---------- ----------
processes                        20              30        150        150
sessions                         25              33        170        170
enqueue_locks                    14              22       2300       2300
enqueue_resourc                  14              37        968 UNLIMITED
es

ges_procs                         0               0          0          0
ges_ress                          0               0          0 UNLIMITED
ges_locks                         0               0          0 UNLIMITED
ges_cache_ress                    0               0          0 UNLIMITED
ges_reg_msgs                      0               0          0 UNLIMITED

RESOURCE_NAME   CURRENT_UTILIZATION MAX_UTILIZATION INITIAL_AL LIMIT_VALU
--------------- ------------------- --------------- ---------- ----------
ges_big_msgs                      0               0          0 UNLIMITED
ges_rsv_msgs                      0               0          0          0
gcs_resources                     0               0          0          0
gcs_shadows                       0               0          0          0
dml_locks                         0              44        748 UNLIMITED
temporary_table                   0               0 UNLIMITED UNLIMITED
_locks

transactions                      0              10        187 UNLIMITED
branches                          0               0        187 UNLIMITED
cmtcallbk                         0               1        187 UNLIMITED

RESOURCE_NAME   CURRENT_UTILIZATION MAX_UTILIZATION INITIAL_AL LIMIT_VALU
--------------- ------------------- --------------- ---------- ----------
sort_segment_lo                   0               1 UNLIMITED UNLIMITED
cks

max_rollback_se                  11              11        187      65535
gments

max_shared_serv                   1               1 UNLIMITED UNLIMITED
ers

parallel_max_se                   0               2         40       3600
rvers

RESOURCE_NAME   CURRENT_UTILIZATION MAX_UTILIZATION INITIAL_AL LIMIT_VALU
--------------- ------------------- --------------- ---------- ----------


22 rows selected.



11
      检查Oracle各个表空间的增长情况

SQL> l
1 select
2     A.tablespace_name,(1-(A.total)/B.total)*100 used_percent
3     from
4     (select tablespace_name,sum(bytes) total
5             from dba_free_space group by tablespace_name) A,
6     (select tablespace_name,sum(bytes) total
7             from dba_data_files group by tablespace_name) B
8*    where A.tablespace_name=B.tablespace_name
SQL> /

TABLESPACE_NAME                USED_PERCENT
------------------------------ ------------
UNDOTBS1                              33.25
SYSAUX                           99.0364583
RISENET                               .0125
USERS                                  62.5
SYSTEM                           98.6067708
EXAMPLE                               68.25
PERFSTAT                            28.7625

7 rows selected.

12       检查一些扩展异常的对象

SQL> select segment_name,segment_type,tablespace_name,
2      (extents/max_extents)*100 Percent
3      from sys.DBA_segments
4      where max_extents!=0 and (extents/max_extents)*100>=95
5 order by percent;

no rows selected
如果有记录返回,则这些对象的扩展已经快达到它定义时的最大扩展值。对于这些对象
要修改它的存储结构参数.

13      检查system表空间内的内容

SQL> select distinct(owner) from dba_tables
2 where tablespace_name='SYSTEM' and
3 owner!='SYS' and owner!='SYSTEM'
4 union
5 select distinct(owner) from dba_indexes
6 where tablespace_name='SYSTEM' and
7 owner!='SYS' and owner!='SYSTEM';

OWNER
------------------------------
MDSYS
OLAPSYS
OUTLN
如果有记录返回,则表明system表空间内存在一些非system和sys用户的对象。应该进一
步检查这些对象是否与我们应用相关。如果相关请把这些对象移到非System表空间,同时应
该检查这些对象属主的缺省表空间值,

14
      检查对象的下一扩展与表空间的最大扩展值
SQL> select a.table_name,a.next_extent,a.tablespace_name
2      from all_tables a,
3      (select tablespace_name,max(bytes) as big_chunk
4      from dba_free_space group by tablespace_name) f
5      where f.tablespace_name=a.tablespace_name
6      and a.next_extent>f.big_chunk
7      union
8      select a.index_name,a.next_extent,a.tablespace_name
9      from all_indexes a,
10      (select tablespace_name,max(bytes) as big_chunk
11      from dba_free_space
12      group by tablespace_name) f
13      where f.tablespace_name=a.tablespace_name
14      and a.next_extent>f.big_chunk;

no rows selected

如果有记录返回,则表明这些对象的下一个扩展大于该对象所属表空间的最大扩展值,
需调整相应表空间的存储参数

你可能感兴趣的:(oracle)