'Oracle/Backup & Recovery'에 해당되는 글 6건
RMAN 임시경로에서 복구하기
Oracle/Backup & Recovery
rtest 테이블 스페이스를 삭제 한 후 기존 파일 경로 말고 다른 위치에 restore 하고 recover
하는 실습을 해보겠다. 복원 경로를 다른 위치로 지정하는 명령어는
set newname for datafile <번호 또는 경로> to < 새 위치 경로 및 파일명>
그리고 복원 한 후 반드시 Control file의 내용을 switch datafile <파일번호> 명령어로 변경
해야 한다. 이 책에서는 임시 복원 장소를 /data/temp 디렉토리로 하겠다.

1) 현재 상태를 확인 후 파일을 삭제
RMAN> report schema;

using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name TESTDB

List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ----------- ----------------------------------------------------
1 720 SYSTEM *** /app/oracle/oradata/testdb/system01.dbf
2 660 SYSAUX *** /app/oracle/oradata/testdb/sysaux01.dbf
3 354 UNDOTBS1 *** /app/oracle/oradata/testdb/undotbs01.dbf
4 748 USERS *** /app/oracle/oradata/testdb/users01.dbf
5 345 EXAMPLE *** /app/oracle/oradata/testdb/example01.dbf
6 10 RTEST *** /app/oracle/oradata/testdb/rtest01.dbf

List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ---------------- --------------------------------------------------
1 100 TEMP100 100 /app/oracle/oradata/testdb/temp100.dbf

RMAN> exit

[oracle@localhost ~]$ rm -f /app/oracle/oradata/testdb/rtest01.dbf
[oracle@localhost ~]$ ls /app/oracle/oradata/testdb/rtest01.dbf
ls: /app/oracle/oradata/testdb/users01.dbf: 그런 파일이나 디렉토리가 없음
2) 임시경로로 파일을 복원 한 후 복구
[oracle@localhost ~]$ mkdir /data/temp <-- 없을 경우 이렇게 새로 만드세요.

[oracle@localhost ~]$ rman target sys/oracle

Recovery Manager: Release 11.2.0.2.0 - Production on Sun Aug 18 02:37:43 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: TESTDB (DBID=2581382545)

-- 파일을 복원하기 전에 복원할 경로를 먼저 지정해 준 후에 restore 명령을 내림
-- 작업형 명령어로 복구를 하겠습니다.


RMAN> run {
2> sql 'alter tablespace rtest offline immediate' ;
3> set newname for datafile '/app/oracle/oradata/testdb/rtest01.dbf'
4> to '/data/temp/rtest01.dbf';
5> restore tablespace rtest;
6> switch datafile 6; <- 이 파일번호는 report schema 에서 확인
7> recover tablespace users;
8> sql 'alter tablespace rtest online';
9> }
( 지면 관계상 복구 내용 출력부분은 생략)
위 명령에서 3-4 번줄로 복원하기 전에 미리 경로를 지정 한 후 5번 줄에서 백업된 파일을 새 경로에 복원하고
6번 줄에서 control file 에 있는 경로를 새 경로로 변경해 주는 순서를 꼭 기억해야한다.
사람이 하는 작업과 비교하면 3,4,5 번줄은 새로운 경로로 복사하는 과정이고 6번 줄은 복사 후
alter tablespace rtest rename datafile 하는 과정과 동일.
RMAN으로 복구 하기
Oracle/Backup & Recovery
1. RMAN으로 복구 하기
RMAN 복구 방법 역시 전통적인 방법과 동일하게 Restore 와 Recovery 라는 개념으로 나뉘게 된다.
Restore 는 백업 파일로부터의 복원이고 Recovery 는 Redo Log / ArchiveLog 를 적용시켜 복구 하는 것임
전통적인 방법과의 차이라면 순서와 원리는 동일하지만 전통적인 방법은 이 과정을 관리자가 수동으로 수행했던 것을
RMAN 유틸리티가 수행한다는 것입니다. 아래에서 자세히 각 Case 별로 어떻게 복구하는 지 살펴 보겠다.

Step 1. 실습을 위해 신규 테이블 스페이스를 생성 후 full backup 을 수행
SYS>create tablespace rtest
2 datafile '/app/oracle/oradata/testdb/rtest01.dbf' size 10M;

Tablespace created.

(RMAN으로 접속해서 전체 백업을 수행.)
RMAN> backup as compressed backupset database
2> format '/data/backup/rman/%T_full_%U';

Step 2. rtest01.dbf 파일을 삭제
RMAN> report schema;
Report of database schema for database with db_unique_name TESTDB
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ---------- --------------------------------------------------
1 720 SYSTEM *** /app/oracle/oradata/testdb/system01.dbf
2 660 SYSAUX *** /app/oracle/oradata/testdb/sysaux01.dbf
3 354 UNDOTBS1 *** /app/oracle/oradata/testdb/undotbs01.dbf
4 748 USERS *** /app/oracle/oradata/testdb/users01.dbf
5 345 EXAMPLE *** /app/oracle/oradata/testdb/example01.dbf
6 10 RTEST *** /app/oracle/oradata/testdb/rtest01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ---------------- -----------------------------------------------
1 100 TEMP100 100 /app/oracle/oradata/testdb/temp100.dbf
(-- rtest01.dbf 파일을 삭제합니다 --)

RMAN> exit

Recovery Manager complete.

[oracle@localhost ~]$ rm -f /app/oracle/oradata/testdb/rtest01.dbf
[oracle@localhost ~]$ ls /app/oracle/oradata/testdb/rtest01.dbf
ls: /app/oracle/oradata/testdb/rtest01.dbf: 그런 파일이나 디렉토리가 없음

Step 3. 삭제된 파일을 복구
1) 독립형 명령어
RMAN> sql 'alter tablespace rtest offline immediate' ;

RMAN> restore tablespace rtest ;

RMAN> recover tablespace rtest ;

RMAN> sql 'alter tablespace rtest online' ;
2. 작업형 명령어(장애를 한번더 일으켜서 복구)
[oracle@localhost ~]$ rm -f /app/oracle/oradata/testdb/rtest01.dbf
[oracle@localhost ~]$ ls /app/oracle/oradata/testdb/rtest01.dbf
ls: /app/oracle/oradata/testdb/rtest01.dbf: 그런 파일이나 디렉토리가 없음

[oracle@localhost ~]$ rman target sys/oracle

Recovery Manager: Release 11.2.0.2.0 - Production on Sun Aug 18 00:27:31 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: TESTDB (DBID=2581382545)

RMAN> run {
2> sql 'alter tablespace rtest offline immediate';
3> restore tablespace rtest ;
4> recover tablespace rtest ;
5> sql 'alter tablespace rtest online ';
6> }
2.Offline 이 안되는 데이터 파일이 삭제된 경우 - DB 종료 후 복구
이번 경우는 Offline 이 안되는 system tablespace 를 삭제 한 후 복구한다.
1 ) 현재 상태 확인 후 system01.dbf 삭제하기
RMAN> report schema;

Report of database schema for database with db_unique_name TESTDB
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ---------- --------------------------------------------------
1 720 SYSTEM *** /app/oracle/oradata/testdb/system01.dbf
2 660 SYSAUX *** /app/oracle/oradata/testdb/sysaux01.dbf
3 354 UNDOTBS1 *** /app/oracle/oradata/testdb/undotbs01.dbf
4 748 USERS *** /app/oracle/oradata/testdb/users01.dbf
5 345 EXAMPLE *** /app/oracle/oradata/testdb/example01.dbf
6 10 RTEST *** /app/oracle/oradata/testdb/rtest01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ---------------- -----------------------------------------------
1 100 TEMP100 100 /app/oracle/oradata/testdb/temp100.dbf

RMAN> exit

Recovery Manager complete.

[oracle@localhost ~]$ rm -f /app/oracle/oradata/testdb/system01.dbf
[oracle@localhost ~]$ ls /app/oracle/oradata/testdb/system01.dbf
ls: /app/oracle/oradata/testdb/system01.dbf: 그런 파일이나 디렉토리가 없음
2) DB종료 후 재시작하여 에러 확인
[oracle@localhost ~]$ rman target sys/oracle

Recovery Manager: Release 11.2.0.2.0 - Production on Sun Aug 18 00:36:19 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: TESTDB (DBID=2581382545)

RMAN> shutdown immediate;

using target database control file instead of recovery catalog

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of shutdown command at 08/18/2013 00:36:24
ORA-01116: error in opening database file 1
ORA-01110: data file 1: '/app/oracle/oradata/testdb/system01.dbf'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3 <--- 정상 종료가 안되는 것이 확인 됩니다.
RMAN> shutdown abort; <--- 강제로 비정상 종료를 시킵니다.
Oracle instance shut down

RMAN> startup


connected to target database (not started)
Oracle instance started
database mounted
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 08/18/2013 00:36:42
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/app/oracle/oradata/testdb/system01.dbf'
(system01.dbf 파일이 없어서 open 이 안됩니다.)
3) 파일을 복원
RMAN> restore tablespace system ;
( 지면 관계상 복원 내용은 생략합니다. 파일 크기가 커서 오래 걸릴 수도 있습니다 )


RMAN> recover database; <-- 비정상 종료가 되었기에 전체 데이터베이스를 복구합니다.
(지면 관계상 복구 내용은 생략합니다)


RMAN> alter database open;
database opened
정상적으로 복구 완료되었다. 위에서는 독립형 명령어로 작업을 했지만 당연히 작업형 명령어로도 가능하다. 직접 해 보시기 바랍니다.
(RMAN) 압축하면서 백업 수행하기(10g, 11g 공통)
Oracle/Backup & Recovery
Oracle 10g RMAN 부터 백업을 수행할 때 압축을 할 수 있다
RMAN에서 지원하는 압축은 기본값은 BZip2 이고 ZLIB 는 옵션으로 선택할 수 있고,
BZip2 방법은 압축 효율은 가장 좋지만 , CPU 부하가 많이 걸릴수 있고 속도 느리다.
그래서 11g R1부터는 Zlib 압축이 추가가 되었는데 CPU 부하는 적고 속도는 빠르지만 압축
효율이 Bzip2 에 비해 상대적으로 좋지 못하다.

ZLIB을 사용하려면 11g 이상 Advanced Compression Option 이 설치되어야 함.
아래 실습은 전, 후 용량 비교와 RMAN의 기본압축인 BZIP2방식을 이용해서 실습하겠음.

1) 압축하지 않고 기본 모드로 전체 Database 백업 수행
RMAN > backup database format '/data/backup/rman/%T_full_%U' ;
2) 압축 하면서 전체 database 백업 수행
RMAN > backup as compressed backupset database
2> format '/data/backup/rman/%T_full_comp_%U' ;
3) 압축하면서 전체 Archive log file 백업
RMAN > backup as compressed backupset archivelog all
2> format '/data/backup/rman/%U_%T';

그 외 각종 백업 옵션들
1) keep - backup 수행 시 bacjupset 보존기간 설정하기
RMAN> backup as compressed backupset tablespace example
2> format '/data/backup/rman/%U_%T'
3> keep until time 'sysdate+90' ;
2) not backuped up - 백업 안된 데이터파일만 골라서 백업
이 옵션은 특정 시점 이후 추가된 테이블 스페이스나 데이터 파일이 있을 경우
그 부분만 백업을 수행하는 기능입니다. 실습을 위해서 전체 백업을 수행 후
테이블 스페이스의 데이터 파일을 추가 한 후 이 옵션을 사용하여 백업을 수행하겠다.
[oracle@localhost ~]$ rman target sys/oracle

RMAN > backup as compressed backupset database
2> format '/data/backup/rman/%U_%T';

Starting backup at 02-DEC-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=40 device type=DISK
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/app/oracle/oradata/testdb/system01.dbf
input datafile file number=00002 name=/app/oracle/oradata/testdb/sysaux01.dbf
input datafile file number=00005 name=/app/oracle/oradata/testdb/example01.dbf
input datafile file number=00004 name=/app/oracle/oradata/testdb/users01.dbf
input datafile file number=00003 name=/app/oracle/oradata/testdb/undotbs01.dbf
( 이하 내용은 생략합니다 )
위와 같이 5개의 데이터 파일을 백업 수행했다.
그 후에 아래와 같이 test tablespace 를 신규로 생성하고
users tablespace 에 users02.dbf 를 추가 하고 기존에 존재하던 example Tablespace 에
테스트용 테이블 tt500 을 생성하고 데이터를 100 건 추가해서 내용을 변경했습니다.
RMAN> exit

Recovery Manager complete.
[oracle@localhost ~]$ sqlplus sys/oracle as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Mon Dec 2 02:57:00 2013
Copyright (c) 1982, 2010, Oracle. All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SYS>create tablespace test
2 datafile '/app/oracle/oradata/testdb/test001.dbf' size 10M;

Tablespace created.

SYS>alter tablespace users add datafile
2 '/app/oracle/oradata/testdb/users02.dbf' size 5M;

Tablespace altered.

SYS>create table tt500 (no number) tablespace example;

Table created.

SYS>begin
2 for i in 1..100 loop
3 insert into tt500 values (i);
4 end loop;
5 commit;
6 end;
7 /
PL/SQL procedure successfully completed.
그 후 위 옵션을 사용하여 추가된 데이터 파일만 백업 하겠다.
SYS>exit

[oracle@localhost ~]$ rman target sys/oracle

RMAN> backup as compressed backupset database
2> format '/data/backup/rman/%U_%T'
3> not backed up ;

Starting backup at 02-DEC-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=46 device type=DISK
skipping datafile 1; already backed up on 02-DEC-13
skipping datafile 2; already backed up on 02-DEC-13
skipping datafile 3; already backed up on 02-DEC-13
skipping datafile 4; already backed up on 02-DEC-13
skipping datafile 5; already backed up on 02-DEC-13
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/app/oracle/oradata/testdb/test001.dbf
input datafile file number=00007 name=/app/oracle/oradata/testdb/users02.dbf
channel ORA_DISK_1: starting piece 1 at 02-DEC-13
channel ORA_DISK_1: finished piece 1 at 02-DEC-13
piece handle=/data/backup/rman/0moqfidj_1_1_20131202 tag=TAG20131202T030211
comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 02-DEC-13
위와 같이 마지막 백업 후 데이터 파일이 추가된 부분만 백업이 수행됨을 확인 할 수 있다.
즉 example Tablespace 와 같이 파일 추가 없이 내용만 변경된 것은 이 방법으로 백업 안됨.
만약 기준일을 주고 싶으면 (예를 들어 오늘을 기준으로 최근 5일 이내 추가된 파일) 아래와 같이 since 옵션을 사용하면 된다.
RMAN> backup as compressed backupset database
2> format '/data/backup/rman/%U_%T'
3> not backed up since time='sysdate - 5' ;

3) RMAN 백업 작업 진행사항 확인하기
RMAN 작업을 하다 보면 얼마나 진행되었고 얼마나 남았는지 궁금할 경우가 있다.
이럴 때는 아래의 방법으로 조회하면 결과를 알 수 있음
SYS> SELECT SID, SERIAL#, CONTEXT, SOFAR, TOTALWORK,
2 ROUND(SOFAR/TOTALWORK*100,2) "%_COMPLETE"
3 FROM V$SESSION_LONGOPS
4 WHERE OPNAME LIKE 'RMAN%'
5 AND OPNAME NOT LIKE '%aggregate%'
6 AND TOTALWORK != 0
7 AND SOFAR <> TOTALWORK ;
SID SERIAL# CONTEXT SOFAR TOTALWORK %_COMPLETE
---------- ---------- -------------- ------------- --------------- -----------------
15 18683 1 57530 202640 28.39
SYS> /
SID SERIAL# CONTEXT SOFAR TOTALWORK %_COMPLETE
---------- ---------- ------------- ------------- --------------- ------------------
15 18683 1 64890 202640 32.02
…  …   …   …   …   …   …   …   …   …   …   …   … ..
SYS> /
no rows selected <- 작업이 완료되면 이렇게 나옴

'Oracle > Backup & Recovery' 카테고리의 다른 글

RMAN 임시경로에서 복구하기  (0) 2014.11.14
RMAN으로 복구 하기  (0) 2014.11.14
RMAN 증분백업(incremental backup)  (0) 2014.11.13
RMAN backup 종류  (0) 2014.11.13
RMAN (Recovery manager) channel 설정  (0) 2014.11.13
RMAN 증분백업(incremental backup)
Oracle/Backup & Recovery

1. 차등 증분 백업 (Incremental backup)
증분 백업이란 이전에 백업 받았던 백업파일과 비교해서
변경된 부분만 골라서 백업을 수행하는 것을 말한다.
차등 증분 백업과 누적 증분 백업이 있고, 이 기능은 Enterprise Edition 에서만 지원된다
그리고 10g 버전부터는 Block change tracking 이라는 기능이 지원이 되어 더 빠른 incremental backup이 지원됨.

                                                                             

                                                                             차등 등분 백업



차등 증분 백업은 백업 받을 때 설정했던 숫자가 자기보다 작거나 같으면 그 시점부터 지금까
지 모든 데이터를 백업을 받는 것을 말함
차등 증분 백업을 수행하는 명령어 예를 보겠다.

RMAN> run {
2> allocate channel c1 type disk;
3> backup
4> incremental level 0 <-- 차등 증분 백업을 의미합니다.
5> database
6> format '/data/backup/rman/%U_%T';
7> }

위 그림의 예를 들어 일요일에 level 0으로 a라는 데이터를 백업 받았고,
월요일까지 b라는 데이터가 추가되었다면 월요일에 level 3으로 백업을 수행하면
월요일보다 level 숫자가 같거나 작은 날을 찾아서 그 날짜 이후로 변경된 것만 백업을 받는 것이니
월요일보다 level 숫자가 작거나 같은날은 일요일이니까 월요일에는
일요일과 월요일 사이에 변경된 b 라는 데이터만 백업 받게 된다.
화요일은 level 3으로 받게 되면 화요일 이전에 백업 받았던 날짜의 level 을 순서대로 찾아서

화요일의 level 3과 같거나 작은 날을 찾게 되는데 월요일도 level 3이므로 월요일과 화요일
사이에 변경된 데이터 c 만 백업 받게 되는 것이다.

수요일은 level 2로 백업 받게 되면 이전 날짜들의 백업을 역순으로 조사해 보는데 화요일은
3으로 수요일보다 크니까 통과하고, 월요일도 3이니까 통과하고 일요일이 0 이니까 일요일
이후부터 수요일까지 변경된 데이터 b,c,d 모두를 백업 받게 됨.


1. 누적 증분 백업 (Incremental backup)

차등 증분 백업은 현재 날짜와 이전 날짜의 level 숫자가 작거나 또는 같으면 그 이전 날짜와

지금 날짜 사이의 변경된 모든 데이터를 백업 받았지만,

누적 증분 백업은 방식은 차등 증분 백업과 동일하다.

하지만 기준되는 날짜를 찾기 위해 작은 날짜가 와야 한다는 점이 차이점.


누적 증분 백업





RMAN> run { 2> allocate channel c2 type disk; 3> backup 4> incremental level 3 cumulative <-- 누적 증분 백업 옵션 5> table

위 그림에서 화요일 과 금요일, 토요일에 level 에 C 가 붙은 것이 누적 증분 백업이다
나머지 내용들은 다 동일하고 화요일에 누적 증분 백업을 받는다면 화요일의 3보다 작은 숫자
를 가진 날짜인 일요일 이후에 변경된 모든 내용을 백업 받아야 하기 때문에 화요일은 월,
화요일 사이에 변경된 b, c 데이터를 모두 백업 받게 되는 것입니다. 금요일과 토요일도 동일한
내용이지요.
이 경우에 만약 수요일 백업 전에 장애가 발생했다면 일요일 전체 백업 파일과 화요일 백업
파일 하나만 복구하면 전체 데이터를 다 복구 할 수 있다.



RMAN backup 종류
Oracle/Backup & Recovery

1. RMAN 백업 종류


(*RMAN Backup시에 주의 사항*)
- open 상태에서 백업을 받으려면 데이터베이스가 archive log mode 로 운영되어야 합니다.
- 데이터베이스가 마운트 또는 오픈되어 있어야 합니다.
- 운영중인 온라인 리두 로그 파일은 백업이 불가합니다
- 노 아카이브모드 에서는 Clean 백업만 사용 가능합니다.
(Clean Backup이란 오프라인 테이블스페이스나 읽기전용 테이블스페이스 백업을 의미합니다.)
- 해당 테이블스페이스는 백업모드이어서는 안됩니다.
- RMAN으로 백업을 수행하는 것은 Begin backup 시의 조건들과 동일해야 합니다.

1) backupset 으로 백업 수행 (default)
Backupset 이란 RMAN이 백업파일을 만들 때 RMAN만이 알 수 있는 형태로
백업파일을 생성하는데 이것을 backupset 이라고 하며 기본값.
이 방법으로 백업을 수행해야 RMAN 백업의 장점들을 모두 사용할 수 있다.
Backup piece란 backupset 의 크기가 너무 클 경우 분할해서 여러 개의 파일로 나누어서 백업 받을 수 있는데
분할되는 하나의 백업 파일을 backup piece라고 부른다.

2) Image copy로 백업 수행
Image copy 란 OS 명령어로 Begin backup 하는 것과 가장 유사한 방법.
RMAN> copy
2> datafile '/app/oracle/oradata/testdb/example01.dbf'
3> to '/data/backup/rman/example01.dbf.bak';
2. RMAN 명령어 종류
1) 작업형 명령
작업형 명령어는 마치 프로그램의 스크립트처럼 여러 개의 명령어를 한꺼번에 사용할 수 있는 방법.
작업형 명령어는 run { 수행할 명령들; } 의 형식으로 구성이 된다.
RMAN> run {
2> allocate channel ch1 type disk
3> format '/data/backup/close/%T_example.bak' ;
4> backup tablespace example ;
5> }
2) 독립형 명령 (stand alone)
이 명령방식은 RMAN> prompt 에 1개의 명령어만 들어가는 방식.
RMAN> backup tablespace example ; <- 1 개의 명령어가 입력됩니다.
RMAN> backup <- 이부분을 여러줄로 쓴다 해도 ; 이 한 개이므로 1개의 명령어.
2> tablespace 마치 SQL문장을 여러 줄에 써도 ; 이 한 개이면 한 개의 명령어.
3> example; 인 것과 마찬가지임.
RMAN (Recovery manager) channel 설정
Oracle/Backup & Recovery
1. channel 설정하기
RMAN 에서 Channel 이란 쉽게 말하면 백업과 복구를 하는 경로를 의미한다..
백업을 수행하기 전에 Channel을 할당 해 줘야 RMAN이 백업 / 복구를 수행할 수 있고
복구를 할 때는 Channel을 할당하지 않아도 되지만 백업을 할 경우는 반드시 Channel을 할당해 줘야 한다.
Channel을 할당하는 방법은 자동 Channel설정과 수동Channel 설정이 있다.

1) 자동 channel 설정하기
자동 Channel이란 백업을 수행할 때 별도의 경로를 주지 않아도 정해진 위치로 백업을 받는
것을 말하며 default channel 의 의미가 있다.
아래와 같이 설정합니다.
[oracle@localhost ~]$ rman target / catalog rcuser/rcuser@rcserver (복구 카탈로그 서버 사용시)
[oracle@localhost ~]$
[oracle@localhost ~]$ rman target sys/oracle (복구 카탈로그  서버 사용 안할시)
[oracle@localhost ~]$
자동 channel 명령어
RMAN > configure default device type to disk (자동 channel 설정 명령어)
(이렇게 설정하면 default device가 파라미터 파일의 db_recovery_file_dest 파라미터의 경로로 설정이 됩니다.)
자동 특정 경로 명령어
[oracle@localhost ~]$ mkdir /data/backup/rman (rman이라는 디렉토리 생성)
[oracle@localhost ~]$ rman target sys/oracle (RMAN 접속)
RMAN > configure channel device type disk
2> format '/data/backup/rman/%U_%T'; (%U는 파일명 중복 안되게,%T는 백업날짜)
RMAN > backup tablespace example ;
2) 수동 channel 명령어
RMAN> run {
2> allocate channel ch1 type disk (ch1 명은 마음대로 줘도 됨)
3> format '/data/backup/close/%U_%T' ;
4> backup tablespace example;
5> }
위의 작 업은 아래와 같이 독립형 명령어로도 가능하다.
RMAN> backup tablespace example
2> format '/data/backup/open/%U_%T' ;
이름으로 직접 지정
RMAN> backup tablespace example
2> format '/data/backup/rman/%T_example.bak';