联机日志损坏时的恢复(正常关闭数据库)
联机日志损坏时的恢复(正常关闭数据库),创建一个表T2插入两行数据,第一行数据写如果归档日志,第二行数据在联机日志中。
1.创建一个表T2插入两行数据,第一行数据写如果归档日志,第二行数据在联机日志中
SQL> create table t2(
a1 number(10),
a2 char(10)) tablespace users;
SQL> insert into t2 values (11,'aa');
SQL> commit;
SQL> alter system switch logfile;
SQL> insert into t2 values(22,'bb');
SQL> commit;
2.查询日志文件
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/database/ykg/ykg1a.log
/database/ykg/ykg2a.log
3.正常关闭数据库
SQL> shutdown immediate
Database closed.
Database dismounted.
Oracle instance shut down.
4.模拟联机日志文件损坏
SQL> host rm -rf /database/ykg/ykg*.log
5.正常启动数据库报错
SQL> startup
ORACLE instance started.
Total System Global Area 293601280 bytes
Fixed Size 2020392 bytes
Variable Size 92277720 bytes
Database Buffers 197132288 bytes
Redo Buffers 2170880 bytes
Database mounted.
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: '/database/ykg/ykg1a.log'
6.查看当前联机日志的SEQUENCE号
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 191
Next log sequence to archive 192
Current log sequence 192
7.假装执行不完全恢复来恢复日志组
RMAN> run {
2> recover database until sequence 193 thread 1;
3> alter database open resetlogs;}
8.验证日志成员已恢复,数据没有丢失
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/database/ykg/ykg1a.log
/database/ykg/ykg2a.log
上一篇: MySQL数据库的索引原理