'rman을 이용한 백업(backup 명령어)'에 해당되는 글 1건

  1. 2009.06.27 rman을 이용한 백업(backup 명령어)
02.Oracle/DataBase2009. 6. 27. 10:52
반응형
rman을 이용한 백업(backup 명령어)

rman 유틸리티를 이용하여 백업하는 방법에 대하여 살펴본다.

1) 이미지 복사
이 방법은 운영체제의 복사 명령어와 같이 물리적 파일을 
rman을 사용하여 카탈로그 DB에 백업하는 방법이다.

 이 방법의 특징은 다음과 같다.
 • 디스크 저장장치에서만 복사할 수 있다.
 • 복구할 때 rman을 사용하지 않고 운영체제에서 직접 복구한다.
 • 데이터 파일, 아카이브 파일, 컨트롤 파일을 모두 이미지 복사할 수 있다.
 • 파일들의 모든 블록을 그대로 복사한다.


2) 다중백업세트
rman을 이용한 백업작업을 수행할 때 여러 개의 데이터 파일과 아카이브 파일, 
컨트롤 파일들을 사용자가 지정한 파일의 개수로 백업할 수 있는데,
 이를 다중백업세트(multiplex backup sets)라 한다.
 또한 하나의 백업세트 안에 저장될 수 있는 파일의 개수도 지정할 수 있는데, 
이를 백업조각(backup piece)라 한다.

예를 들어, 데이터베이스에는 3개의 데이터 파일과 3개의 컨트롤 파일, 
2개의 리두로그 파일, 3개의 아카이브 파일이 있는 경우,

rman에서  BACKUP DATABASE FILESPERSET=4 명령어로 대상 데이터베이스를 전체 백업한다. 
이 백업의 결과는 CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT= 'backup/%U'에 정의 되어 있는 경로에 
3개의 백업세트와 4개의 백업조각이 백업된다. 

즉, 백업세트는 백업작업 후 생성될 백업 파일의 개수를 의미하며, 
백업조각은 하나의 백업세트에 저장될 파일의 수를 의미한다. 

【예제】
$ rman target rman/rman
 
Recovery Manager Release 9.2.0.1.0 - 64bit Production
Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.
connected to target database JINPO (DBID=785004453)
 
RMAN> configure default device type to disk;
 
using target database controlfile instead of recovery catalog
new RMAN configuration parameters
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
new RMAN configuration parameters are successfully stored
 
RMAN> backup database archivelog all filesperset=5;
 
Starting backup at 10-SEP-04
allocated channel ORA_DISK_1
channel ORA_DISK_1 sid=12 devtype=DISK
channel ORA_DISK_1 starting full datafile backupset
channel ORA_DISK_1 specifying datafile(s) in backupset
including current SPFILE in backupset
including current controlfile in backupset
input datafile fno=00001 name=/export/home/oracle/oradata/jinpo/system01.dbf
input datafile fno=00005 name=/export/home/oracle/oradata/jinpo/example01.dbf
input datafile fno=00002 name=/export/home/oracle/oradata/jinpo/undotbs01.dbf
input datafile fno=00010 name=/export/home/oracle/oradata/jinpo/xdb01.dbf
input datafile fno=00006 name=/export/home/oracle/oradata/jinpo/indx01.dbf
input datafile fno=00009 name=/export/home/oracle/oradata/jinpo/users01.dbf
input datafile fno=00003 name=/export/home/oracle/oradata/jinpo/cwmlite01.dbf
input datafile fno=00004 name=/export/home/oracle/oradata/jinpo/drsys01.dbf
input datafile fno=00007 name=/export/home/oracle/oradata/jinpo/odm01.dbf
input datafile fno=00008 name=/export/home/oracle/oradata/jinpo/tools01.dbf
channel ORA_DISK_1 starting piece 1 at 10-SEP-04
channel ORA_DISK_1 finished piece 1 at 10-SEP-04
piece handle=/export/home/oracle/app/oracle/product/9.2.0/dbs/01fvkg11_1_1 comment=NONE
channel ORA_DISK_1 backup set complete, elapsed time: 00:03:47
channel ORA_DISK_1 starting archive log backupset
channel ORA_DISK_1 specifying archive log(s) in backup set
input archive log thread=1 sequence=70 recid=1 stamp=536405085
input archive log thread=1 sequence=71 recid=2 stamp=536490872
channel ORA_DISK_1 starting piece 1 at 10-SEP-04
channel ORA_DISK_1 finished piece 1 at 10-SEP-04
piece handle=/export/home/oracle/app/oracle/product/9.2.0/dbs/02fvkg84_1_1 comment=NONE
channel ORA_DISK_1 backup set complete, elapsed time: 00:00:08
Finished backup at 10-SEP-04
 
RMAN> 


3) 이중 백업세트
다중 백업세트가 여러 개의 파일들을 하나의 백업세트로 구성하는 방법인데 반하여, 
이중백업세트는 하나의 파일을 여러 개의 백업세트로 나누는 방법을 의미한다.
BACKUP 명령어와 함께 COPIES 키워드가 하나의 데이터 파일을 몇 개의 조각으로 나눌 것인지를 지정한다. 
DATAFILE n 키워드는 대상 데이터 파일의 파일 번호이며, 
번호는 DBA_DATA_FILES 자료사전에서 확인할 수 있다.
【예제】
SQL> connect system/manager
Connected.
SQL> select file_name,file_id from dba_data_files;
 
FILE_NAME                                             FILE_ID
------------------------------------------------- ----------
/export/home/oracle/oradata/jinpo/system01.dbf            1
/export/home/oracle/oradata/jinpo/undotbs01.dbf           2
/export/home/oracle/oradata/jinpo/cwmlite01.dbf           3
export/home/oracle/oradata/jinpo/drsys01.dbf              4
/export/home/oracle/oradata/jinpo/example01.dbf           5
/export/home/oracle/oradata/jinpo/indx01.dbf              6
/export/home/oracle/oradata/jinpo/odm01.dbf               7
/export/home/oracle/oradata/jinpo/tools01.dbf             8
/export/home/oracle/oradata/jinpo/users01.dbf             9
/export/home/oracle/oradata/jinpo/xdb01.dbf              10
 
10 rows selected.
 
SQL> exit
$ rman target rman/rman
 
Recovery Manager Release 9.2.0.1.0 - 64bit Production
Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.
connected to target database JINPO (DBID=785004453)
 
RMAN> BACKUP COPIES 2 DATAFILE 5;
 
Starting backup at 10-SEP-04
using target database controlfile instead of recovery catalog
allocated channel ORA_DISK_1
channel ORA_DISK_1 sid=9 devtype=DISK
channel ORA_DISK_1 starting full datafile backupset
channel ORA_DISK_1 specifying datafile(s) in backupset
input datafile fno=00005 name=/export/home/oracle/oradata/jinpo/example01.dbf
channel ORA_DISK_1 starting piece 1 at 10-SEP-04
channel ORA_DISK_1 finished piece 1 at 10-SEP-04 with 2 copies
piece handle=/export/home/oracle/app/oracle/product/9.2.0/dbs/03fvkhdm_1_1 comment=NONE
piece handle=/export/home/oracle/app/oracle/product/9.2.0/dbs/03fvkhdm_1_2 comment=NONE
channel ORA_DISK_1 backup set complete, elapsed time: 00:01:15
Finished backup at 10-SEP-04
 
RMAN> 


4) Backup 명령어
rman 유틸리티 프롬프트에서 사용하는 backup 명령어와 그 옵션은 다음과 같다.
【형식】
     BACKUP [BACKUP-TYPE] [옵션]

여기서 BACKUP-TYPE의 종류는 다음과 같다.
DATABASE데이터베이스 전체를 백업한다.
TABLESPACE ‘테이블스페이스명’ 지정한 테이블스페이스만 백업한다.
DATAFILE ‘파일명’ 특정 데이터 파일만 백업한다.
DATAFILECOPY ‘파일명’ 지정한 데이터파일을 복사하여 백업한다.
ARCHIVELOG ALL 백업시 모든 아카이브 파일도 함께 백업한다.
CURRENT CONTROLFILE 백업시 현재 컨트롤 파일도 함께 백업한다.
CONTROLFILECOPY ‘파일명’ 현재 컨트롤 파일을 복사하여 백업한다.
옵션의 종류는 다음과 같다.
TAG=‘내용’ 현재 백업절차에 대한 주석을 작성
FILESPERSET=n 백업조각의 수를 지정
DELETE INPUT 백업 후 아카이브 파일들을 삭제
FORMAT = ‘파일 경로와 파일명’ 백업파일의 경로와 파일명을 지정
다음은 자동으로 파일명을 지정하는 와일드카드는 다음과 같다.
%P 백업세트 내의 백업조각 번호
%S 백업세트번호
%D 대상 데이터베이스명
%N 대상 데이터베이스의 다른 표시이름
%T 초단위 시간 정보
%U 백업세트와 시간정보로 된 8문자
V$BACKUP_SET 자료사전을 참조해보면 현재 생성되어 있는 백업세트의 개수와 각 백업세트의 블록 크기를 알 수 있으며, 또한 V$BACKUP_PIECE 자료사전을 보면 백업세트의 경로와 파일명을 알 수 있다. 【예제】 SQL> connect system/manager Connected. SQL> select recid, block_size from v$backup_set; RECID BLOCK_SIZE ---------- ---------- 1 8192 2 512 3 8192 SQL> col handle format a65; SQL> select recid,set_count,piece#, handle from v$backup_piece; RECID SET_COUNT PIECE# HANDLE ---------- ---------- ---------- ----------------------- 1 1 1 /export/home/oracle/app/oracle/product/9.2.0/dbs/01fvkg11_1_1 2 2 1 /export/home/oracle/app/oracle/product/9.2.0/dbs/02fvkg84_1_1 3 3 1 /export/home/oracle/app/oracle/product/9.2.0/dbs/03fvkhdm_1_1 4 3 1 /export/home/oracle/app/oracle/product/9.2.0/dbs/03fvkhdm_1_2 SQL> 5) 컨트롤 파일의 자동 백업 rman 유틸리티에서 configure 명령으로 컨트롤 파일을 자동 백업하고 똑 같은 복사 본을 사용자가 지정하는 경로에 지정한 파일 명으로 백업할 수 있다. CONFIGURE CONTROLFILE AUTOBACKUP ON 명령을 실행하면 컨트롤 파일의 정보가 변경 될 때마다 채널 할당시 설정한 기본 백업경로에 백업해 준다. 또한 CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘경로와 파일명’ 명령으로 실행하면 지정된 경로와 파일명으로 컨트롤 파일을 백업해 준다. 【예제】 $ rman target rman/rman Recovery Manager Release 9.2.0.1.0 - 64bit Production Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved. connected to target database JINPO (DBID=785004453) RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON; using target database controlfile instead of recovery catalog new RMAN configuration parameters CONFIGURE CONTROLFILE AUTOBACKUP ON; new RMAN configuration parameters are successfully stored RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'joe_contrpl'; snapshot controlfile name set to joe_contrpl new RMAN configuration parameters are successfully stored RMAN> 참조: dbv 유틸리티를 사용하여 백업된 데이터가 깨졌는지 확인할 수 있다.
Posted by 1010