문서유형ㅣ기술정보
분야ㅣ관리/환경설정
적용제품버전ㅣTibero7.2.4
문서번호ㅣTBATI047
개요
본 문서는 DD Copy 설명 및 유의사항을 기술합니다. 단, 해당 시나리오는 운영중인 Tibero 환경 (TAC Raw-Device)에서 DB 백업과 DD Copy를 이용하여 타 서버에 복구를 통해 재구축 방안을 목적으로 합니다.
테스트 환경
- OS 버전 : Rocky Linux 8.10 (Green Obsidian)
- Tibero 버전 : Tibero7 (DB7.2.4) Build 303667
- AS-IS Tibero 구성 : 2Node TAC (Raw-Device)
- TO-BE Tibero 구성 : 2Node TAC (Raw-Device)
방법
DD Copy?
저장 장치(디스크, 파티션, 파일 등)의 데이터를 블록 단위로 정확히 복제(이미징)하는 작업으로, 파일 시스템 구조, 파티션 정보, 메타데이터까지 포함하여 원본과 완전히 동일하게 복사하는 기능입니다.
옵션 설명 및 사용 예시
Tibero에서 자주 사용되는 옵션에 대해서만 설명합니다. ( ※ 더 많은 옵션은 dd --help를 통해 확인한다. )
| 옵션 명 | 단위 | 설명 |
|---|---|---|
| if (Input File) | 파일, 디스크 | 원본 파일 또는 디스크 |
| of (Out File) | 파일, 디스크 | 타겟 파일 또는 디스크 |
| bs (Block Size) | Bytes | 한번에 얼마나 많은 byte를 읽으지를 지정하며 일반적으로 count 옵션과 함께 사용 (기본값은 512) |
| count | N | N개의 입력된 블록만 복사 |
| iflag (Input Flag) | 옵션 지정 | OS 캐시를 사용하지 않고, 디스크를 직접 읽음(Direct I/O) |
| oflag (Out Flag) | 옵션 지정 | OS 캐시를 사용하지 않고, 디스크에 직접 쓰기 수행(Direct I/O) |
DD Copy 사용 예시
1. Source의 내용을 Target에 복사한다.
ㄴdd if=Source of=Target
2. source의 내용을 target에 1024*10 bytes 만큼 복사한다.
ㄴdd if=source of=target bs=1024 count=10
ㄴdd if=source of=target bs=512 count=20
제약 사항
일부 시스템의 경우, 원본 디스크가 장착된 시스템 기종과 타켓 디스크 시스템의 기종이 같아야 합니다.
원본 디스크의 Filesystem에 문제가 있는 경우, 문제가 있는 부분도 같이 복사 됩니다.
( ※ 해당 명령어를 잘못 사용하는 경우, 디스크 전체를 덮어쓸 수 있기 때문에 사용 시 주의 필요 합니다. )
Tibero에서 DD Copy 수행
DD Copy를 통한 Raw-Device 복제 및 불완전 복구 예시
본 절에서는 DD Copy가 Tibero Raw-Device 환경에서 어떻게 활용되는지를 설명하기 위해, AS-IS 2-Node TAC(Raw-Device) 구성에서 DB 백업 및 DD Copy를 이용하여 TO-BE 환경에서 불완전 복구 방식으로 DB를 재구축하는 시나리오를 예로 들어 설명합니다.
TO-BE 환경 사전 준비
- AS-IS 환경과 동일한 환경 구성
ex) Hostname, IP, Port, Raw-Device 구성, 디스크 권한, OS Profile 설정 등
- AS-IS 환경과 동일한 Tibero 엔진 설치 및 설정 (복구 예정으로 db 생성은 하지 않는다.)
ex) $TB_HOME 경로, $TB_SID.tip, Resource 등
예상 시나리오
- 온라인 백업 수행 (Begin Backup ~ End Backup)
- 테스트 테이블 생성 및 양 노드에서 DML 수행 (운영 부하 재현 목적)
- 데이터 영역 DD Copy 수행 (Raw-Device->Filesystem)
- 컨트롤 파일 백업 (resetlogs)
- 아카이브, 백업본 TO-BE 서버로 전송
- 백업본 (Filesystem) DD Copy를 통해 Raw-Device로 restore
- nomount 기동 후, 컨트롤 파일 재생성
- mount 기동 후, Recover 수행
- resetlogs 기동 및 정상 기동
※ 온라인 백업 중, DD Copy 시 주의 사항 (Raw-Device 구성인 경우)
온라인 백업 중 DD Copy 수행할 때, iflag=direct, oflag=direct 옵션을 사용하지 않는 경우 I/O가 OS Cache를 거치게 됩니다. 이 경우 운영기와 백업본의 TSN 값이 달라질 수 있어 복구에 실패할 수 있으므로, 두 옵션을 반드시 지정하여 DD Copy를 진행할 것을 권고합니다.
== AS-IS 수행 ==
[t7_1]tibero7@tibero_raw:/home/tibero7> tbsql sys
tbSQL 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Enter Password:
Connected to Tibero.
-- 테스트 테이블 test 생성
SQL> create table tibero.test ( a date, b varchar2(10)) tablespace usr;
Table 'TIBERO.TEST' created.
SQL> insert into tibero.test (a, b) values (systimestamp, 'aa');
1 row inserted.
SQL> commit;
Commit completed.
-- begin backup 수행
SQL> alter database begin backup;
Database altered.
-- node1,2 운영 부하 재현 목적
SQL> DECLARE
BEGIN
FOR i IN 1..50000 LOOP
INSERT INTO TIBERO.TEST (a,b) VALUES (SYSTIMESTAMP, 'AA');
IF MOD(i,10000) = 0 THEN
COMMIT;
END IF;
END LOOP;
COMMIT;
END;
/
PSM completed.
-- end backup 수행
SQL> alter database end backup;
Database altered.
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> alter system checkpoint;
System altered.
-- 데이터 영역 Raw-Device DD Copy
[t7_1]tibero7@tibero_raw:/home/tibero7> dd if=/dev/raw/raw17 bs=128M iflag=direct oflag=direct of=/home/tibero7/system001.dtf bs=128M status=progress
402653184 bytes (403 MB, 384 MiB) copied, 1 s, 394 MB/s
3+1 records in
3+1 records out
524288000 bytes (524 MB, 500 MiB) copied, 1.57237 s, 333 MB/s
[t7_1]tibero7@tibero_raw:/home/tibero7> dd if=/dev/raw/raw18 bs=128M iflag=direct oflag=direct of=/home/tibero7/usr001.dtf bs=128M status=progress
3+1 records in
3+1 records out
524288000 bytes (524 MB, 500 MiB) copied, 1.17725 s, 445 MB/s
[t7_1]tibero7@tibero_raw:/home/tibero7> dd if=/dev/raw/raw19 bs=128M iflag=direct oflag=direct of=/home/tibero7/undo001.dtf bs=128M status=progress
524288000 bytes (524 MB, 500 MiB) copied, 1 s, 493 MB/s
3+1 records in
3+1 records out
524288000 bytes (524 MB, 500 MiB) copied, 1.32987 s, 394 MB/s
[t7_1]tibero7@tibero_raw:/home/tibero7> dd if=/dev/raw/raw20 bs=128M iflag=direct oflag=direct of=/home/tibero7/undo002.dtf bs=128M status=progress
3+1 records in
3+1 records out
524288000 bytes (524 MB, 500 MiB) copied, 1.15563 s, 454 MB/s
[t7_1]tibero7@tibero_raw:/home/tibero7> dd if=/dev/raw/raw22 bs=128M iflag=direct oflag=direct of=/home/tibero7/data001.dtf bs=128M status=progress
3+1 records in
3+1 records out
524288000 bytes (524 MB, 500 MiB) copied, 1.18858 s, 441 MB/s
[t7_1]tibero7@tibero_raw:/home/tibero7> dd if=/dev/raw/raw23 bs=128M iflag=direct oflag=direct of=/home/tibero7/data002.dtf bs=128M status=progress
3+1 records in
3+1 records out
524288000 bytes (524 MB, 500 MiB) copied, 1.19607 s, 438 MB/s
[t7_1]tibero7@tibero_raw:/home/tibero7> dd if=/dev/raw/raw24 bs=128M iflag=direct oflag=direct of=/home/tibero7/syssub001.dtf bs=128M status=progress
3+1 records in
3+1 records out
524288000 bytes (524 MB, 500 MiB) copied, 1.19354 s, 439 MB/s
[t7_1]tibero7@tibero_raw:/home/tibero7> ls -rlt
..
-rw-rw-r--. 1 tibero7 tibero7 524288000 11월 25 03:27 system001.dtf
-rw-rw-r--. 1 tibero7 tibero7 524288000 11월 25 03:27 usr001.dtf
-rw-rw-r--. 1 tibero7 tibero7 524288000 11월 25 03:27 undo001.dtf
-rw-rw-r--. 1 tibero7 tibero7 524288000 11월 25 03:27 undo002.dtf
-rw-rw-r--. 1 tibero7 tibero7 524288000 11월 25 03:27 data001.dtf
-rw-rw-r--. 1 tibero7 tibero7 524288000 11월 25 03:27 data002.dtf
-rw-rw-r--. 1 tibero7 tibero7 524288000 11월 25 03:28 syssub001.dtf
-- 백업본 및 아카이브 전부 TO-BE 서버로 scp
[t7_1]tibero7@tibero_raw:/home/tibero7> scp ./*.dtf root@192.168.29.101:/home/tibero7
The authenticity of host '192.168.29.101 (192.168.29.101)' can't be established.
ECDSA key fingerprint is SHA256:X1dZuXKK781n1qhXT7zPo/tAnYUL4AxmGN9ywX3sy/w.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.29.101' (ECDSA) to the list of known hosts.
root@192.168.29.101's password:
data001.dtf 100% 500MB 110.4MB/s 00:04
data002.dtf 100% 500MB 110.9MB/s 00:04
syssub001.dtf 100% 500MB 109.1MB/s 00:04
system001.dtf 100% 500MB 103.5MB/s 00:04
undo001.dtf 100% 500MB 102.5MB/s 00:04
undo002.dtf 100% 500MB 72.2MB/s 00:06
usr001.dtf 100% 500MB 76.1MB/s 00:06
[t7_1]tibero7@tibero_raw:/home/tibero7/tibero_arch/t7/t7_1/arch> scp ./*.arc root@192.168.29.101:/home/tibero7/tibero_arch/t7/t7_1/arch
root@192.168.29.101's password:
log-t0-r0-s1.arc 100% 512 99.9KB/s 00:00
log-t0-r0-s10.arc 100% 512 1.3MB/s 00:00
log-t0-r0-s11.arc 100% 512 1.6MB/s 00:00
log-t0-r0-s12.arc 100% 512 1.4MB/s 00:00
log-t0-r0-s2.arc 100% 1510KB 89.9MB/s 00:00
log-t0-r0-s3.arc 100% 80MB 110.6MB/s 00:00
log-t0-r0-s4.arc 100% 2886KB 118.6MB/s 00:00
log-t0-r0-s5.arc 100% 319KB 51.5MB/s 00:00
log-t0-r0-s6.arc 100% 100MB 115.1MB/s 00:00
log-t0-r0-s7.arc 100% 1415KB 111.1MB/s 00:00
log-t0-r0-s8.arc 100% 14MB 175.1MB/s 00:00
log-t0-r0-s9.arc 100% 1024 1.6MB/s 00:00
[t7_2]tibero7@tibero_raw:/home/tibero7/tibero_arch/t7/t7_2/arch> scp ./*.arc root@192.168.29.101:/home/tibero7/tibero_arch/t7/t7_1/arch
The authenticity of host '192.168.29.101 (192.168.29.101)' can't be established.
ECDSA key fingerprint is SHA256:X1dZuXKK781n1qhXT7zPo/tAnYUL4AxmGN9ywX3sy/w.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.29.101' (ECDSA) to the list of known hosts.
root@192.168.29.101's password:
log-t1-r0-s1.arc 100% 512 428.2KB/s 00:00
log-t1-r0-s2.arc 100% 1057KB 110.6MB/s 00:00
log-t1-r0-s3.arc 100% 4376KB 49.6MB/s 00:00
log-t1-r0-s4.arc 100% 15MB 177.6MB/s 00:00
log-t1-r0-s5.arc 100% 512 1.2MB/s 00:00
log-t1-r0-s6.arc 100% 512 691.9KB/s 00:00
log-t1-r0-s7.arc 100% 512 1.3MB/s 00:00
log-t1-r0-s8.arc 100% 512 1.6MB/s 00:00
-- resetlogs로 컨트롤 파일 백업
SQL> alter database backup controlfile to trace as '/home/tibero7/reset.sql' resetlogs;
Database altered.
== TO-BE 수행 ==
[t7_1]tibero7@tibero_raw:/home/tibero7> dd if=/home/tibero7/system001.dtf bs=128M iflag=direct oflag=direct of=/dev/raw/raw17 bs=128M status=progress
3+1 records in
3+1 records out
524288000 bytes (524 MB, 500 MiB) copied, 0.796823 s, 658 MB/s
[t7_1]tibero7@tibero_raw:/home/tibero7> dd if=/home/tibero7/usr001.dtf bs=128M iflag=direct oflag=direct of=/dev/raw/raw18 bs=128M status=progress
3+1 records in
3+1 records out
524288000 bytes (524 MB, 500 MiB) copied, 0.687016 s, 763 MB/s
[t7_1]tibero7@tibero_raw:/home/tibero7> dd if=/home/tibero7/undo001.dtf bs=128M iflag=direct oflag=direct of=/dev/raw/raw19 bs=128M status=progress
3+1 records in
3+1 records out
524288000 bytes (524 MB, 500 MiB) copied, 0.661971 s, 792 MB/s
[t7_1]tibero7@tibero_raw:/home/tibero7> dd if=/home/tibero7/undo002.dtf bs=128M iflag=direct oflag=direct of=/dev/raw/raw20 bs=128M status=progress
3+1 records in
3+1 records out
524288000 bytes (524 MB, 500 MiB) copied, 0.698065 s, 751 MB/s
[t7_1]tibero7@tibero_raw:/home/tibero7> dd if=/home/tibero7/data001.dtf bs=128M iflag=direct oflag=direct of=/dev/raw/raw22 bs=128M status=progress
3+1 records in
3+1 records out
524288000 bytes (524 MB, 500 MiB) copied, 0.673473 s, 778 MB/s
[t7_1]tibero7@tibero_raw:/home/tibero7> dd if=/home/tibero7/data002.dtf bs=128M iflag=direct oflag=direct of=/dev/raw/raw23 bs=128M status=progress
3+1 records in
3+1 records out
524288000 bytes (524 MB, 500 MiB) copied, 0.684171 s, 766 MB/s
[t7_1]tibero7@tibero_raw:/home/tibero7> dd if=/home/tibero7/syssub001.dtf bs=128M iflag=direct oflag=direct of=/dev/raw/raw24 bs=128M status=progress
3+1 records in
3+1 records out
524288000 bytes (524 MB, 500 MiB) copied, 0.71869 s, 730 MB/s
-- nomount 기동 후, 컨트롤 파일 재생성
[t7_1]tibero7@tibero_raw:/home/tibero7> tbboot nomount
Listener port = 2629
Tibero 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Tibero instance started up (NOMOUNT mode).
[t7_1]tibero7@tibero_raw:/home/tibero7> tbsql sys
tbSQL 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Enter Password:
Connected to Tibero.
SQL> @reset.sql
Control File created.
-- mount 기동 후, thread 1에 대한 리두 그룹 생성 및 thread 1 활성화
[t7_1]tibero7@tibero_raw:/home/tibero7> tbboot mount
Listener port = 2629
Tibero 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Tibero instance started up (MOUNT mode).
SQL> ALTER DATABASE ADD LOGFILE THREAD 1 GROUP 10 ('/dev/raw/raw11','/dev/raw/raw12') SIZE 100M reuse ;
Database altered.
SQL> ALTER DATABASE ADD LOGFILE THREAD 1 GROUP 11 ('/dev/raw/raw13','/dev/raw/raw14') SIZE 100M reuse ;
Database altered.
SQL> ALTER DATABASE ADD LOGFILE THREAD 1 GROUP 12 ('/dev/raw/raw15','/dev/raw/raw16') SIZE 100M reuse ;
Database altered.
SQL> ALTER DATABASE ENABLE PUBLIC THREAD 1;
Database altered.
-- 불완전 복구 수행
SQL> alter database recover automatic;
TBR-1147: Need log file (thread 0 seq 13) to recover from TSN 161776.
Recovery done until 2025/11/25 03:28:55 TSN 161767.
Recovery is incomplete and resetlogs is required.
[t7_1]tibero7@tibero_raw:/home/tibero7> tbdown immediate
Tibero instance terminated (IMMEDIATE mode).
-- resetlogs 수행
[t7_1]tibero7@tibero_raw:/home/tibero7> tbboot resetlogs;
Listener port = 2629
Tibero 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Tibero instance started up (NORMAL RESETLOGS mode).
-- TO-BE 1번 노드 정상기동
[t7_1]tibero7@tibero_raw:/home/tibero7> tbdown immediate
Tibero instance terminated (IMMEDIATE mode).
Listener port = 2629
Tibero 7
TmaxTibero Corporation Copyright (c) 2020-. All rights reserved.
Tibero instance started up (NORMAL mode).
-- 복구 후 오브젝트 확인
SQL> select count(*) from tibero.test;
COUNT(*)
----------
100001
1 row selected.