`

redo log 相关操作学习

阅读更多

1.Creating Redo Log Groups and Members

1.1.Creating Redo Log Groups

ALTER DATABASE 
  ADD LOGFILE GROUP 10 ('/oracle/dbs/log1c.rdo', '/oracle/dbs/log2c.rdo')
      SIZE 500K;

1.2.Creating Redo Log Members

ALTER DATABASE ADD LOGFILE MEMBER '/oracle/dbs/log2b.rdo' TO GROUP 2;

2.Relocating and Renaming Redo Log Members

2.1.Steps for Renaming Redo Log Members 

  1. Shut down the database.

    SHUTDOWN
  2. Copy the redo log files to the new location.

    The following example uses operating system commands (UNIX) to move the redo log members to a new location:

    mv /diska/logs/log1a.rdo /diskc/logs/log1c.rdo
    mv /diska/logs/log2a.rdo /diskc/logs/log2c.rdo
  3. Startup the database, mount, but do not open it.

    CONNECT / as SYSDBA
    STARTUP MOUNT
  4. Rename the redo log members.

    Use the ALTER DATABASE statement with the RENAME FILE clause to rename the database redo log files.

    ALTER DATABASE 
      RENAME FILE '/diska/logs/log1a.rdo', '/diska/logs/log2a.rdo' 
               TO '/diskc/logs/log1c.rdo', '/diskc/logs/log2c.rdo';
  5. Open the database for normal operation.

    The redo log alterations take effect when the database is opened.

    ALTER DATABASE OPEN; 

3.Dropping Redo Log Groups and Members

3.1.Dropping Log Groups

To drop a redo log group, you must have the ALTER DATABASE system privilege. Before dropping a redo log group, consider the following restrictions and precautions:

  • An instance requires at least two groups of redo log files, regardless of the number of members in the groups. (A group comprises one or more members.)

  • You can drop a redo log group only if it is inactive. If you need to drop the current group, first force a log switch to occur.

  • Make sure a redo log group is archived (if archiving is enabled) before dropping it. To see whether this has happened, use the V$LOG view.

    SELECT GROUP#, ARCHIVED, STATUS FROM V$LOG;
    
       GROUP# ARC STATUS
    --------- --- ----------------
            1 YES ACTIVE
            2 NO  CURRENT
            3 YES INACTIVE
            4 YES INACTIVE

Drop a redo log group with the SQL statement ALTER DATABASE with the DROP LOGFILE clause.

The following statement drops redo log group number 3:

   

  ALTER DATABASE DROP LOGFILE GROUP 3;

3.2.Dropping Redo Log Members

ALTER DATABASE DROP LOGFILE MEMBER '/oracle/dbs/log3c.rdo';


4.Forcing Log Switches

To force a log switch, you must have the ALTER SYSTEM privilege. Use the ALTER SYSTEM statement with the SWITCH LOGFILE clause.

The following statement forces a log switch:

ALTER SYSTEM SWITCH LOGFILE; 

5.Verifying Blocks in Redo Log Files

If you set the initialization parameter DB_BLOCK_CHECKSUM to TRUE, the database computes a checksum for each database block when it is written to disk, including each redo log block as it is being written to the current log. The checksum is stored the header of the block.

6.Clearing a Redo Log File

A redo log file might become corrupted while the database is open, and ultimately stop database activity because archiving cannot continue. In this situation the ALTER DATABASE CLEAR LOGFILE statement can be used to reinitialize the file without shutting down the database.

The following statement clears the log files in redo log group number 3:

ALTER DATABASE CLEAR LOGFILE GROUP 3;

This statement overcomes two situations where dropping redo logs is not possible:

  • If there are only two log groups

  • The corrupt redo log file belongs to the current group

If the corrupt redo log file has not been archived, use the UNARCHIVED keyword in the statement.

ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 3;

This statement clears the corrupted redo logs and avoids archiving them. The cleared redo logs are available for use even though they were not archived.

If you clear a log file that is needed for recovery of a backup, then you can no longer recover from that backup. The database writes a message in the alert log describing the backups from which you cannot recover.

If you want to clear an unarchived redo log that is needed to bring an offline tablespace online, use the UNRECOVERABLE DATAFILE clause in the ALTER DATABASE CLEAR LOGFILE statement.

If you clear a redo log needed to bring an offline tablespace online, you will not be able to bring the tablespace online again. You will have to drop the tablespace or perform an incomplete recovery. Note that tablespaces taken offline normal do not require recovery.

 

分享到:
评论

相关推荐

    py_innodb_page_info工具

    `py_innodb_page_info`能帮助我们查看redo log的内容,理解这些日志如何与数据页关联,如何在事务提交或回滚时执行操作。 另一方面,undo log(回滚日志)则用于回滚事务和提供隔离级别。它记录了对数据的原始状态...

    Archive Log 学习笔记 --oracle 数据库

    - 归档日志切换:当redo log group切换时,会自动触发归档操作,也可以手动通过`ALTER SYSTEM ARCHIVE LOG CURRENT`命令进行。 4. **归档日志和RMAN备份**: - RMAN(Recovery Manager)是Oracle提供的备份和恢复...

    redo与undo_a.pdf11

    在Oracle数据库系统中,redo日志由一系列的redo log files组成,这些文件包含了一系列的redo entries,每个entry都对应一个特定的事务操作。 undo,又称回滚日志(Undo Log),则记录了事务对数据的原始状态,即在...

    Exadata X5 Administration(1z0-070).docx

    redo log 是关系数据库中最 critical 的组件之一,它记录了所有数据库的事务操作,以便在系统崩溃或故障时恢复数据库。Exadata Smart Flash Log 使用 flash 存储器来加速 redo log 的写入,使得数据库的整体性能得到...

    MySQL的日志基础知识及基本操作学习教程

    相关配置如`innodb_flush_log_at_trx_commit`控制何时将redo log写入磁盘,以确保数据一致性。 5. 二进制日志(Binary Log) 二进制日志记录了所有改变数据库状态的非临时性语句,以及服务器状态的改变,主要用于...

    oracle常用命令

    `ALTER DATABASE RENAME FILE`用于改变日志文件的路径或名称,例如:`ALTER DATABASE RENAME FILE 'c:/oracle/oradata/oradb/redo01.log' TO 'c:/oracle/oradata/redo01.log';` 6. **删除在线重做日志组(Dropping...

    pl/sql学习文档

    5. **Changing the name of the online redo log file** - `ALTER DATABASE RENAME FILE 'old_path' TO 'new_path';`:更改在线重做日志文件的路径或名称,适用于日志文件迁移场景。 6. **Dropping online redo ...

    从 0 开始带你成为MySQL实战优化高手

    非也,揭秘redo log buffer.pdf”和“44 redo log buffer中的缓冲日志,到底什么时候可以写入磁盘?l.pdf”中,你将深入理解redo log的工作原理和写入时机。 数据库优化不仅限于SQL语句,还涉及到存储和硬件层面。...

    数据库日志操作相关信息

    - **重做日志(Redo Log)**:记录事务的修改操作,用于在系统崩溃后重新执行这些操作以恢复数据。 - **回滚日志(Undo Log)**:记录事务的撤销操作,用于回滚未提交的事务。 - **归档日志(Archive Log)**:在...

    最牛逼的Oracle11gOCP学习笔记

    共享池用来缓存最近执行过的SQL语句和数据定义,而Redo Log Buffer负责在数据库进行修改时记录这些修改,以备恢复使用。 Oracle数据库包括数据文件、控制文件和Redo Log文件。数据文件存放用户的数据;控制文件包含...

    SQL log explore工具软件

    Oracle LogMiner是Oracle数据库提供的一种内置工具,它允许用户分析redo log文件,从中提取SQL语句、DML操作和事务信息。通过LogMiner,DBA可以回顾历史操作,追踪错误,进行性能调优,以及满足合规性的审计需求。...

    mysql学习.docx

    4. **InnoDB的redo log**:更新记录首先写入redo log,然后更新内存。redo log是固定大小,循环写入,提供crash-safe能力,保证即使数据库重启,已提交的记录也不会丢失。 5. **binlog**:MySQL Server层的日志,...

    Oracle Database 10gR2 Data Guard操作手册

    参考资料则包括了相关文档和技术资料,为深入学习提供路径。 2. 需求概述 总体目标是建立一个Physical Standby Database,它与Primary Database实时同步,能够在主数据库出现故障时立即接管服务。运行环境包括硬件...

    WIN平台单机搭建oracle dg 实验与总结

    在 primary 侧,我们需要生成 standby redolog,以便在复制库上应用redo日志。可以使用以下命令来生成 standby redolog: ```sql ALTER DATABASE ADD STANDBY LOGFILE 'D:\ORACLE\ORADATA\DG1\ONLINELOG\redo05.log'...

    oracle11g OCM 题库_第三场

    315 HIGH OPEN 06-OCT-15 Redolog file /u01/app/oracle/oradata/PROD2/redo03.log is missing 204 HIGH OPEN 06-OCT-15 Redolog file /u01/app/oracle/oradata/PROD2/redo03.log is corrupt 121 HIGH OPEN 05-OCT-...

    Oracle常用命令

    通过以上详细介绍,我们不仅了解了Oracle数据库中一系列关键的管理命令,还深入学习了日志管理和表空间管理的核心概念与操作流程。这些知识对于任何希望深化理解Oracle数据库运维和优化的专业人士来说,都是不可或缺...

    Oracle基础培训.pptx

    总结来说,Oracle基础培训旨在让学习者掌握Oracle数据库的基本架构和操作,包括其内存和进程的管理,物理存储的组织,以及如何进行有效的数据库管理和性能优化。通过深入理解这些概念,能更好地管理和维护Oracle...

    oracle操作日志

    1. Redo Logs:Oracle的Redo Log File系统由一组成员文件组成,它们以循环方式记录事务操作。当一个事务提交时,其更改的数据被写入redo log,如果系统发生故障,通过redo logs可以恢复未持久化的数据。 2. Alert ...

Global site tag (gtag.js) - Google Analytics