오라클 백업 및 복구(RMAN)
1. RMAN으로 데이터 복구
가. Drop table 복구
<장애상황 만들기>
나. 백업파일 보존기간 설정(day) RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 1 DAYS; 다. 백업본의 개수 지정(개) RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 1; 라. 백업수행 시 병렬 프로세스 개수 RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO BACKUPSET; 마. 컨트롤파일 자동 백업 RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON; RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/data/backup/rman/%F’; 바. backupset의 최대크기 무제한 RMAN> CONFIGURE MAXSETSIZE TO UNLIMITED; 사. 중복 백업데이터 보관 RMAN> CONFIGURE BACKUP OPTIMIZATION OFF; 아. 백업파일 하나당 최대크기 지정 RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 100M;
-- 테이블 생성 및 데이터 삽입 create table scott.aaa (no number) tablespace example; insert into scott.aaa values (1); insert into scott.aaa values (2); commit; select * from scott.aaa; -- 시간 확인 select to_char(sysdate, 'RRRR-MM-DD:HH24:MI:SS') TIME from dual; -- 장애발생 drop table scott.aaa purge;< RMAN으로 복구하기> $ rman target / catalog rcuser/rcuser@rcserver RMAN> shutdown immediate; RMAN> run { startup mount; sql ‘alter session set nls_date_format=”RRRR-MM-DD:HH24:MI:SS”‘; set until time=’2012-02-24:22:48:51’; restore database; recover database; alter database open resetlogs; }
--복구 데이터 확인 select * from scott.aaa;나. 장애난 서버가 아닌 다른서버에서의 DB복구 < DB 백업 > $ rman target / catalog rcuser/rcuser@rcserver RMAN> run { allocate channel c1 device type disk; allocate channel c2 device type disk; allocate channel c3 device type disk; backup as compressed backupset format ‘/data/backup/rman/data_%U_%T’ database; backup as compressed backupset format ‘/data/backup/rman/arch_%U_%T’ archivelog all; backup as compressed backupset format ‘/data/backup/rman/ctl_%U_%T’ current controlfile; } <장애상황 만들기>
-- 테스트용 테이블 생성 create table scott.bbb (no number) tablespace users; insert into scott.bbb values (1); insert into scott.bbb values (2); insert into scott.bbb values (3); commit; select * from scott.bbb;$ rm /app/oracle/oradata/testdb/*
shutdown abort;$ vi $ORACLE_HOME/dbs/inittestdb.ora
*.control_files=’/data/temp/control01.ctl’
$ rman target / catalog rcuser/rcuser@rcserver
RMAN> startup nomount;
RMAN> restore controlfile from ‘/data/backup/rman/ctl_0qn45h3e_1_1_20120224’;
RMAN> alter database mount;
RMAN> report schema;
RMAN> run {
#채널 설정
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
#데이터 이름 변경
set newname for datafile 1 to ‘/data/temp/system01.dbf’;
set newname for datafile 2 to ‘/data/temp/sysaux01.dbf’;
set newname for datafile 3 to ‘/data/temp/undotbs01.dbf’;
set newname for datafile 4 to ‘/data/temp/users01.dbf’;
set newname for datafile 5 to ‘/data/temp/example01.dbf’;
# 파일 복원
restore database;
# controlfile에 저장
switch datafile all;
}
$ sqlplus / as sysdba
recover database until cancel using backup controlfile; auto alter database open resetlogs;2. RMAN 환경 변수 가. 현재 환경변수 보기 RMAN> show all;
나. 백업파일 보존기간 설정(day) RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 1 DAYS; 다. 백업본의 개수 지정(개) RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 1; 라. 백업수행 시 병렬 프로세스 개수 RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 3 BACKUP TYPE TO BACKUPSET; 마. 컨트롤파일 자동 백업 RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON; RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/data/backup/rman/%F’; 바. backupset의 최대크기 무제한 RMAN> CONFIGURE MAXSETSIZE TO UNLIMITED; 사. 중복 백업데이터 보관 RMAN> CONFIGURE BACKUP OPTIMIZATION OFF; 아. 백업파일 하나당 최대크기 지정 RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 100M;
쥔장님~ 질문좀할께.
내가 아직 RMAN에서 cloneDB부분 정리를 안해서 좀 헷갈리는 부분이 있다.
우리 기존에 클론디비 만들때 컨트롤파일도 재생성 하면서 DB이름 설정 해 줬잖아.
근데 위에 차근차근 보니까, 컨트롤 파일을 그냥 백업본에서 복원해 오는 것 같은데, 저렇게 되면 DB이름 같은건 어찌 되는거야?
그러고 보니 파라미터 파일도 딱히설정 안해주는데, 저걸로만 보면 클론 디비는 아닌것 같아서 헷갈림..ㅠㅠ