Home Database Mysql Tutorial 探索Oracle不完全恢复之--基于cancel的恢复 第二篇

探索Oracle不完全恢复之--基于cancel的恢复 第二篇

Jun 07, 2016 pm 05:17 PM

探索Oracle不完全恢复之--基于cancel的恢复 第二篇

基于cancel 的不一致性恢复(归档丢失) 第二篇

 

创建测试表

SQL> conn wwl/wwl

Connected.

 

SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID

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

WWL001                         TABLE

 

SQL> create table WWL002 as select *from wwl001;

Table created.

 

SQL> conn / as sysdba

Connected.

 

切换日志

SQL> alter system switch logfile;

System altered.

 

后再创建第二张表

SQL> conn wwl/wwl

Connected.

 

SQL> create table wwl003 as select *from wwl001;

Table created.

 

查看当前日志组,,确定当前活动的日志组,是组4

SQL> conn / as sysdba

Connected.

SQL> set line 200

SQL> select * from v$log;

 

   GROUP#    THREAD#  SEQUENCE#     BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM

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

         4          1          2 134217728          2 YES ACTIVE                 1716929 30-JUL-12

        5          1          1 134217728          2 YES INACTIVE               1692728 27-JUL-12

        6          1          3 134217728          2 NO  CURRENT                1720396 30-JUL-12

        7          1          0 134217728          2 YES UNUSED                       0

 

定位当前日志组的日志文件,有两个。

 SQL> col member format a30

SQL> select * from v$logfile;

 

   GROUP# STATUS  TYPE    MEMBER                         IS_

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

        7         ONLINE  /DBBak2/oradata/WWL/redo7a.log NO

        7         ONLINE  /DBBak2/oradata/WWL/redo7b.log NO

        6         ONLINE  /DBBak2/oradata/WWL/redo6a.log NO

        6         ONLINE  /DBBak2/oradata/WWL/redo6b.log NO

        5 STALE   ONLINE  /DBBak2/oradata/WWL/redo5a.log NO

        5 STALE   ONLINE  /DBBak2/oradata/WWL/redo5b.log NO

         4         ONLINE /DBBak2/oradata/WWL/redo4a.log NO

         4         ONLINE /DBBak2/oradata/WWL/redo4b.log NO

 

8 rows selected.

 

删除当前日志组文件,模拟在线事务丢失:

SQL> !rm -f/DBBak2/oradata/WWL/redo4a.log

SQL> !rm -f/DBBak2/oradata/WWL/redo4b.log

 

模拟服务器断电

SQL> shutdown abort;

Oracle instance shut down.

 

恢复步骤:

1、尝试启动数据库的时候报当前日志丢失。

SQL> startup

ORACLE instance started.

 

Total System Global Area  100663296 bytes

Fixed Size                  1217884 bytes

Variable Size              88083108 bytes

Database Buffers            8388608 bytes

Redo Buffers                2973696 bytes

Database mounted.

ORA-00313: open failedfor members of log group 4 of thread 1

ORA-00312: online log 4thread 1: '/DBBak2/oradata/WWL/redo4b.log'

ORA-27037: unable toobtain file status

Linux Error: 2: No suchfile or directory

Additional information: 3

ORA-00312: online log 4thread 1: '/DBBak2/oradata/WWL/redo4a.log'

ORA-27037: unable toobtain file status

Linux Error: 2: No suchfile or directory

Additional information: 3

 

2、尝试Clear redo4

SQL> alter database clear logfile group4;

alter database clear logfile group 4

*

ERROR at line 1:

ORA-01624: log 4 needed for crash recoveryof instance WWL (thread 1)

ORA-00312: online log 4 thread 1:'/DBBak2/oradata/WWL/redo4a.log'

ORA-00312: online log 4 thread 1:'/DBBak2/oradata/WWL/redo4b.log'

 

3、在当前库做基于Cancel的不完全恢复

SQL> recover database until cancel;

ORA-00279: change 1716930 generated at07/30/2012 11:03:51 needed for thread 1

ORA-00289: suggestion :/DBSoft/product/10.2.0/db_1/dbs/arch1_2_789761098.dbf

ORA-00280: change 1716930 for thread 1 isin sequence #2

 

 

Specify log: {=suggested |filename | AUTO | CANCEL}

auto

ORA-00279: change 1720396 generated at07/30/2012 13:37:21 needed for thread 1

ORA-00289: suggestion :/DBSoft/product/10.2.0/db_1/dbs/arch1_3_789761098.dbf

ORA-00280: change 1720396 for thread 1 isin sequence #3

ORA-00278: log file'/DBSoft/product/10.2.0/db_1/dbs/arch1_2_789761098.dbf' no longer needed forthis recovery

 

 

ORA-00308: cannot open archived log'/DBSoft/product/10.2.0/db_1/dbs/arch1_3_789761098.dbf'

ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory

Additional information: 3

 

 

ORA-01547: warning: RECOVER succeeded butOPEN RESETLOGS would get error below

ORA-01194: file 1 needs more recovery to beconsistent

ORA-01110: data file 1:'/DBBak2/oradata/WWL/system01.dbf'

 

做完恢复之后必须使用resetlogs选项打开数据库:

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-01194: file 1 needs more recovery to beconsistent

ORA-01110: data file 1:'/DBBak2/oradata/WWL/system01.dbf'

 

 

 

重建下控制文件:

SQL> CREATE CONTROLFILE REUSE DATABASE"WWL" RESETLOGS  ARCHIVELOG

   MAXLOGFILES 16

   MAXLOGMEMBERS 3

   '/DBBak2/oradata/WWL/redo4a.log',

   MAXDATAFILES 100

   MAXINSTANCES 8

 GROUP 5 (

   MAXLOGHISTORY 292

LOGFILE

 GROUP 4 (

   '/DBBak2/oradata/WWL/redo4a.log',

   '/DBBak2/oradata/WWL/redo4b.log'

 GROUP 6 (

  )SIZE 128M,

 GROUP 5 (

   '/DBBak2/oradata/WWL/redo5a.log',

   '/DBBak2/oradata/WWL/redo5b.log'

   '/DBBak2/oradata/WWL/redo7b.log'

  )SIZE 128M,

 GROUP 6 (

   '/DBBak2/oradata/WWL/redo6a.log',

   '/DBBak2/oradata/WWL/redo6b.log'

  )SIZE 128M,

 GROUP 7 (

   '/DBBak2/oradata/WWL/redo7a.log',

   '/DBBak2/oradata/WWL/redo7b.log'

  )SIZE 128M

-- STANDBY LOGFILE

DATAFILE

 '/DBBak2/oradata/WWL/system01.dbf',

 '/DBBak2/oradata/WWL/undotbs01.dbf',

 '/DBBak2/oradata/WWL/sysaux01.dbf',

 '/DBBak2/oradata/WWL/users01.dbf',

 '/DBBak2/oradata/WWL/wwl001',

 '/DBBak2/oradata/WWL/wwl002',

 '/DBBak2/oradata/WWL/wwl003'

CHARACTER SET ZHS16CGB231280

 34  ;

 

Control file created.

 

再次打开,结果还是不行

SQL> alter database open resetlogs;

alter database open resetlogs

*

ERROR at line 1:

ORA-01194: file 1 needs more recovery to beconsistent

ORA-01110: data file 1:'/DBBak2/oradata/WWL/system01.dbf'

 

可以尝试使用_allow_resetlogs_corruption隐含参数来打开数据库

SQL> alter system set"_allow_resetlogs_corruption"=true scope=spfile;

System altered.

 

修改完参数之后重启数据库到mount状态

SQL> shutdown immediate

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

 

SQL> startup;

ORACLE instance started.

 

Total System Global Area  100663296 bytes

Fixed Size                  1217884 bytes

Variable Size              88083108 bytes

Database Buffers            8388608 bytes

Redo Buffers                2973696 bytes

Database mounted.

ORA-01589: must use RESETLOGS orNORESETLOGS option for database open

 

同样以resetlogs模式启动数据库

SQL> alter database open resetlogs;

Database altered.

 

一定记得关闭该参数

SQL> alter system set"_allow_resetlogs_corruption"=FALSE scope=spfile;

System altered.

 

让参数关闭生效,再次启动数据库

SQL> startup force;

ORACLE instance started.

 

Total System Global Area  100663296 bytes

Fixed Size                  1217884 bytes

Variable Size              88083108 bytes

Database Buffers            8388608 bytes

Redo Buffers                2973696 bytes

Database mounted.

Database opened.

 

SQL> show parameter_allow_resetlogs_corruption

NAME                                 TYPE        VALUE

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

_allow_resetlogs_corruption          boolean     FALSE

SQL>

 

SQL> ALTER TABLESPACE TEMP01 ADDTEMPFILE '/DBBak2/oradata/WWL/temp01.dbf' REUSE;

Tablespace altered.

 

检查数据

SQL> conn wwl/wwl

Connected.

 

 

SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID

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

WWL001                         TABLE

WWL002                         TABLE

 

相关阅读:

探索Oracle之RMAN_01概念

探索Oracle之RMAN_02基本使用

探索Oracle之RMAN_03非一致性备份

探索Oracle之RMAN_04非一致性备份

探索Oracle之RMAN_05增量备份

探索Oracle之RMAN_06备份策略

探索Oracle之RMAN_07单个数据文件丢失恢复

探索Oracle之RMAN_07整个业务表空间丢失恢复

探索Oracle之RMAN_07 磁盘损坏数据丢失恢复

探索Oracle之RMAN_07 数据库所有文件全部丢失恢复

探索Oracle之RMAN_07 重做日志redu文件丢失恢复

探索Oracle之RMAN_07 参数文件丢失恢复

探索Oracle之RMAN_07控制文件丢失恢复

探索Oracle之RMAN_07 system表空间丢失恢复

linux

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1268
29
C# Tutorial
1243
24
MySQL: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

MySQL's Role: Databases in Web Applications MySQL's Role: Databases in Web Applications Apr 17, 2025 am 12:23 AM

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

Explain the role of InnoDB redo logs and undo logs. Explain the role of InnoDB redo logs and undo logs. Apr 15, 2025 am 12:16 AM

InnoDB uses redologs and undologs to ensure data consistency and reliability. 1.redologs record data page modification to ensure crash recovery and transaction persistence. 2.undologs records the original data value and supports transaction rollback and MVCC.

MySQL: An Introduction to the World's Most Popular Database MySQL: An Introduction to the World's Most Popular Database Apr 12, 2025 am 12:18 AM

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

MySQL's Place: Databases and Programming MySQL's Place: Databases and Programming Apr 13, 2025 am 12:18 AM

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

Why Use MySQL? Benefits and Advantages Why Use MySQL? Benefits and Advantages Apr 12, 2025 am 12:17 AM

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

MySQL vs. Other Programming Languages: A Comparison MySQL vs. Other Programming Languages: A Comparison Apr 19, 2025 am 12:22 AM

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages ​​such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages ​​have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

How does MySQL index cardinality affect query performance? How does MySQL index cardinality affect query performance? Apr 14, 2025 am 12:18 AM

MySQL index cardinality has a significant impact on query performance: 1. High cardinality index can more effectively narrow the data range and improve query efficiency; 2. Low cardinality index may lead to full table scanning and reduce query performance; 3. In joint index, high cardinality sequences should be placed in front to optimize query.

See all articles