Home > Database > Mysql Tutorial > 联机日志损坏时的恢复(正常关闭数据库)

联机日志损坏时的恢复(正常关闭数据库)

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:16:39
Original
934 people have browsed it

联机日志损坏时的恢复(正常关闭数据库),创建一个表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

linux

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template