728x90
시나리오
- 온라인 복구 (hot backup)
- 불완전 복구 (리두로그파일이 없을 때)
1. Backup
1.1. 데이터 파일 위치 확인
select name, status from v$datafile;
1.2. 컨트롤 파일 위치 확인
select name from v$controlfile;
1.3. 아카이브로그 모드 확인
SQL> archive log list;
1.4. 아카이브 로그 모드로 전환
SQL> shutdown immediate
SQL> startup mount
SQL> alter database archivelog;
SQL> archive log list;
1.5. 테이블스페이스, 유저 생성
shutdown immediate
startup
conn / as sysdba
create table space [테이블스페이스명] datafile '/[테이블스페이스경로]' size 100M autoextend on next 100M maxsize 1G;
create user [유저명] identified by [유저비밀번호] default tablespace [테이블스페이스명];
생성한 유저에게 권한 부여
grant connect, resource, dba to [유저명];
1.6. 데이터 파일 백업
alter database begin backup;
!cp /home/oracle/oradata/orcl/system01.dbf /backup
!cp /home/oracle/oradata/orcl/sysaux01.dbf /backup
!cp /home/oracle/oradata/orcl/undotbs01.dbf /backup
!cp /home/oracle/oradata/orcl/users01.dbf /backup
!cp /home/oracle/oradata/orcl/ts_test01.dbf /backup
alter databse end backup;
alter database backup controlfile to trace as '/backup/control.sql' reuse RESETLOGS;
1.7. 테이블 생성, 데이터 삽입
sqlplus [유저명]/[유저비밀번호]
create table [테이블명]([컬럼명] [데이터타입(n)]);
insert into [테이블명] values('[데이터]');
commit;
alter system switch logfile;
insert into [테이블명] values('[데이터]');
commit;
alter system switch logfile;
insert into [테이블명] values('[데이터]');
commit;
불완전복구를 테스트 하기 위해 마지막 데이터 삽입 시 로그스위치 생략
1.8. 장애 발생
shutdown
rm /home/oracle/oradata/orcl/*.*
1. Recovery
cp /backp/*.sql
cp /backup/*.dbf
startup nomount
@control.sql
shutdown
startup mount
recover database until time '2024-03-08 19:06:13' using backup controlfile ;
* 시간은 마지막 아카이브 로그 저장 시간으로
alter databse open resetlogs;
shutdown immediate
startup
conn [유저명]/[유저비밀번호]
select * from [테이블명];
'DB > Oracle' 카테고리의 다른 글
[Oracle] 오라클 DB 삭제 deinstall (0) | 2024.03.12 |
---|---|
[Oracle] 리눅스 cent OS 7 에 oracle 11g 설치 (1) | 2024.01.04 |