Database Support Engineer Oracle資料庫支援工程師手冊
TROUBLESHOOTING STEPS
1) High memory usage/memory leak related issue
set pages 999
clear col
spool pga.out
select to_char(sysdate,'DD-MON-YY HH:MI:SS') from dual;
PROMPT
PROMPT V$SESSSTAT MEMORY INFO
PROMPT -------------------------
select p.spid, s.sid, substr(n.name,1,25) memory, s.value
from v$sesstat s , v$statname n,v$process p,v$session vs
where s.statistic# = n.statistic#
and n.name like '%pga memory%' and s.sid=vs.sid
and vs.paddr=p.addr order by s.value asc;
PROMPT
PROMPT LARGEST PGA_ALLOC_MEM PROCESS NOT LIKE LGWR
PROMPT -------------------------
select pid,spid,substr(username,1,20) "USER" ,program,
PGA_USED_MEM,PGA_ALLOC_MEM,PGA_FREEABLE_MEM,PGA_MAX_MEM
from v$process where pga_alloc_mem=
(select max(pga_alloc_mem) from v$process
where program not like '%LGWR%');
PROMPT
PROMPT SELECT SUM(PGA_ALLOC_MEM) FROM V$PROCESS
PROMPT -------------------------
select sum(pga_alloc_mem) from v$process;
PROMPT
PROMPT SELECT FROM V$PROCESS
PROMPT -------------------------
select spid, program,pga_alloc_mem from v$process
order by pga_alloc_mem desc;
PROMPT
PROMPT SELECT * FROM V$PGASTAT
PROMPT -------------------------
select substr(name,1,30), value, unit from v$pgastat;
show parameter
spool off
exit
Total memory used by Oracle.
--------------
select sum(bytes)/1024/1024 mb from (select bytes from v$sgastat union select value bytes from v$sesstat s, v$statname n where n.STATISTIC# = s.STATISTIC# and n.name = 'session pga memory' );
Process memory
---------------
select a.sid,value/(1024*1024),program from v$session a, v$sesstat b where a.sid=b.sid and b.statistic#=(select statistic# from v$statname where name='session pga memory');
If you have identified any specific session/process consuming high memory, then request you to gather the below information
select spid,pga_used_mem,pga_alloc_mem from v$process where addr=(select paddr from v$session where sid=
oradebug setospid
oradebug dump heapdump 536870917
oradebug tracefile_name
Related article NOTE.233869.1 Diagnosing and Resolving ORA-4030 error
2) Invalid objects related issues
set pages 1000
set lines 120
col owner format a30
col object_name format a30
col object_type format a30
col comp_id format a20
col comp_name format a40
col version format a10
col status format a15
col dbname format a15
spool INVALID_OBJECTS_AND_REGISTRY_INFO.lst
PROMPT DATABASE NAME
PROMPT =============
select sys_context('USERENV','DB_NAME') DBNAME from dual;
PROMPT COUNT OF INVALID OBJECTS
PROMPT ========================
select count(*) from dba_objects where status='INVALID';
PROMPT INVALID OBJECTS GROUPED BY OBJECT TYPE AND OWNER
PROMPT ================================================
select owner,object_type,count(*) from dba_objects where status='INVALID' group by owner,object_type;
PROMPT DBA_REGISTRY CONTENTS (VIEW DOES NOT EXISIT IN VERSIONS < 9.2.0)
PROMPT ================================================================
select comp_id,comp_name,version,status from dba_registry;
spool off
spool INVALID_OBJECTS.lst
PROMPT LIST OF INVALID OBJECTS
PROMPT =======================
select owner,object_name,object_type from dba_objects where status='INVALID';
spool off
Related article NOTE.300056.1 Debug and Validate Invalid Objects
3) Hanganalyze and systemstate
$ sqlplus /nolog
connect / as sysdba
oradebug setmypid
oradebug unlimit
oradebug hanganalyze 3
wait 90 seconds
oradebug hanganalyze 3
exit
$ sqlplus /nolog
connect / as sysdba
oradebug setmypid
oradebug unlimit
oradebug dump systemstate 10
wait 90 seconds
oradebug dump systemstate 10
wait 90 seconds
oradebug dump systemstate 10
exit
Use level 266 where appropriate
Related articles
Note 61552.1 Diagnosing Database Hanging Issues
Note.215858.1 Interpreting HANGANALYZE trace files to diagnose hanging and performance problems
Note.423153.1 Understanding and Reading Systemstates
4) Status of JVM
-- script to determine the status of the Oracle JVM and required packages
connect / as sysdba
spool jvm_stat.log
set serveroutput on
set echo on
set pagesize500
set linesize 100
column comp_name format a40
select comp_name, version, status from dba_registry;
select owner, status, count(*) from all_objects
where object_type like '%JAVA%' group by owner, status;
select owner, object_type, count(*) from all_objects
where object_type like '%JAVA%' and status <> 'VALID' group by owner, object_type;
select owner, status, object_type, object_name from all_objects
where object_name like'%DBMS_JAVA%';
select owner, status, object_type, object_name from all_objects
where object_name like'%INITJVMAUX%';
select * from v$sgastat where POOL = 'java pool' or NAME = 'free memory';
show parameter pool_size
show parameter sga
select owner, object_type, status, dbms_java.longname(object_name) from all_objects
where object_type like '%JAVA%' and status <> 'VALID';
spool off
/
Related article Note 842449.1 Troubleshooting Oracle JVM
5) Scheduler related issues
set ver off
set term off
set page 0
set markup html on spool on
spool scheduler.html
alter session set NLS_TIMESTAMP_TZ_FORMAT='DD-MON-RR HH.MI.SS AM TZR'
/
alter session set NLS_DATE_FORMAT='DD-MON-RR HH.MI.SS AM'
/
select WINDOW_NAME,WINDOW_PRIORITY,ENABLED,RESOURCE_PLAN,NEXT_START_DATE,
DURATION from DBA_SCHEDULER_WINDOWS
/
select LOG_DATE,WINDOW_NAME,REQ_START_DATE,ACTUAL_START_DATE,WINDOW_DURATION,
ACTUAL_DURATION,ADDITIONAL_INFO from DBA_SCHEDULER_WINDOW_DETAILS
where rownum<20
order by LOG_DATE
/
select LOG_DATE,STATUS,WINDOW_NAME, OPERATION from DBA_SCHEDULER_WINDOW_LOG
order by LOG_DATE desc
/
select WINDOW_GROUP_NAME, ENABLED, NEXT_START_DATE from DBA_SCHEDULER_WINDOW
_GROUPS
/
select LOG_DATE, OWNER,JOB_NAME, STATUS,ERROR#,REQ_START_DATE,ACTUAL_START_DATE,
ADDITIONAL_INFO from DBA_SCHEDULER_JOB_RUN_DETAILS
where JOB_NAME in ('GATHER_ITEM_STATS_JOB')
order by LOG_DATE
/
show parameter job_queue
/
spool off
set markup html off spool off
Related article Note 783357.1 Troubleshooting DBMS_SCHEDULER and DBMS_JOB
6) Session genrating high redo
SQL> SELECT s.sid, s.serial#, s.username, s.program,
i.block_changes
FROM v$session s, v$sess_io i
WHERE s.sid = i.sid
ORDER BY 5 desc, 1, 2, 3, 4;
SQL> SELECT s.sid, s.serial#, s.username, s.program,
t.used_ublk, t.used_urec
FROM v$session s, v$transaction t
WHERE s.taddr = t.addr
ORDER BY 5 desc, 6 desc, 1, 2, 3, 4;
Related article NOTE.167492.1 How to Find Sessions Generating Lots of Redo
7) Enterprise manager tablespace alert issues
-- QUERY 1: The following query shows the outstanding alerts that the RDBMS is aware of:
SELECT REASON
, METRIC_VALUE
, MESSAGE_TYPE
, TO_CHAR(CREATION_TIME,'DD-MON-YYYY HH24:MI:SS')
, HOST_ID
FROM SYS.DBA_OUTSTANDING_ALERTS;
-- QUERY 2: The following query shows the current thresholds settings for the RDBMS tablespace full metric:
SELECT METRICS_NAME
, WARNING_OPERATOR WARN_OP
, WARNING_VALUE WARN_VAL
, CRITICAL_OPERATOR CRIT_OP
, CRITICAL_VALUE CRIT_VAL
, OBJECT_TYPE OBJ_TYPE
, OBJECT_NAME OBJ_NAME
, STATUS
FROM SYS.DBA_THRESHOLDS
WHERE metrics_name LIKE ??????%Tablespace%??????; -- Do not replace the string ??????Tablespace??????
-- QUERY 3: The following query shows the current values for the Tablespace Used(%) metric from the perspective of the RDBMS:
SELECT TABLESPACE_NAME TBSP_NAME
, USED_SPACE
, TABLESPACE_SIZE TBSP_SIZE
, USED_PERCENT
FROM SYS.DBA_TABLESPACE_USAGE_METRICS;
Related article Note 403264.1 Troubleshooting a Database Tablespace Used(%) Alert proble
8) 10046 trace
To gather 10046 trace at the session level:
alter session set tracefile_identifier='10046';
alter session set timed_statistics = true;
alter session set statistics_level=all;
alter session set max_dump_file_size = unlimited;
alter session set events '10046 trace name context forever,level 12';
-- Execute the queries or operations to be traced here --
select * from dual;
exit;
If the session is not exited then the trace can be disabled using:
alter session set events '10046 trace name context off';
-----------------------------------------------------------------------------------------------------------
If trace from an existing session is required then oradebug can be used to attach to the session and initiate 10046 tracing.
The first step is to identify the session to be traced by some means:
For example, in SQL*Plus, start a session to find the OS process id (spid) for the target session:
select p.PID,p.SPID,s.SID from v$process p,v$session s where s.paddr = p.addr and s.sid = &SESSION_ID /
SPID is the operating system Process identifier (os pid)
PID is the Oracle Process identifier (ora pid)
Once the OS process id for the process has been determined then the trace can be initialised as follows:
Lets assume that the process to be traced has an os pid of 9834.
Login to SQL*Plus as a dba and execute the following:
connect / as sysdba
oradebug setospid 9834
oradebug unlimit
oradebug event 10046 trace name context forever,level 12
Remember to replace the example '9834' value with the actual os pid.
Note that it is also possible to attach to a session via oradebug using the 'setorapid'.
In this case the PID (Oracle Process identifier ) would be used (rather than the 'SPID') and the oradebug text would change to:
connect / as sysdba
oradebug setorapid 9834
oradebug unlimit
oradebug event 10046 trace name context forever,level 12
Remember to replace the example '9834' value with the actual ora pid.
To disable oradebug tracing once tracing is finished:
oradebug event 10046 trace name context off
-----------------------------------------------------------------------------------------------------------
System-wide tracing can be enabled as follows:
alter system set events '10046 trace name context forever,level 12';
The setting can be disabled in all sessions by using the following command:
alter system set events '10046 trace name context off';
9) Errorstack
At system level for an particular error
SQL> alter system set events ‘30926 trace name errorstack level 3’;
To unset it after trace file is produced:
SQL> alter system set events ‘30926 trace name errorstack off’;
At session level for an particular error
SQL> alter session set events ‘30926 trace name errorstack level 3’;
To unset it after trace file is produced:
SQL> alter session set events ‘30926 trace name errorstack off’;
Remember to replace the example '30926' value with the actual ora error to be traced.
10) Oradebug for getting function stack of processes
For user process use query below query to identify process associated with session
SELECT P.PID ORAPID, P.SPID OSPID FROM V$SESSION S, V$PROCESS
WHERE S.PADDR=P.ADDR AND
S.SID=&SID;
oradebug setorapid &orapid
oradebug dump errorstack 3;
oradebug tracefile_name
For background process
select p.spid from v$process p,v$bgprocess b
where p.addr=b.paddr
and name like '%SMON%');
oradebug setospid
oradebug dump errorstack 3;
oradebug tracefile_name
11) How to Trace Unix System Calls for a Process
O/S Trace Utility
----------- ------------------------------------------------------
Sun Solaris truss, e.g.:
$ truss -aefo
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10543606/viewspace-1063789/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql database manual(mysql資料庫手冊)MySqlDatabase資料庫
- Database EngineerDatabase
- 【轉】Oracle資料庫日常維護手冊Oracle資料庫
- Oracle資料庫日常維護手冊 (zt)Oracle資料庫
- Oracle 9i 資料庫建立手冊Oracle資料庫
- oracle之 oracle database vault(資料庫保險庫)OracleDatabase資料庫
- 資料庫命令速查手冊資料庫
- 【PingCAP】Database Kernel EngineerPingCAPDatabase
- 【PingCAP】Database Storage EngineerPingCAPDatabase
- XML資料庫開發手冊XML資料庫
- Database Firewall安全手冊Database
- 檢視Oracle Database 10g 的資料庫支援的作業系統OracleDatabase資料庫作業系統
- 超大資料庫和分割槽手冊大資料資料庫
- PostgreSQL學習手冊(資料庫管理)SQL資料庫
- Oracle資料庫開啟NUMA支援Oracle資料庫
- Oracle 資料庫官方不支援VMWareOracle資料庫
- Database Firewall管理員手冊Database
- Oracle 資料庫重放(Database Replay)功能演示Oracle資料庫Database
- XML資料庫開發手冊總結XML資料庫
- [轉] 連線資料庫查詢手冊資料庫
- PostgreSQL學習手冊(資料庫維護)SQL資料庫
- 手動建立oracle資料庫Oracle資料庫
- Oracle 手動建立資料庫Oracle資料庫
- 資料工程師妹子養成手記——資料庫篇工程師資料庫
- Oracle & MySQL & PostgreSQL資料庫恢復支援OracleMySql資料庫
- Oracle 資料庫官方申明不支援VmwareOracle資料庫
- Oracle Database 12c可插拔資料庫案例OracleDatabase資料庫
- Java工程師手冊Java工程師
- Database Firewall安全手冊總結Database
- 管理RMAN資料庫——RMAN使用者手冊資料庫
- UT 資料庫日常維護指導手冊資料庫
- Support Status - Oracle Database on Linux Itanium [ID 1130325.1]OracleDatabaseLinux
- Autodesk正在招聘Civil、Infraworks金牌支援工程師(Premium Support Specialist)工程師REM
- oracle手動刪除資料庫Oracle資料庫
- 手動刪除oracle資料庫Oracle資料庫
- 手工建立oracle示例資料庫schema (Database Examples 安裝)Oracle資料庫Database
- database資料庫的資料結構Database資料庫資料結構
- Database Firewall管理員手冊總結Database