문서유형ㅣ기술정보
분야ㅣ관리/환경설정
적용제품버전ㅣTibero 7.2.3
문서번호ㅣTADTI115
개요
본 문서에서는 데이터 파일 이름 혹은 경로를 변경하는 방법에 대하여 3가지 방법을 가이드 합니다.
- 테스트 환경: Tibero 7.2.3
방법
Case 1. 테이블 스페이스 Offline 상태에서 데이터파일 이름/경로 변경
- DB 재기동 없이 데이터 파일의 이름 혹은 경로를 변경하는 방법
- 변경하려는 대상 데이터파일이 속한 테이블스페이스의 가용성을 offline으로 변경한 상태에서
rename datafile 명령을 실행하여 데이터파일의 이름 혹은 경로를 변경합니다.
이 때, 테이블스페이스는 non-SYSTEM이어야 offline 상태로 변경할 수 있다. - 데이터 파일의 정보가 변경되었으므로 작업이 끝난 후, 컨트롤파일 백업이 필요합니다.
참고
Tibero 7 이전 버전에 적용되는, 테이블 스페이스 오프라인 상태에서의 데이터파일 이름, 경로 방법은
아래 링크를 통해 확인하실 수 있습니다.
수행절차
1. datafile, tablespace 확인
SQL> set linesize 200 SQL> col file_name for a40 SQL> col tablespace_name for a20 SQL> select file_name, tablespace_name from dba_datafiles where file_name like '%ts%.dtf'; FILE_NAME TABLESPACE_NAME ---------------------------------------- -------------------- /tibero/tibero7/database/tac/ts1.dtf TS1 /tibero/tibero7/database/tac/ts2.dtf TS1 /tibero/tibero7/database/tac/ts3.dtf TS1 3 rows selected.
2. 대상 tablespace를 offline 상태로 변경
SQL> alter tablespace TS1 offline; Tablespace 'TS1' altered. SQL> select tablespace_name, status from dba_tablespaces where tablespace_name = 'TS1'; TABLESPACE_NAME STATUS -------------------- --------- TS1 OFFLINE
3. 대상 datafile 경로 변경
[tibero@devdb tac]$ ls ts1.dtf ts1.dtf [tibero@devdb tac]$ cp ts1.dtf /tibero/tac/datafile/ts1.dtf [tibero@devdb tac]$ cd /tibero/tac/datafile [tibero@devdb datafile]$ ls ts1.dtf ts1.dtf
4. rename datafile 명령
SQL> alter tablespace TS1 rename datafile '/tibero/tibero7/database/tac/ts1.dtf'
TO '/tibero/tac/datafile/ts1.dtf';
Tablespace 'TS1' altered.
5. 대상 tablespace를 online 상태로 전환
SQL> alter tablespace ts1 online; Tablespace 'TS1' altered.
6. 작업 확인 및 controlfile 백업
SQL> select file_name, tablespace_name from dba_datafiles where tablespace_name='TS1'; FILE_NAME TABLESPACE_NAME ---------------------------------------- -------------------- /tibero/tac/datafile/ts1.dtf TS1 /tibero/tibero7/database/tac/ts2.dtf TS1 /tibero/tibero7/database/tac/ts3.dtf TS1 3 rows selected. SQL> alter database backup controlfile to trace as '/tibero/tac/control_back.sql'; Database altered. [tibero@devdb tac]$ ls control_back.sql control_back.sql
Case 2. 컨트롤파일 재생성을 통한 데이터파일 이름/경로 변경
- 백업되어 있는 컨트롤파일 생성 구문을 이용 및 수정하여 데이터파일의 이름 및 경로를 변경하는 방법입니다. OS상에서 데이터파일의 이름 혹은 경로가 변경되었을 경우, 컨트롤파일 백업본을 사용하여 데이터베이스를 복구할 수 있는 방법입니다.
- DB 재기동 및 미디어복구(ALTER DATABASE RECOVER -)가 필요합니다.
(DB는 ARCHIVELOG MODE로 수행)
참고
Tibero 7 이전 버전에 적용되는, 컨트롤파일 재생성을 통한 데이터파일 이름, 경로 방법은
아래 링크를 통해 확인하실 수 있습니다.
수행절차
1. datafile 확인
SQL> set linesize 200 SQL> col file_name for a50 SQL> col tablespace_name for a20 SQL> select file_name, tablespace_name from dba_datafiles where file_name like '%ts_%'; FILE_NAME TABLESPACE_NAME -------------------------------------------------- -------------------- /tibero/tac/datafile/ts1.dtf TS1 /tibero/tibero7/database/tac/ts2.dtf TS1 /tibero/tibero7/database/tac/ts3.dtf TS1 3 rows selected.
2. controlfile 백업
SQL> alter database backup controlfile to trace as '/tibero/ctl_bak.sql' reuse noresetlogs; Database altered. [tibero@devdb ~]$ pwd /tibero [tibero@devdb ~]$ ls ctl_bak.sql ctl_bak.sql
3. DB down
[tibero@devdb ~]$ tbdown immediate Tibero instance terminated (IMMEDIATE mode). [tibero@devdb ~]$ ps -ef|grep tbsvr tibero 3810401 3789549 0 14:14 pts/1 00:00:00 grep --color=auto tbsvr
4. 대상 datafile 경로 변경
[tibero@devdb tac]$ pwd /tibero/tibero7/database/tac [tibero@devdb tac]$ ls ts2.dtf ts2.dtf [tibero@devdb tac]$ cp ts2.dtf /tibero/tac/datafile/ts2.dtf [tibero@devdb tac]$ ls /tibero/tac/datafile/ts2.dtf /tibero/tac/datafile/ts2.dtf
5. 백업한 controlfile 생성 구문 변경
[tibero@devdb ~]$ vi ctl_bak.sql
CREATE CONTROLFILE REUSE DATABASE "tac"
LOGFILE
-- Thread #0
GROUP 0 (
'/tibero/tibero7/database/tac1/redo001.log',
'/tibero/tibero7/database/tac1/redo002.log'
) SIZE 100M,
GROUP 1 (
'/tibero/tibero7/database/tac1/redo011.log',
'/tibero/tibero7/database/tac1/redo012.log'
) SIZE 100M
NORESETLOGS
DATAFILE
'/tibero/tibero7/database/tac1/system001.dtf',
'/tibero/tibero7/database/tac1/undo001.dtf',
'/tibero/tibero7/database/tac1/usr001.dtf',
'/tibero/tibero7/database/tac1/syssub001.dtf',
'/tibero/tac/datafile/ts1.dtf',
-- '/tibero/tibero7/database/tac/ts2.dtf', ### 기존의 경로
'/tibero/tac/datafile/ts2.dtf', ### 신규 경로
'/tibero/tibero7/database/tac/ts3.dtf'
ARCHIVELOG
MAXLOGFILES 100
MAXFBLOGFILES 255
MAXLOGMEMBERS 8
MAXDATAFILES 4026
MAXARCHIVELOG 500
MAXBACKUPSET 500
MAXLOGHISTORY 500
MAXFBMARKER 168
MAXFBARCHIVELOG 500
CHARACTER SET UTF8
NATIONAL CHARACTER SET UTF16
;
---- Adding Tempfiles is required in OPEN(NORMAL) mode.
-- ALTER TABLESPACE TEMP ADD TEMPFILE '/tibero/tibero7/database/tac1/temp001.dtf'
-- SIZE 100M REUSE AUTOEXTEND ON NEXT 256K MAXSIZE 32G;
### DB 복구 작업 이후 TEMP 파일 추가 필요.
6. DB NOMOUNT 기동 및 CONTROLFILE 재생성
[tibero@devdb ~]$ tbboot nomount Change core dump dir to /tibero/tibero7/bin/prof. Listener port = 8629 Tibero 7 TmaxTibero Corporation Copyright (c) 2020-. All rights reserved. Tibero instance started up (NOMOUNT mode). [tibero@devdb ~]$ tbsql sys/tibero tbSQL 7 TmaxTibero Corporation Copyright (c) 2020-. All rights reserved. Connected to Tibero. SQL> @ctl_bak.sql Control File created.
7. DB MOUNT 기동 및 DB 복구
[tibero@devdb ~]$ tbdown immediate Tibero instance terminated (IMMEDIATE mode). [tibero@devdb ~]$ tbboot mount Change core dump dir to /tibero/tibero7/bin/prof. Listener port = 8629 Tibero 7 TmaxTibero Corporation Copyright (c) 2020-. All rights reserved. Tibero instance started up (MOUNT mode). [tibero@devdb ~]$ tbsql sys/tibero tbSQL 7 TmaxTibero Corporation Copyright (c) 2020-. All rights reserved. Connected to Tibero. SQL> alter database recover automatic; Database altered.
8. DB 정상기동 및 TEMP 파일 재생성
[tibero@devdb ~]$ tbdown immediate Tibero instance terminated (IMMEDIATE mode). [tibero@devdb ~]$ tbboot Change core dump dir to /tibero/tibero7/bin/prof. Listener port = 8629 Tibero 7 TmaxTibero Corporation Copyright (c) 2020-. All rights reserved. Tibero instance started up (NORMAL mode). [tibero@devdb ~]$ tbsql sys/tibero tbSQL 7 TmaxTibero Corporation Copyright (c) 2020-. All rights reserved. Connected to Tibero. SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '/tibero/tibero7/database/tac1/temp001.dtf' SIZE 100M REUSE AUTOEXTEND ON NEXT 256K MAXSIZE 32G; Tablespace 'TEMP' altered.
9. 작업 확인 및 controlfile 백업
SQL> select name from v$datafile; NAME ---------------------------------------------------------- /tibero/tibero7/database/tac1/system001.dtf /tibero/tibero7/database/tac1/undo001.dtf /tibero/tibero7/database/tac1/usr001.dtf /tibero/tibero7/database/tac1/syssub001.dtf /tibero/tac/datafile/ts1.dtf /tibero/tibero7/database/tac/ts2.dtf ## 작업한 파일 /tibero/tibero7/database/tac/ts3.dtf SQL> alter database backup controlfile to trace as 'ctl_after_backup.sql' reuse noresetlogs; Database altered.
Case 3. MOUNT모드에서 데이터파일 이름/경로 변경
- MOUNT 모드에서 rename datafile 명령을 실행하여 데이터파일의 이름 및 경로를 변경하는 방법입니다.
- DB 재기동이 필요하고, DB 복구 과정 없이 한 개 이상의 테이블스페이스의 데이터파일 혹은 SYSTEM
테이블스페이스의 데이터파일의 이름 및 경로를 변경할 수 있는 방법입니다. - 데이터 파일의 정보가 변경되었으므로 작업이 끝난 후, 컨트롤파일 백업이 필요합니다.
참고
Tibero 7 이전 버전에 적용되는, DB 마운트 모드에서의 데이터파일 이름, 경로 방법은
아래 링크를 통해 확인하실 수 있습니다.
수행절차
1. datafile 확인
SQL> set linesize 200 SQL> col file_name for a50 SQL> col tablespace_name for a20 SQL> select file_name, tablespace_name from dba_datafiles where file_name like '%ts%.dtf'; FILE_NAME TABLESPACE_NAME -------------------------------------------------- -------------------- /tibero/tac/datafile/ts1.dtf TS1 /tibero/tac/datafile/ts2.dtf TS1 /tibero/tibero7/database/tac/ts3.dtf TS1
2. DB MOUNT 기동
[tibero@devdb ~]$ tbdown immediate Tibero instance terminated (IMMEDIATE mode). [tibero@devdb ~]$ tbboot mount Change core dump dir to /tibero/tibero7/bin/prof. Listener port = 8629 Tibero 7 TmaxTibero Corporation Copyright (c) 2020-. All rights reserved. Tibero instance started up (MOUNT mode).
3. 대상 datafile 경로 변경
[tibero@devdb tac]$ pwd /tibero/tibero7/database/tac [tibero@devdb tac]$ cp ts3.dtf /tibero/tac/datafile/ts3.dtf [tibero@devdb tac]$ ls /tibero/tac/datafile/ts3.dtf /tibero/tac/datafile/ts3.dtf
4. rename datafile 명령
[tibero@devdb tac]$ tbsql sys/tibero
tbSQL 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Connected to Tibero.
SQL> alter tablespace ts1 rename datafile '/tibero/tibero7/database/tac/ts3.dtf' TO
'/tibero/tac/datafile/ts3.dtf';
Tablespace 'TS1' altered.
5. DB 정상기동
[tibero@devdb ~]$ tbdown immediate Tibero instance terminated (IMMEDIATE mode). [tibero@devdb ~]$ tbboot Change core dump dir to /tibero/tibero7/bin/prof. Listener port = 8629 Tibero 7 TmaxTibero Corporation Copyright (c) 2020-. All rights reserved. Tibero instance started up (NORMAL mode).
6. 작업 확인 및 controlfile 백업
SQL> set linesize 200 SQL> col file_name for a50 SQL> col tablespace_name for a20 SQL> select file_name, tablespace_name from dba_datafiles where file_name like '%ts_%'; FILE_NAME TABLESPACE_NAME -------------------------------------------------- -------------------- /tibero/tac/datafile/ts1.dtf TS1 /tibero/tac/datafile/ts2.dtf TS1 /tibero/tac/datafile/ts3.dtf TS1 3 rows selected. SQL> alter database backup controlfile to trace as '/tibero/ctl_bak_3after.sql' reuse noresetlogs; Database altered.