Home > Database > Mysql Tutorial > body text

归档模式关闭数据库的恢复

WBOY
Release: 2016-06-07 15:23:45
Original
1125 people have browsed it

欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入 一。非归档模式关闭数据库的恢复 1.shutdown immediate; 关闭数据库 2.使用操作系统命令拷贝最新的备份(数据文件和控制文件,如果备份了日志文件) 3.进行不完全恢复recover database until cancel

欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入

    一。非归档模式关闭数据库的恢复

    1.shutdown immediate; 关闭数据库

    2.使用操作系统命令拷贝最新的备份(数据文件和控制文件,如果备份了日志文件)

    3.进行不完全恢复recover database  until cancel using backup;

    4.重置日志打开数据库alter database open resetlogs;

    二。数据文件离线或者表空间离线的恢复

    SQL> create table t1 tablespace tbs_sf as select * from dba_objects;   --创建测试表到指定表空间

    SQL> select file_id,file_name from dba_data_files where TABLESPACE_NAME='TBS_SF'; --可以看到数据文件时26号

    FILE_ID FILE_NAME

    ---------- --------------------------------------------------

    26 /database/oradata/skyread/sf01.dbf

    SQL> alter database datafile 26 offline drop; --数据文件脱机,这里是模拟故障,恢复的时候相当于从备份拷贝一个新文件回来

    Database altered.

    SQL> select count(*) from t1; --可见无法查看该表空间的表

    select count(*) from t1

    *

    ERROR at line 1:

    ORA-00376: file 26 cannot be read at this time

    ORA-01110: data file 26: '/database/oradata/skyread/sf01.dbf'

    SQL> select hxfil file_id,fhsta status,fhscn scn,fhrba_seq seq from x$kcvfh where hxfil=26;

    FILE_ID     STATUS SCN                     SEQ

    ---------- ---------- ---------------- ----------

    26          4 122693804311              2

    SQL> select GROUP#,BYTES,ARCHIVED,STATUS,SEQUENCE# from v$log; --可见红色的日志没有被覆盖,可以进行恢复

    GROUP#      BYTES ARC STATUS            SEQUENCE#

    ---------- ---------- --- ---------------- ----------

    1  536870912 YES INACTIVE                  1

    2  536870912 NO  CURRENT                   2

    3  536870912 YES UNUSED                    0

    4  536870912 YES UNUSED                    0

    5  536870912 YES UNUSED                    0

    SQL> recover datafile  26; --进行恢复

    Media recovery complete.

    SQL> alter database datafile 26 online;

    Database altered.

    SQL> select count(*) from t1;

    COUNT(*)

    ----------

    50483

[1] [2] 

归档模式关闭数据库的恢复

source:php.cn
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!