1. DB 내리기
SYS@ora11g> shutdown immediate
나무늘보가 하도 일을 안하다 보니 이제는 아예 DB 를 내리고 시작
2. users 테이블스페이스에 속한 데이터파일 지워서 장애 유발하기
SYS@ora11g> ! rm /u01/app/oracle/oradata/ora11g/users01.dbf
3. DB 올리기
SYS@ora11g> startup
ORACLE instance started.
Total System Global Area 711430144 bytes
Fixed Size 1367004 bytes
Variable Size 448791588 bytes
Database Buffers 255852544 bytes
Redo Buffers 5419008 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/u01/app/oracle/oradata/ora11g/users01.dbf'
있어야 할 파일이 없어서 마운트 단계까지만 열리고 오류가 발생한다.
4. 다시 RMAN 으로 새로 접속해서 오류 내용 보기
[oracle@oracle ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Mon Jan 29 11:51:48 2024
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORA11G (DBID=256148007, not open)
RMAN> list failure;
RMAN> list failure;
using target database control file instead of recovery catalog
List of Database Failures
=========================
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
128 HIGH OPEN 29-JAN-24 One or more non-system datafiles are missing
102 HIGH OPEN 08-JAN-24 One or more non-system datafiles are offline
RMAN> list failure 128 detail;
RMAN> list failure 128 detail;
List of Database Failures
=========================
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
128 HIGH OPEN 29-JAN-24 One or more non-system datafiles are missing
Impact: See impact for individual child failures
List of child failures for parent failure ID 128
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
12105 HIGH OPEN 29-JAN-24 Datafile 4: '/u01/app/oracle/oradata/ora11g/users01.dbf' is missing
Impact: Some objects in tablespace USERS might be unavailable
RMAN> advise failure;
(QUESTION. 이건 뭐하는 명령어야? 위에 나온 list failure 나 list failure 128 detail 하고 다른 점이 대체 뭐야?
내가 보기엔 별다를 게 없어 보이는데...?)
(ANSWER. advise failure 하면 해결 방법을 제시해 주면서
복구 스크립트 - 아래 파랗고 굵은 글씨로 표시한 부분 - 을 만드는데,
그걸 가지고 다음 단계인 repair failure 를 수행하는 것이기 때문에 이 단계는 꼭 필요하다.)
RMAN> advise failure;
List of Database Failures
=========================
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
128 HIGH OPEN 29-JAN-24 One or more non-system datafiles are missing
Impact: See impact for individual child failures
List of child failures for parent failure ID 128
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
12105 HIGH OPEN 29-JAN-24 Datafile 4: '/u01/app/oracle/oradata/ora11g/users01.dbf' is missing
Impact: Some objects in tablespace USERS might be unavailable
analyzing automatic repair options; this may take some time
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=171 device type=DISK
analyzing automatic repair options complete
Mandatory Manual Actions
========================
no manual actions available
Optional Manual Actions
=======================
1. If file /u01/app/oracle/oradata/ora11g/users01.dbf was unintentionally renamed or moved, restore it
Automated Repair Options
========================
Option Repair Description
------ ------------------
1 Restore and recover datafile 4
Strategy: The repair includes complete media recovery with no data loss
Repair script: /u01/app/oracle/diag/rdbms/ora11g/ora11g/hm/reco_2163379507.hm
RMAN> repair failure preview;
니가 한번 고쳐보라고 말하면: 자기 같으면 어떻게 어떻게 고치겠다고 알려주는데,
물론 저대로 따라해도 되지만
RMAN> repair failure preview;
Strategy: The repair includes complete media recovery with no data loss
Repair script: /u01/app/oracle/diag/rdbms/ora11g/ora11g/hm/reco_2163379507.hm
contents of repair script:
# restore and recover datafile
restore datafile 4;
recover datafile 4;
sql 'alter database datafile 4 online';
저것도 귀찮다면 그냥
5. RMAN 에게 고치라고 명령하기
RMAN> repair failure;
Do you really want to execute the above repair (enter YES or NO)? yes
나한테는 한 번만 물어봤는데 만약 얘가 또 한번 물어보면 또 yes 하기
(이거 두번째로 물어본 거는 DB 열어줄까 물어본 거라는데 나한테는 아예 묻지도 않았어...
선생님은 DB 열어줄까 말까 얘가 물어봐줬다는데... 사람 차별하냐...)
RMAN> repair failure;
Strategy: The repair includes complete media recovery with no data loss
Repair script: /u01/app/oracle/diag/rdbms/ora11g/ora11g/hm/reco_2163379507.hm
contents of repair script:
# restore and recover datafile
restore datafile 4;
recover datafile 4;
sql 'alter database datafile 4 online';
Do you really want to execute the above repair (enter YES or NO)? yes
executing repair script
Starting restore at 29-JAN-24
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/ora11g/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/ORA11G/backupset/2024_01_29/o1_mf_nnndf_TAG20240129T105858_lvg1m2g9_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/ORA11G/backupset/2024_01_29/o1_mf_nnndf_TAG20240129T105858_lvg1m2g9_.bkp tag=TAG20240129T105858
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 29-JAN-24
Starting recover at 29-JAN-24
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 29-JAN-24
sql statement: alter database datafile 4 online
repair failure complete
6. DB 상태를 확인해보면 : 마운트 단계라고 나오는데
데이터베이스 오픈 단계까지 올리기
SYS@ora11g> select status from v$instance;
STATUS
------------
MOUNTED
SYS@ora11g> alter database open;
Database altered.
1. 다시 정상적으로 DB 내리기
SYS@ora11g> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
2. 시스템 데이터파일 지우기
SYS@ora11g> ! rm /u01/app/oracle/oradata/ora11g/system01.dbf
3. DB 올리기 (당연히 오류 발생)
SYS@ora11g> startup
ORACLE instance started.
Total System Global Area 711430144 bytes
Fixed Size 1367004 bytes
Variable Size 452985892 bytes
Database Buffers 251658240 bytes
Redo Buffers 5419008 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/u01/app/oracle/oradata/ora11g/system01.dbf'
4. RMAN 에서 오류 정보 확인
RMAN> list failure;
using target database control file instead of recovery catalog
List of Database Failures
=========================
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
12187 CRITICAL OPEN 29-JAN-24 System datafile 1: '/u01/app/oracle/oradata/ora11g/system01.dbf' is missing
102 HIGH OPEN 08-JAN-24 One or more non-system datafiles are offline
RMAN> list failure 12187 detail;
using target database control file instead of recovery catalog
List of Database Failures
=========================
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
12187 CRITICAL OPEN 29-JAN-24 System datafile 1: '/u01/app/oracle/oradata/ora11g/system01.dbf' is missing
Impact: Database cannot be opened
5.
RMAN> advise failure;
오류에 대한 조언 받기
RMAN> advise failure;
List of Database Failures
=========================
Failure ID Priority Status Time Detected Summary
---------- -------- --------- ------------- -------
12187 CRITICAL OPEN 29-JAN-24 System datafile 1: '/u01/app/oracle/oradata/ora11g/system01.dbf' is missing
Impact: Database cannot be opened
analyzing automatic repair options; this may take some time
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=171 device type=DISK
analyzing automatic repair options complete
Mandatory Manual Actions
========================
no manual actions available
Optional Manual Actions
=======================
1. If file /u01/app/oracle/oradata/ora11g/system01.dbf was unintentionally renamed or moved, restore it
Automated Repair Options
========================
Option Repair Description
------ ------------------
1 Restore and recover datafile 1
Strategy: The repair includes complete media recovery with no data loss
Repair script: /u01/app/oracle/diag/rdbms/ora11g/ora11g/hm/reco_3298291817.hm
RMAN> repair failure preview;
너 같으면 어떻게 고칠 거냐고도 물어보기
RMAN> repair failure preview;
Strategy: The repair includes complete media recovery with no data loss
Repair script: /u01/app/oracle/diag/rdbms/ora11g/ora11g/hm/reco_3298291817.hm
contents of repair script:
# restore and recover datafile
restore datafile 1;
recover datafile 1;
sql 'alter database datafile 1 online';
6. RMAN 에게 알아서 좀 고쳐달라고 하기
RMAN> repair failure;
Do you really want to execute the above repair (enter YES or NO)? yes
7. DB 열기
SYS@ora11g> alter database open;
Database altered.
일반적인 복구는 얘로 할 수 있지만
불완전 복구는 얘로는 할 수 없다. (사람이 해야 함)
컨트롤파일이 깨졌을 때의 복구도 얘로는 할 수 없다.
(데이터파일이 깨졌을 때 정도만 복구할 수 있다)
음... 편리하지만 한계가 분명하네...
2024년 1월 29일 5교시 백업셋과 백업피스 크기 제한하기, 이미지 카피 백업 (0) | 2024.01.29 |
---|---|
2024년 1월 29일 4교시+5교시 앞부분 : 컨트롤파일과 데이터파일들이 몽땅 깨졌을 때 RMAN으로 복구하기 / 컨트롤파일과 리두로그 파일이 깨졌을 때 RMAN으로 복구하기 (0) | 2024.01.29 |
2024년 1월 29일 2교시 헌 DB 새 DB 로 만들기, 초기 파라미터 파일이 깨졌을 때의 대처 방법(DBID) (0) | 2024.01.29 |
2024년 1월 29일 1교시 RMAN clear 명령어, 컨트롤파일이 깨진 경우 RMAN 으로 복구하기 (0) | 2024.01.29 |
2024년 1월 26일 3교시 자습시간 ♡ (0) | 2024.01.26 |