oracle备份与恢复
LOG_CHECKPOINT_INTERVAL LOG_CHECKPOINT_TIMEOUT
如何改变联机日志文件的位置
1. 2. 3. 4. 5. 关闭数据库. 将联机日志文件拷贝到新位置. 将数据库启动到挂接状态(mount). 执行 ALTER DATABASE RENAME FILE 命令. 打开数据库.
Data Buffer Cache Large Pool Redo Log Buffer
Shared Pool Shared SQL & PLSQL Data Dict. Cache LGWR ARCH
SMON DBWR PMON CKPT
1 Offline Data File 2 2 Restore Data File 2
log1a.rdo
log1b.rdo
log2a.rdo
log2b.rdo
Group 1
Group 2
删除联机日志组
ALTER DATABASE DROP LOGFILE GROUP 3;
log1a.rdo log1b.rdo
log2a.rdo log2b.rdo
log3a.rdo log3b.rdo
备份的模式
Closed database Open database
No archive Mode
Archive Mode Physical backup
归档方式配置
Online redo log files
Group 1 Group 2
Archived log file ARCH
052 /archive/arch052.arc
144 145
Redo log File 2
144 146
Datame the file or directory location:
SVRMGR> connect system/manager as sysdba; Connected. SVRMGR> startup mount pfile=initDB00.ora; Oracle instance started. SVRMGR> alter database rename file 2> ‘/disk1/data/user_01.dbf` 3> ‘/disk2/data/user_01.dbf`; Statement Processed. SVRMGR> alter database open;
Group 1
Group 2
Group 3
删除联机日志成员
ALTER DATABASE DROP LOGFILE MEMBER ‘/data1/oracle8/oradata/log1b.log’;
log1a.rdo log1b.rdo log2a.rdo log2b.rdo
Group 1
Group 2
Oracle数据库备份与恢复 数据库备份与恢复
主要内容
1.有关联机日志文件的一些操作 2.不使用Oracle Recovery Manager 的物理备份 3.非归档方式下的恢复 4.归档方式下的完全恢复 5.归档方式下的不完全恢复 6. 逻辑备份--Oracle Export and Import 实用工具
打开数据库备份选项
All tablespace datafiles Tablespace USER_DATA user01.dbf user02.dbf Individual datafile Tablespace USER_DATA user01.dbf user02.dbf
备份状态信息
数据字典: 数据字典
Shared Pool Shared SQL & PLSQL Data Dict. Cache LGWR ARCH
SMON DBWR PMON CKPT
1 Mount the database 2 Offline Data File 2 4 Restore Data File 2
SMON DBWR PMON CKPT
4 Open the database
146
2
Data File 1
Mount Instance
146
Control Files
146
Redo log File 1
1 Restore Data File 2
(Log Seq 144)
145 144 146
Parameter File Password File Data File 2
清除联机日志文件
示例
ALTER DATABASE CLEAR LOGFILE ‘/data1/oracle8/oradata/log1b.log’ ;
日志转换(log switches) 和检查点 (checkpoint)
强制日志转换
ALTER SYSTEM SWITCH LOGFILE;
与检查点相关的初始化参数
非归档方式Oracle恢复
非归档方式下的介质失败和恢复
失败
磁盘损坏、数据文件丢失
恢复
恢复所有数据文件、控制文件、日志文件 口令文件和参数文件的恢复是可选的
非归档方式下的恢复
144
Data File 1
144
Control Files
144
Redo log File 1
144
Parameter File Password File Data File 2 Data File 3
(Log Seq 144)
Parameter File Password File
146
Data File 1
146
Control Files
146
Redo log File 1
145 144 146
Data File 2
145
Redo log File 2
3 Apply Log Files
Archived Log File
Online redo logs
3
ARCH
Selectively Archive Log Files
1
ALTER SYSTEM ARCHIVE LOG sequence 052;
051
052
053
Server Process
Online redo logs
051 052
2
归档日志信息
Data dictionary views
3 1
HOST cp <files> /backup/
4
Data files
Log files
Control Password Parameter files file files
STARTUP OPEN;
打开数据库的备份
Control Files Datafiles Parameter Files Password File Online Archived Redo Redo Log Files Log Files
V$BACKUP V$DATAFILE_HEADER
备份控制文件
alter database backup controlfile to ‘/data1/control1.bkp’;
创建二进制映像: Creating a text trace file:
alter database backup controlfile to trace;
143
Redo log File 2
144
Backup
恢复最近一次备份
144 146
Data File 1
144 146
Control Files
144 146
Redo log File 1
144 146
Parameter File Password File Data File 2 Data File 3
完全恢复: 方法 1 (closed database)
User Process Server Process
PGA Data Buffer Locks Cache Data Buffer
Instance SGA
Large Pool Redo Log Buffer
Shared Pool Shared SQL & PLSQL Data Dict. Cache LGWR ARCH
log2b.rdo
log3a.rdo log3b.rdo
Group 1
Group 2
Group 3
增加联机日志成员
ALTER DATABASE ADD LOGFILE MEMBER ‘/data1/oracle8/oradata/log1b.log’ TO GROUP 1, ‘/data1/oracle8/oradata/log1b.log’ TO GROUP 2;
V$ARCHIVED_LOG V$ARCHIVE_DEST V$LOG_HISTORY V$DATABASE
Command line
ARCHIVE LOG LIST;
不使用Recovery Manager的物理备份 不使用Recovery Manager的物理备份
关闭数据库的备份
2
SHUTDOWN IMMEDIATE;
Recover 语法
恢复关闭的数据库: 恢复关闭的数据库:
SVRMGR> recover database; SVRMGR> recover datafile > ‘/disk1/data/df2.dbf`;
恢复打开的数据库: 恢复打开的数据库:
SVRMGR> recover tablespace USER_DATA; SVRMGR> recover datafile 2;