[Oracle] AWR(Automatic Workload Repository)

๋ด„ยท2025๋…„ 9์›” 5์ผ

์˜ค๋ผํด ๊ด€๋ฆฌ

๋ชฉ๋ก ๋ณด๊ธฐ
105/163

๐Ÿ”Ž ์˜ค๋ผํด์ด ์ž์‹ ์˜ ๋ฌธ์ œ๋ฅผ ์Šค์Šค๋กœ ์ง„๋‹จํ•˜๊ณ  ๊ทธ ๋ฌธ์ œ์ ์— ๋Œ€ํ•œ ๋‚ด์šฉ์„ ์ €์žฅํ•˜๋Š” ๊ณต๊ฐ„

AWR(Automatic Workload Repository)


๐Ÿ”Ž AWR์ด ์žˆ๋Š” ๊ณต๊ฐ„์ด ์–ด๋А ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค์ธ๊ฐ€?

sysaux ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค


[์‹ค์Šต1] 1์‹œ๊ฐ„์— ํ•œ๋ฒˆ์”ฉ ์„ฑ๋Šฅ์ •๋ณด๋ฅผ ์ž๋™์œผ๋กœ ์ˆ˜์ง‘ํ•˜๊ณ  ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ

SYS @ ora19dw > @?/rdbms/admin/awrrpt.sql


report_type์˜ ๊ฐ’์„ ์ž…๋ ฅํ•˜์‹ญ์‹œ์˜ค: html
๊ตฌ   1: select 'Type Specified: ',lower(nvl('&&report_type','html')) report_type from dual
์‹    1: select 'Type Specified: ',lower(nvl('html','html')) report_type from dual

Type Specified:  html

๊ตฌ   1: select '&&report_type' report_type_def from dual
์‹    1: select 'html' report_type_def from dual



๊ตฌ   1: select '&&view_loc' view_loc_def from dual
์‹    1: select 'AWR_PDB' view_loc_def from dual



Current Instance
~~~~~~~~~~~~~~~~
DB Id          DB Name        Inst Num       Instance       Container Name
-------------- -------------- -------------- -------------- --------------
 1004651910     ORA19DW                     1 ora19dw        ora19dw



Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  DB Id      Inst Num   DB Name      Instance     Host
------------ ---------- ---------    ----------   ------
* 1004651910     1      ORA19DW      ora19dw      ora19c

Using 1004651910 for database Id
Using          1 for instance number


Specify the number of days of snapshots to choose from
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Entering the number of days (n) will result in the most recent
(n) days of snapshots being listed.  Pressing <return> without
specifying a number lists all completed snapshots.


num_days์˜ ๊ฐ’์„ ์ž…๋ ฅํ•˜์‹ญ์‹œ์˜ค:  ๊ทธ๋ƒฅ ์—”ํ„ฐ์น˜์„ธ์š”

Listing all Completed Snapshots
Instance     DB Name      Snap Id       Snap Started    Snap Level
------------ ------------ ---------- ------------------ ----------

ora19dw      ORA19DW              5  29 8์›”  2025 14:10   1
                                  6  29 8์›”  2025 16:27   1
                                  7  01 9์›”  2025 10:30   1
                                  8  01 9์›”  2025 12:00   1
                                  9  01 9์›”  2025 13:00   1
                                 10  01 9์›”  2025 14:00   1
                                 11  01 9์›”  2025 15:00   1
                                 12  01 9์›”  2025 16:00   1
                                 13  01 9์›”  2025 17:00   1
                                 14  02 9์›”  2025 16:26   1
                                 15  05 9์›”  2025 12:18   1
                                 16  05 9์›”  2025 13:00   1
                                 17  05 9์›”  2025 14:00   1
                                 18  05 9์›”  2025 15:00   1


Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
begin_snap์˜ ๊ฐ’์„ ์ž…๋ ฅํ•˜์‹ญ์‹œ์˜ค:










Instances in this Workload Repository schema
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  DB Id      Inst Num   DB Name      Instance     Host
------------ ---------- ---------    ----------   ------
* 1004651910     1      ORA19DW      ora19dw      ora19c

Using 1004651910 for database Id
Using          1 for instance number


Specify the number of days of snapshots to choose from
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Entering the number of days (n) will result in the most recent
(n) days of snapshots being listed.  Pressing <return> without
specifying a number lists all completed snapshots.


num_days์˜ ๊ฐ’์„ ์ž…๋ ฅํ•˜์‹ญ์‹œ์˜ค:

Listing all Completed Snapshots
Instance     DB Name      Snap Id       Snap Started    Snap Level
------------ ------------ ---------- ------------------ ----------

ora19dw      ORA19DW              5  29 8์›”  2025 14:10   1
                                  6  29 8์›”  2025 16:27   1
                                  7  01 9์›”  2025 10:30   1
                                  8  01 9์›”  2025 12:00   1
                                  9  01 9์›”  2025 13:00   1
                                 10  01 9์›”  2025 14:00   1
                                 11  01 9์›”  2025 15:00   1
                                 12  01 9์›”  2025 16:00   1
                                 13  01 9์›”  2025 17:00   1
                                 14  02 9์›”  2025 16:26   1
                                 15  05 9์›”  2025 12:18   1
                                 16  05 9์›”  2025 13:00   1
                                 17  05 9์›”  2025 14:00   1
                                 18  05 9์›”  2025 15:00   1


Specify the Begin and End Snapshot Ids
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
begin_snap์˜ ๊ฐ’์„ ์ž…๋ ฅํ•˜์‹ญ์‹œ์˜ค: 17

end_snap์˜ ๊ฐ’์„ ์ž…๋ ฅํ•˜์‹ญ์‹œ์˜ค: 18

๋ชจ๋ฐ”ํ…€์—์„œ html ํŒŒ์ผ ๋‹ค์šด๋ฐ›๊ณ  ์—ด์–ด๋ณด๋ฉด ๋จ



[์‹ค์Šต2] ์ˆ˜๋™์œผ๋กœ ์„ฑ๋Šฅ์ •๋ณด๋ฅผ ์ˆ˜์ง‘ํ•˜๊ฒŒ ํ•˜์‹œ์˜ค

exec dbms_workload_repository.create_snapshot;

select snap_id, begin_interval_time, end_interval_time
 from dba_hist_snapshot
 order by snap_id asc;

๋ฌธ์ œ2. scott ์œ ์ ธ์—์„œ ์•…์„ฑ SQL์„ ํ•˜๋‚˜ ๊ฑธ๊ณ  TOP ๊ณผ ์˜ค๋ Œ์ง€๋กœ ํ˜„์žฌ ๋ฐœ์ƒํ•œ ์ด์Šˆ๋ฅผ ํ™•์ธํ•˜์‹œ์˜ค

SYS @ ora19dw > connect scott/tiger
์—ฐ๊ฒฐ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.
SCOTT @ ora19dw >
SCOTT @ ora19dw > select count(*)
            from emp, emp, emp, emp, emp, emp, emp, emp, emp, emp, emp;


์˜ค๋ Œ์ง€๋ฅผ ์ผญ๋‹ˆ๋‹ค.

๋งˆ์šฐ์Šค ์šฐํด๋ฆญ - kill session ํ•˜๋ฉด
putty์˜ top์—์„œ 28913๋ฒˆ์ด ์‚ฌ๋ผ์ง


๋ฌธ์ œ3. ๊ณผ๊ฑฐ์— DB์—์„œ ๋ฐœ์ƒํ•œ ์„ฑ๋Šฅ์ƒ์˜ ์ด์Šˆ๋ฅผ ํ™•์ธํ•˜์‹œ์˜ค


ใ„ด SQL Statistics ํด๋ฆญ


๐Ÿ”ธ [๋ฌธ์ œ] hr ๊ณ„์ •์œผ๋กœ ์ ‘์†ํ•ด์„œ employees ํ…Œ์ด๋ธ”์— ๋Œ€ํ•œ ์•…์„ฑ SQL์„ ํ•˜๋‚˜ ์ˆ˜ํ–‰ํ•˜๊ณ , ์˜ค๋ Œ์ง€์— awr ๋ ˆํฌํŠธ๋ฅผ ์ƒ์„ฑํ•ด์„œ ์•…์„ฑ sql์˜ full text๋ฅผ ์ฐพ์•„๋‚ด์‹œ์˜ค

1. snapshot ์ฐ๊ธฐ

exec dbms_workload_repository.create_snapshot;

select snap_id, begin_interval_time, end_interval_time
 from dba_hist_snapshot
 order by snap_id asc;


2. hr ๊ณ„์ •์œผ๋กœ ์ ‘์†ํ•ด์„œ employees ํ…Œ์ด๋ธ”์— ๋Œ€ํ•œ ์•…์„ฑ SQL ์ˆ˜ํ–‰

SYS @ ora19dw > connect hr/hr
์—ฐ๊ฒฐ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

HR @ ora19dw > select count(*)
  2  from employees, employees, employees, employees, employees, employees, employees, employees, employees;


3. ์˜ค๋ Œ์ง€์— awr ๋ ˆํฌํŠธ ์ƒ์„ฑ ํ›„, ์•…์„ฑ sql์˜ full text ์ฐพ๊ธฐ


๐Ÿ”ธ [๋ฌธ์ œ] dw์ชฝ์— ts50 ์ด๋ผ๋Š” ์ด๋ฆ„์œผ๋กœ ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์ด ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค๋ฅผ default permanent ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค๋กœ ์ง€์ •ํ•˜์‹œ์˜ค. ๊ทธ๋ฆฌ๊ณ  temp200 ์ด๋ผ๋Š” temporary ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค๋ฅผ ์ƒ์„ฑํ•˜๊ณ  ์ด ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค๋ฅผ default temporary ํ…Œ์ด๋ธ” ์ŠคํŽ˜์ด์Šค๋กœ ์ง€์ •ํ•˜์‹œ์˜ค

1. ts50 ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค ์ƒ์„ฑ ํ›„, default permanent ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๋กœ ์ง€์ •

SYS @ ora19dw > create tablespace ts50
  2  datafile '/u01/app/oracle/oradata/ORA19DW/ts50.dbf' size 10m;

ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๊ฐ€ ์ƒ์„ฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

SYS @ ora19dw > alter database default tablespace ts50;

๋ฐ์ดํƒ€๋ฒ ์ด์Šค๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

SYS @ ora19dw >

2. temp200์ด๋ผ๋Š” temporary ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค ์ƒ์„ฑ ํ›„, default temporary ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๋กœ ์ง€์ •

SYS @ ora19dw > create temporary tablespace temp200
  2  tempfile '/u01/app/oracle/oradata/ORA19DW/temp200.dbf' size 10m;

ํ…Œ์ด๋ธ”์ŠคํŽ˜์ด์Šค๊ฐ€ ์ƒ์„ฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

SYS @ ora19dw > alter database default temporary tablespace temp200;

๋ฐ์ดํƒ€๋ฒ ์ด์Šค๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.


3. ๊ฐ๊ฐ ์ž˜ ์ง€์ •๋˜์—ˆ๋Š”์ง€ ํ™•์ธ

SYS @ ora19dw > select *
  2  from database_properties
  3  where property_name in ('DEFAULT_PERMANENT_TABLESPACE', 'DEFAULT_TEMP_TABLESPACE');

PROPERTY_NAME
--------------------------------------------------------------------------------
PROPERTY_VALUE
--------------------------------------------------------------------------------
DESCRIPTION
--------------------------------------------------------------------------------
DEFAULT_PERMANENT_TABLESPACE
TS50
Name of default permanent tablespace

DEFAULT_TEMP_TABLESPACE
TEMP200
Name of default temporary tablespace

PROPERTY_NAME
--------------------------------------------------------------------------------
PROPERTY_VALUE
--------------------------------------------------------------------------------
DESCRIPTION
--------------------------------------------------------------------------------


๋ฌธ์ œ4. ์•„์นด์ด๋ธŒ ๋กœ๊ทธ ํŒŒ์ผ์ด ์ƒ์„ฑ๋˜๋Š” ์œ„์น˜์ธ fast recovery area ์˜์—ญ์˜ ์‚ฌ์ด์ฆˆ๋ฅผ ๋” ๋Š˜๋ฆฌ์‹œ์˜ค

SYS @ ora19dw > alter system set db_recovery_file_dest_size=20g;

์‹œ์Šคํ…œ์ด ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

[oracle@ora19c ~]$ export ORACLE_SID=ora19dw
[oracle@ora19c ~]$
[oracle@ora19c ~]$ rman target /

๋ณต๊ตฌ ๊ด€๋ฆฌ์ž: Release 19.0.0.0.0 - Production on ์›” 9์›” 8 09:50:35 2025
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

๋Œ€์ƒ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์— ์ ‘์†๋จ: ORA19DW(DBID=1004651910)

RMAN> delete archivelog all;

[oracle@ora19c ~]$ cd /u01/app/oracle/oradata
[oracle@ora19c oradata]$ ls
ORA19  ORA19DW
[oracle@ora19c oradata]$
[oracle@ora19c oradata]$ rm -rf ORA19
[oracle@ora19c oradata]$ df -h
Filesystem           Size  Used Avail Use% Mounted on
devtmpfs             3.8G     0  3.8G   0% /dev
tmpfs                3.8G     0  3.8G   0% /dev/shm
tmpfs                3.8G  9.3M  3.8G   1% /run
tmpfs                3.8G     0  3.8G   0% /sys/fs/cgroup
/dev/mapper/ol-root   44G   32G   13G  71% /
/dev/sda1           1014M  234M  781M  23% /boot
tmpfs                768M     0  768M   0% /run/user/1000
tmpfs                768M   12K  768M   1% /run/user/42
[oracle@ora19c oradata]$ sysdw

SQL*Plus: Release 19.0.0.0.0 - Production on ์›” 9์›” 8 09:53:09 2025
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


๋‹ค์Œ์— ์ ‘์†๋จ:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SYS @ ora19dw >

0๊ฐœ์˜ ๋Œ“๊ธ€