1.사용가능한 DBMS 패키지
select *
from dba_objects
where object_name like 'DBMS%'
and object_type = 'PACKAGE' ORDER BY OBJECT_NAME;
2. 계정에서 못찾을때는 권한을 주자 (개인테스트)
grant alter session to scott;3. dbms 모니터 실행권한 주기
GRANT EXECUTE ON dbms_monitor TO PUBLIC;
4. 서비스 명을 알아낸다.
show parameter service_name;
SQL Trace 사용 방법 - 다른세션에서 트레이스
(1) 9i에서
exec dbms_system.set_ev(145, 3, 10046, 12, '');
=> 시리얼 번호가 3인 145번 세션에서 레벨 12로 10046 이벤트 트레이스
(2) 10g
(시작)
begin
dbms_monitor.session_trace_enable(
session_id=>145, serial_num=>3,
waits=>TRUE, binds=>TRUE);
end;
/
(해제)
begin
dbms_monitor.session_trace_disable(
session_id=>145, serial_num=>3);
end;
/
(3) oradebug 명령어
oradebug help
oradebug setospid 3796
oradebug unlimit /* 트레이스 파일의 크기를 없앰 */
oradebug event 10046 trace name context forever, level 8
oradebug tracefile_name /* 트레이스 파일 이름 확인 */
oradebug event 10046 trace name context off /* 트레이스 해제 */
oradebug close_trace
SQL Trace 사용 방법 - Service, Modele, Action 단위로 트레이스 걸기- 10g
- show parameter service_name;
- /* 서비스나 모듈 이름 보는 방법 */
select sid, service_name, module, action
from v$session
where service_name <> 'SYS$BACKGROUND';
(1) 세션에 거는 방법 - 세션 이름이 eCRM인 세션에 모두 트레이스 걸기
begin
dbms_monitor.serv_mod_act_trace_enable(
service_name=>'eCRM',
module_name=>dbms_monitor.all_modules,
action_name=>dbms_monitor.all_actions,
waits=>true, binds=>true);
end;
/
(트레이스 설정 확인)
select primary_id service_name, qualifier_id1 module, qualifier_id2 action,
waits, binds
from dba_enabled_traces;
(트레이스 해제)
begin
dbms_monitor.serv_mod_act_trace_disable(
service_name=>'eCRM',
module_name=>dbms_monitor.all_modules,
action_name=>dbms_monitor.all_actions);
end;
/
(2) 모듈에 거는 방법
(모듈 이름 바꾸기)
begin
dbms_application_info.set_module(
module_name=>'emp manager',
action_name=>'select emp');
end;
/
(확인)
select sid, service_name, module, action
from v$session
where service_name <> 'SYS$BACKGROUND';
(모듈에 걸기)
begin
dbms_monitor.serv_mod_act_trace_enable(
service_name=>'eCRM', module_name=>'emp manager',
action_name=>dbms_monitor.all_actions,
waits=>true, binds=>true);
end;
/
(트레이스 설정 확인)
select primary_id service_name, qualifier_id1 module, qualifier_id2 action,
waits, binds
from dba_enabled_traces;
(트레이스 해제)
begin
dbms_monitor.serv_mod_act_trace_disable(
service_name=>'eCRM', module_name=>'emp manager',
action_name=>dbms_monitor.all_actions);
end;
/
(실행 중 부분 모듈에 걸기)
..
dbms_application_info.set_action('update emp');
..
begin
dbms_monitor.serv_mod_act_trace_enable(
service_name=>'eCRM', module_name=>‘emp manager',
action_name=>'update emp',
waits=>true, binds=>true);
end;
/
select primary_id service_name, qualifier_id1 module, qualifier_id2 action,
waits, binds
from dba_enabled_traces;
(특정값으로 설정된 세션에만 트레이스 걸기)
- 설정
exec dbms_session.set_identifier('oraking');
- 트레이스 걸기
begin
dbms_monitor.client_id_trace_enable(
client_id=>'oraking',
waits=>false, binds=>false);
end;
/
오라클 성능 고도화
'튜닝' 카테고리의 다른 글
| v$system_event (0) | 2016.12.26 |
|---|---|
| DBMS_XPLAN 활용 (0) | 2016.12.23 |
| 눈여겨 볼만한 대기 이벤트들 (0) | 2016.12.22 |
| TKPROF 사용 기본 (0) | 2016.12.22 |
| SQL Trace 위치 찾는 스크립트 (0) | 2016.12.22 |