상세 컨텐츠

본문 제목

Oracle temp tablespace 증설하기!!

IT 알아보기

by 3학년 1반 민군 2021. 2. 8. 15:39

본문

오늘은 Temp Tablespace에 관해 알아보겠습니다.

 

Temp Tablespace란?

 

임시 테이블스페이스로 인덱스의 생성, 정렬작업(Order by 등), 백업작업(expdp, datapump 등) 등의 작업시 할용되는 공간입니다.

 

말 그대로 임시로 활용되는 공간이므로 중요한 데이터가 들어있지 않아 생성이 빠릅니다.

(다른 테이블스페이스와는 달리 control file에 기록되지않으며, 다른 테이블스페이스의 경우 블록검사를 진행하기때문에 할당이 느림)

 

이 공간은 여러 사용자가 사용자별로 할당해서 사용하며

 

system 사용자가 사용하는 공간을 default tempory tablespace 라고 합니다.

 

이때 default tempory tablespace는 오프라인 상태로 전환되는 것이 불가능합니다.

 

오늘은 이 Temp Tablespace의 사이즈 증설에 대해 알아보겠습니다.


테스트 환경에서 Temp Tablespace를 증설해보았습니다.

 

Temp Tablespace의 사이즈를 증설하기위해 임시 테이블스페이스 추가 후 기존 temp파일 삭제, 재생성 과정입니다.

 

현재 Temp Tablespace 조회

SQL> select tablespace_name, bytes/1024/1024 MB, file_name from dba_temp_files;

TABLESPACE_NAME 		       MB FILE_NAME
------------------------------ ---------- ------------------------------------------------------------
TEMP				     2000 /*****/oracle/app/oracle/oradata/ORCL11/temp01.dbf

[oracle@ORACLE11 ~]$ cd /*****/oracle/app/oracle/oradata/ORCL11
[oracle@ORACLE11 ORCL11]$ ll
total 5499396
-rw-r----- 1 oracle dba    8077312 Feb  6 01:49 control01.ctl
-rw-r----- 1 oracle dba    8077312 Feb  6 01:49 control02.ctl
-rw-r----- 1 oracle dba  314573312 Feb  4 01:34 redo04_2.LOG
-rw-r----- 1 oracle dba  314573312 Feb  6 01:46 redo04.log
-rw-r----- 1 oracle dba  314573312 Feb  4 01:34 redo05_2.LOG
-rw-r----- 1 oracle dba  314573312 Feb  4 01:21 redo05.log
-rw-r----- 1 oracle dba  314573312 Feb  4 01:34 redo06_2.LOG
-rw-r----- 1 oracle dba  314573312 Feb  4 01:21 redo06.log
-rw-r----- 1 oracle dba  524296192 Feb  6 01:40 sysaux01.dbf
-rw-r----- 1 oracle dba  734011392 Feb  6 01:30 system01.dbf
-rw-r----- 1 oracle dba 2097160192 Feb  5 22:00 temp01.dbf
-rw-r----- 1 oracle dba  314580992 Feb  6 01:40 undotbs01.dbf
-rw-r----- 1 oracle dba 2147491840 Feb  4 01:23 users01.dbf

현재 2000MB 사이즈임을 확인

임시 테이블스페이스 생성 및 Default tempory tablespace 변경

SQL> create temporary tablespace temp1 tempfile '/*****/oracle/app/oracle/oradata/ORCL11/temp02.dbf' size 1g;

Tablespace created.

SQL> alter database default temporary tablespace temp1;

Database altered.

SQL> select tablespace_name, bytes/1024/1024 MB, file_name from dba_temp_files;

TABLESPACE_NAME 		       MB FILE_NAME
------------------------------ ---------- ------------------------------------------------------------
TEMP				     2000 /*****/oracle/app/oracle/oradata/ORCL11/temp01.dbf
TEMP1				     1024 /*****/oracle/app/oracle/oradata/ORCL11/temp02.dbf

기존 temp tablespace 삭제

SQL> drop tablespace temp;

Tablespace dropped.

SQL> select tablespace_name, bytes/1024/1024 MB, file_name from dba_temp_files;

TABLESPACE_NAME 		       MB FILE_NAME
------------------------------ ---------- ------------------------------------------------------------
TEMP1				     1024 /*****/oracle/app/oracle/oradata/ORCL11/temp02.dbf

물리적 삭제

[oracle@ORACLE11 ORCL11]$ rm -rf temp01.dbf

[oracle@ORACLE11 ORCL11]$ ll
total 5493244
-rw-r----- 1 oracle dba    8077312 Feb  6 02:08 control01.ctl
-rw-r----- 1 oracle dba    8077312 Feb  6 02:08 control02.ctl
-rw-r----- 1 oracle dba  314573312 Feb  4 01:34 redo04_2.LOG
-rw-r----- 1 oracle dba  314573312 Feb  6 02:08 redo04.log
-rw-r----- 1 oracle dba  314573312 Feb  4 01:34 redo05_2.LOG
-rw-r----- 1 oracle dba  314573312 Feb  4 01:21 redo05.log
-rw-r----- 1 oracle dba  314573312 Feb  4 01:34 redo06_2.LOG
-rw-r----- 1 oracle dba  314573312 Feb  4 01:21 redo06.log
-rw-r----- 1 oracle dba  524296192 Feb  6 02:06 sysaux01.dbf
-rw-r----- 1 oracle dba  734011392 Feb  6 02:05 system01.dbf
-rw-r----- 1 oracle dba 1073750016 Feb  6 02:05 temp02.dbf
-rw-r----- 1 oracle dba  314580992 Feb  6 02:06 undotbs01.dbf
-rw-r----- 1 oracle dba 2147491840 Feb  4 01:23 users01.dbf

새로운 temp tablespace 생성 및 default temporary tablespace 지정

SQL> create temporary tablespace temp tempfile '/*****/oracle/app/oracle/oradata/ORCL11/temp01.dbf' size 2g autoextend on maxsize 5g;

Tablespace created.

SQL> alter database default temporary tablespace temp;

Database altered.

SQL> select tablespace_name, bytes/1024/1024 MB, file_name from dba_temp_files;

TABLESPACE_NAME 		       MB FILE_NAME
------------------------------ ---------- ------------------------------------------------------------
TEMP				     2048 /*****/oracle/app/oracle/oradata/ORCL11/temp01.dbf
TEMP1				     1024 /*****/oracle/app/oracle/oradata/ORCL11/temp02.dbf

임시테이블스페이스 삭제

SQL> drop tablespace temp1;

Tablespace dropped.

확인

SQL> select tablespace_name, bytes/1024/1024 MB, file_name from dba_temp_files;

TABLESPACE_NAME 		       MB FILE_NAME
------------------------------ ---------- ------------------------------------------------------------
TEMP				     2048 /*****/oracle/app/oracle/oradata/ORCL11/temp01.dbf

[oracle@ORACLE11 ORCL11]$ ll
total 5494268
-rw-r----- 1 oracle dba    8077312 Feb  6 02:12 control01.ctl
-rw-r----- 1 oracle dba    8077312 Feb  6 02:12 control02.ctl
-rw-r----- 1 oracle dba  314573312 Feb  4 01:34 redo04_2.LOG
-rw-r----- 1 oracle dba  314573312 Feb  6 02:12 redo04.log
-rw-r----- 1 oracle dba  314573312 Feb  4 01:34 redo05_2.LOG
-rw-r----- 1 oracle dba  314573312 Feb  4 01:21 redo05.log
-rw-r----- 1 oracle dba  314573312 Feb  4 01:34 redo06_2.LOG
-rw-r----- 1 oracle dba  314573312 Feb  4 01:21 redo06.log
-rw-r----- 1 oracle dba  524296192 Feb  6 02:11 sysaux01.dbf
-rw-r----- 1 oracle dba  734011392 Feb  6 02:11 system01.dbf
-rw-r----- 1 oracle dba 2147491840 Feb  6 02:10 temp01.dbf
-rw-r----- 1 oracle dba 1073750016 Feb  6 02:05 temp02.dbf
-rw-r----- 1 oracle dba  314580992 Feb  6 02:12 undotbs01.dbf
-rw-r----- 1 oracle dba 2147491840 Feb  4 01:23 users01.dbf

[oracle@ORACLE11 ORCL11]$ rm -rf temp02.dbf

[oracle@ORACLE11 ORCL11]$ ll
total 5493244
-rw-r----- 1 oracle dba    8077312 Feb  6 02:12 control01.ctl
-rw-r----- 1 oracle dba    8077312 Feb  6 02:12 control02.ctl
-rw-r----- 1 oracle dba  314573312 Feb  4 01:34 redo04_2.LOG
-rw-r----- 1 oracle dba  314573312 Feb  6 02:12 redo04.log
-rw-r----- 1 oracle dba  314573312 Feb  4 01:34 redo05_2.LOG
-rw-r----- 1 oracle dba  314573312 Feb  4 01:21 redo05.log
-rw-r----- 1 oracle dba  314573312 Feb  4 01:34 redo06_2.LOG
-rw-r----- 1 oracle dba  314573312 Feb  4 01:21 redo06.log
-rw-r----- 1 oracle dba  524296192 Feb  6 02:11 sysaux01.dbf
-rw-r----- 1 oracle dba  734011392 Feb  6 02:11 system01.dbf
-rw-r----- 1 oracle dba 2147491840 Feb  6 02:10 temp01.dbf
-rw-r----- 1 oracle dba  314580992 Feb  6 02:12 undotbs01.dbf
-rw-r----- 1 oracle dba 2147491840 Feb  4 01:23 users01.dbf

결론 : 기존 2000MB 였던 TEMP TABLESPACE의 공간이 2048MB로 수정되었다.

관련글 더보기

댓글 영역