#) data file, tablespace 정보 확인
SELECT a.file#, b.name tbs_name, a.name file_name, a.status, a.checkpoint_change#
FROM v$datafile a, v$tablespace b
WHERE a.ts# = b.ts#;
#) rollback 세그먼트 정보 확인
SELECT segment_id, segment_name, owner, tablespace_name, status
FROM dba_rollback_segs;
#) hr 계정 : DML 실행
update hr.employees
set salary = 2000
where employee_id = 100;
#) sys 계정
s.username, /* session의 사용자이름 */
s.sid, /* session의 세션ID */
s.serial#, /* 세션 일련번호 */
r.name, /* role 이름 */
t.xidusn, /* 트랜잭션의 undo segment 번호 */
t.ubafil, /* 트랜잭션의 und file 번호 */
t.ubablk, /* 트랜잭션의 undo 블록 번호 */
t.used_ublk /* 트랜잭션의 undo 블록의 수 */
#) 세션, 트랜잭션 및 롤백 세그멘트 정보 확인
select s.username, s.sid, s.serial#, r.name, t.xidusn, t.ubafil, t.ubablk, t.used_ublk
from v$session s, v$transaction t, v$rollname r
where s.taddr = t.addr
and t.xidusn = r.usn;
XIDUSN UBAFIL(파일번호) UBABLK(언두블록) USED_UBLK(언두블록 수)
#) session kill 하기
'SID, SERIAL'
alter system kill session '140,177' immediate;
#) <HR SESSION> 접속 후
- 조회 불가 : sys 에서 hr kill 했기 때문.
select * from hr.employees;
select * from hr.employees
*
ERROR at line 1:
ORA-03135: connection lost contact
Process ID: 29976
Session ID: 140 Serial number: 177
#) sys 계정으로 재접속
conn hr/hr
=> UPDATE 문 실행
update hr.employees
set salary = 2000
where employee_id = 100;
#) SYS SESSION 에서 SID,SERIAL 번호 확인
<<SYS SESSION>>
select s.username, s.sid, s.serial#, r.name, t.xidusn, t.ubafil, t.ubablk, t.used_ublk
from v$session s, v$transaction t, v$rollname r
where s.taddr = t.addr
and t.xidusn = r.usn;
#) current, SEQUENCE 번호 확인
select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
7 1 29 104857600 512 1 NO INACTIVE 1764483 09-JAN-24 1784778 09-JAN-24
8 1 30 104857600 512 1 NO CURRENT 1784778 09-JAN-24 2.8147E+14
9 1 28 104857600 512 1 NO INACTIVE 1764479 09-JAN-24 1764483 09-JAN-24
# 장애 유발 #
! rm /u01/app/oracle/oradata/ora11g/undotbs01.dbf
alter system checkpoint;
=> 비정상적으로 DB 내려갔음
#) DB 올리기 => session 내려감
startup
ORA-24324: service handle not initialized
ORA-01041: internal error. hostdef extension doesn't exist
#) 다시 재접속
conn / as sysdba
#) DB 비정상적인 종료하기
shutdown abort
#) DB 올리기
- mount 단계까지만 올리기
startup
ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
ORA-01110: data file 6: '/u01/app/oracle/oradata/ora11g/undotbs01.dbf'
#) data file 확인
select name, status from v$datafile;
#) 파일번호로 해보기
ORA-01110: data file 6: '/u01/app/oracle/oradata/ora11g/undotbs01.dbf'
alter database datafile 6 offline for drop;
#) undotbs01.dbf 상태 확인
select name, status from v$datafile;
NAME STATUS
-------------------------------------------------- -------
/u01/app/oracle/oradata/ora11g/system01.dbf SYSTEM
/u01/app/oracle/oradata/ora11g/sysaux01.dbf ONLINE
/u01/app/oracle/oradata/ora11g/users01.dbf ONLINE
/u01/app/oracle/oradata/ora11g/example01.dbf ONLINE
/u01/app/oracle/oradata/ora11g/undotbs01.dbf RECOVER
#) DB open
alter database open;
#) open 제대로 했는지 확인
=> select문 확인 / DML문 불가
select count(*) from hr.employees;
#) undo1.dbf 생성
CREATE UNDO TABLESPACE undo1
DATAFILE '/u01/app/oracle/oradata/ora11g/undo1.dbf' SIZE 10M AUTOEXTEND ON;
#) undo 확인
show parameter undo
=> UNDOTBS : 새로운 undo로 수정
#) UNDOTBS -> UNDO1 로 변경
alter system set undo_tablespace = undo1;
#) 변경된 undo1 확인
show parameter undo
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
undo_management string AUTO
undo_retention integer 900
undo_tablespace string UNDO1
#) undo 확인
=>기본 10개 생성 + 기존 undotbs 10개
SELECT segment_id, segment_name, owner, tablespace_name, status FROM dba_rollback_segs;
SEGMENT_ID SEGMENT_NAME OWNER TABLESPACE_NAME STATUS
---------- ------------------------------ ------ ------------------------------ ----------------
0 SYSTEM SYS SYSTEM ONLINE
1 _SYSSMU1_1546322671$ PUBLIC UNDOTBS NEEDS RECOVERY
2 _SYSSMU2_390784345$ PUBLIC UNDOTBS NEEDS RECOVERY
3 _SYSSMU3_1386048583$ PUBLIC UNDOTBS NEEDS RECOVERY
4 _SYSSMU4_1372935823$ PUBLIC UNDOTBS NEEDS RECOVERY
5 _SYSSMU5_2650963508$ PUBLIC UNDOTBS NEEDS RECOVERY
6 _SYSSMU6_4136026661$ PUBLIC UNDOTBS NEEDS RECOVERY
7 _SYSSMU7_3764534833$ PUBLIC UNDOTBS NEEDS RECOVERY
8 _SYSSMU8_209989947$ PUBLIC UNDOTBS NEEDS RECOVERY
9 _SYSSMU9_198652043$ PUBLIC UNDOTBS NEEDS RECOVERY
10 _SYSSMU10_863991237$ PUBLIC UNDOTBS NEEDS RECOVERY
11 _SYSSMU11_3644246507$ PUBLIC UNDO1 ONLINE
12 _SYSSMU12_3785212808$ PUBLIC UNDO1 ONLINE
13 _SYSSMU13_1156647635$ PUBLIC UNDO1 ONLINE
14 _SYSSMU14_4080438239$ PUBLIC UNDO1 ONLINE
15 _SYSSMU15_2515553540$ PUBLIC UNDO1 ONLINE
16 _SYSSMU16_1863078453$ PUBLIC UNDO1 ONLINE
17 _SYSSMU17_1908207187$ PUBLIC UNDO1 ONLINE
18 _SYSSMU18_1387739918$ PUBLIC UNDO1 ONLINE
19 _SYSSMU19_2376516152$ PUBLIC UNDO1 ONLINE
20 _SYSSMU20_1948499560$ PUBLIC UNDO1 ONLINE
#) 상태가 NEEDS RECOVERY 제거하는 작업
drop tablespace undotbs including contents and datafiles;
drop tablespace undotbs including contents and datafiles
*
ERROR at line 1:
ORA-01548: active rollback segment '_SYSSMU1_1546322671$' found, terminate dropping tablespace
(또는 OFFLINE 상태로 변경되었을 경우 => drop tablespace 된 것이다.)
#) drop 실패시 해결 방법
SELECT segment_id, segment_name, owner, tablespace_name, status
FROM dba_rollback_segs
WHERE status ='NEEDS RECOVERY';
segment_name
_SYSSMU1_1546322671$
_SYSSMU2_390784345$
_SYSSMU3_1386048583$
_SYSSMU4_1372935823$
_SYSSMU5_2650963508$
_SYSSMU6_4136026661$
_SYSSMU7_3764534833$
_SYSSMU8_209989947$
_SYSSMU9_198652043$
_SYSSMU10_863991237$
#) pfile 생성
create pfile from spfile;
#) 수동으로 OFFLINE 모드로 변경해야 한다.
#1) 정상적인 종료 후 OS 나오기
shutdown immediate
!
#2) pfile 생성된 디렉터리로 이동 후vi 편집기로 열기
[oracle1@oracle ~]$ cd $ORACLE_HOME/dbs
[oracle1@oracle dbs]$ ls
hc_ora11g.dat init.ora initora11g.ora lkORA11G orapwora11g spfileora11g.ora
[oracle1@oracle dbs]$ vi initora11g.ora
(수정)
_offline_rollback_segments=(
_SYSSMU1_1546322671$,
_SYSSMU2_390784345$,
_SYSSMU3_1386048583$,
_SYSSMU4_1372935823$,
_SYSSMU5_2650963508$,
_SYSSMU6_4136026661$,
_SYSSMU7_3764534833$,
_SYSSMU8_209989947$,
_SYSSMU9_198652043$,
_SYSSMU10_863991237$)
:wq (저장)
#3) 수정된 파일 확인
[oracle1@oracle dbs]$ cat initora11g.ora
...
*.undo_tablespace='UNDO1'
_offline_rollback_segments=(
_SYSSMU1_1546322671$,
_SYSSMU2_390784345$,
_SYSSMU3_1386048583$,
_SYSSMU4_1372935823$,
_SYSSMU5_2650963508$,
_SYSSMU6_4136026661$,
_SYSSMU7_3764534833$,
_SYSSMU8_209989947$,
_SYSSMU9_198652043$,
_SYSSMU10_863991237$)
#4) DB를 pfile 올리기
[oracle1@oracle dbs]$ exit
exit
startup pfile='$ORACLE_HOME/dbs/initora11g.ora'
#5) drop tablespace 삭제
drop tablespace undotbs including contents and datafiles;
#6) undo1.dbf 확인
- NEEDS RECOVERY mode 없는지 확인
SELECT segment_id, segment_name, owner, tablespace_name, status FROM dba_rollback_segs;
SEGMENT_ID SEGMENT_NAME OWNER TABLESPACE_NAME STATUS
---------- ------------------------------ ------ ------------------------------ ----------------
0 SYSTEM SYS SYSTEM ONLINE
11 _SYSSMU11_3644246507$ PUBLIC UNDO1 ONLINE
12 _SYSSMU12_3785212808$ PUBLIC UNDO1 ONLINE
13 _SYSSMU13_1156647635$ PUBLIC UNDO1 ONLINE
14 _SYSSMU14_4080438239$ PUBLIC UNDO1 ONLINE
15 _SYSSMU15_2515553540$ PUBLIC UNDO1 ONLINE
16 _SYSSMU16_1863078453$ PUBLIC UNDO1 ONLINE
17 _SYSSMU17_1908207187$ PUBLIC UNDO1 ONLINE
18 _SYSSMU18_1387739918$ PUBLIC UNDO1 ONLINE
19 _SYSSMU19_2376516152$ PUBLIC UNDO1 ONLINE
20 _SYSSMU20_1948499560$ PUBLIC UNDO1 ONLINE
11 rows selected.
'Backup > Noarchive Log Mode' 카테고리의 다른 글
backup file에 redo log file(옵션 파일)이 없을 경우 (1) | 2024.01.11 |
---|---|
데이터 이관 작업 전 상태로 원상 복구 (0) | 2024.01.11 |
SYSTEM TABLESPACE 속한 데이터 파일이 손상되었을 경우(backup 이후에 REDO 가 없을 경우) (0) | 2024.01.11 |
모든 data file, redo log file, control file이 있는 디스크 손상되었을 경우 (0) | 2024.01.10 |
SYSTEM TABLESPACE에 속한 데이터 파일 손상되었을 경우 (backup 이후에 REDO 가 있을 경우) (0) | 2024.01.10 |