내맘대로긍정이 알려주는
Oracle 23ai 신기능
무료 세미나 발표자료
다운로드
trending_flat
OS환경 : Oracle Linux6.8(64bit)
DB 환경 : Oracle Database 10.2.0.4
방법 : rman 복구 시나리오1
1. RMAN 처음 사용할 경우 환경설정 작업
RMAN은 archive mode에서만 백업이 된다.
아카이브 모드 설정
1 2 3 4 5 6 7 8 9 10 | SQL> STARTUP MOUNT SQL> ALTER DATABASE ARCHIVELOG; SQL> ARCHVIE LOG LIST Database log mode Archive Mode Automatic archival Enabled Archive destination /oracle/app/oracle/product/10.2.0/db_1/dbs/arch Oldest online log sequence 1 Next log sequence to archive 1 Current log sequence 1 SQL> ALTER DATABASE OPEN; |
RMAN 접속
1 2 3 | $ rman target / nocatalog 또는 $ rman target / |
RMAN에서는 configure 명령어로 파라미터를 수정함
device 에 대한 channel 을 설정
1 | RMAN> configure channel device type disk format '/oracle/app/oracle/backup/orcl_%U'; |
controlfile Auto backup channel 설정
1 | RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/oracle/app/oracle/backup/control/%F'; |
Backup 최적화 option
1 | RMAN> CONFIGURE BACKUP OPTIMIZATION ON; |
controlfile Auto Backup 설정
1 | RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON; |
백업보관주기 설정
1 | RMAN> configure retention policy to recovery window of 5 days; |
모든 설정 확인
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | RMAN> show all CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 5 DAYS; CONFIGURE BACKUP OPTIMIZATION ON; CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/oracle/app/oracle/backup/control/%F'; CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/oracle/app/oracle/backup/orcl_%U'; CONFIGURE MAXSETSIZE TO UNLIMITED; # default CONFIGURE ENCRYPTION FOR DATABASE OFF; # default CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/oracle/app/oracle/product/10.2.0/db_1/dbs/snapcf_orcl.f'; # default |
2. full 백업 진행
1 | RMAN> backup as compressed backupset database spfile plus archivelog delete input; |
3. system01.dbf datafile 삭제
1 | $ rm -rf /oracle/app/oracle/oradata/system01.dbf |
4. DB 재기동
1 2 3 4 5 6 7 8 9 10 11 12 | SQL> SHUTDOWN ABORT SQL> STARTUP ORACLE instance started. Total System Global Area 285212672 bytes Fixed Size 2095704 bytes Variable Size 88081832 bytes Database Buffers 188743680 bytes Redo Buffers 6291456 bytes Database mounted. ORA-01157: cannot identify/lock data file 1 - see DBWR trace file ORA-01110: data file 1: '/oracle/app/oracle/oradata/orcl/system01.dbf' |
에러발생
5. RMAN에서 복구
RMAN에서 datafile 번호 확인
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | RMAN> list backup; using target database control file instead of recovery catalog List of Backup Sets =================== BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 5 Full 320.02M DISK 00:00:03 08-FEB-18 BP Key: 5 Status: AVAILABLE Compressed: NO Tag: TAG20180208T161325 Piece Name: /oracle/app/oracle/backup/orcl_0asqno95_1_1 List of Datafiles in backup set 5 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 1 Full 269595 08-FEB-18 /oracle/app/oracle/oradata/orcl/system01.dbf 2 Full 269595 08-FEB-18 /oracle/app/oracle/oradata/orcl/undotbs01.dbf 3 Full 269595 08-FEB-18 /oracle/app/oracle/oradata/orcl/sysaux01.dbf 4 Full 269595 08-FEB-18 /oracle/app/oracle/oradata/orcl/users01.dbf 5 Full 269595 08-FEB-18 /oracle/app/oracle/oradata/orcl/jshts01.dbf BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 6 Full 6.80M DISK 00:00:00 08-FEB-18 BP Key: 6 Status: AVAILABLE Compressed: NO Tag: TAG20180208T161332 Piece Name: /oracle/app/oracle/backup/control/c-1491144423-20180208-01 Control File Included: Ckp SCN: 269602 Ckp time: 08-FEB-18 SPFILE Included: Modification time: 08-FEB-18 |
system01.dbf는 1번 파일임을 확인할수 있다. (사실 위에 startup 시에도 datafile 번호가 나옴)
restore 진행(정상적인 파일 다시 부어주는 작업)
1 2 3 4 5 6 7 8 9 10 11 12 13 | RMAN> restore datafile 1; Starting restore at 08-FEB-18 allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=156 devtype=DISK channel ORA_DISK_1: starting datafile backupset restore channel ORA_DISK_1: specifying datafile(s) to restore from backup set restoring datafile 00001 to /oracle/app/oracle/oradata/orcl/system01.dbf channel ORA_DISK_1: reading from backup piece /oracle/app/oracle/backup/orcl_0asqno95_1_1 channel ORA_DISK_1: restored backup piece 1 piece handle=/oracle/app/oracle/backup/orcl_0asqno95_1_1 tag=TAG20180208T161325 channel ORA_DISK_1: restore complete, elapsed time: 00:00:04 Finished restore at 08-FEB-18 |
recover 진행(부어진 파일에서 문제있는 부분을 복구하는 작업)
1 2 3 4 5 6 7 8 | RMAN>recover datafile 1; Starting recover at 08-FEB-18 using channel ORA_DISK_1 starting media recovery media recovery complete, elapsed time: 00:00:01 Finished recover at 08-FEB-18 |
6.DB 오픈 시켜서 정상동작 확인
1 2 3 4 5 6 7 8 9 10 11 12 13 | RMAN> sql 'alter database open'; sql statement: alter database open RMAN> exit oracle> sqlplus / as sysdba SQL> SELECT INSTANCE_NAME, STATUS FROM V$INSTANCE; INSTANCE_NAME STATUS ---------------- ------------ orcl OPEN 1 row selected. |
참조 : 굿어스 기술노트 40회 RMAN
'ORACLE > Backup&Recover' 카테고리의 다른 글
hot backup 복구 시나리오1 (0) | 2018.12.17 |
---|---|
Oracle 12c R2 Clone DB 생성 및 복구 시나리오 (3) | 2018.09.20 |
최악의 복구 시나리오에 대한 해결방법(SCN이 모두 틀림) (0) | 2018.09.20 |
Oracle Block change tracking 기능 (0) | 2018.05.24 |
RMAN CrossCheck 명령 (0) | 2018.02.21 |