search
HomeDatabaseMysql TutorialOracle控制文件的备份、恢复以及多路复用

给大家带来有关Oracle控制文件的技术分享。控制文件的作用我想就毋庸赘言了吧?上至九十老妪,下到五岁孩童,对于控制文件的重要

前言 

    今天给大家带来有关Oracle控制文件的技术分享。不积跬步无以至千里,不积小流无以成江海。Oracle技术博大精深,,以我一个人的力量,那无异于蜉蝣于天地,沧海之一粟。在此,笔者抛砖引玉,希望读者能够与我形成良好的互动,之间共同进步。闲言少叙,书归正传,马上开始今天的讨论话题。

Oracle 备份恢复概念 
 
一、控制文件概要描述
      既然今天的主题是控制文件,那么首先我先带大家来简要回顾一下控制文件的相关知识点。控制文件在默认情况下,一般和数据文件以及日志文件等位于同一个目录(当然,不放在这里也是没有问题的……看个人喜好),具体查看的sql语句是:
      SYS@ENMOEDU > select name from v$controlfile;
     
      NAME
      ------------------------------
      /u01/app/oracle/oradata/ENMOEDU/control01.ctl
      /u01/app/oracle/fast_recovery_area/ENMOEDU/control02.ctl
      从这里就已经清晰的看到我控制文件的路径以及名称了,还有,细心的读者应该发现了,我是一个很小心谨慎的人,所以呢,我的控制文件是两份。这样做的好处是,万一我其中的一个控制文件被误删了或者损坏了,我还有另外一个控制文件保证我数据库的正常运行以及启动(不小心把多路复用技术给提前引入了……稍后会有更详细的配置以及解析)。
      控制文件的作用我想就毋庸赘言了吧?上至九十老妪,下到五岁孩童,对于控制文件的重要性都能如数家珍般的娓娓道来。控制文件中有数据库以及在线重做日志的位置以及众多重要的信息,丢失或者损坏控制文件,数据库将无法正常启动和运行。既然控制文件这么重要,那么我们该怎么对它进行备份和恢复呢?
 
二、控制文件的备份与恢复
      (1)基于用户管理的备份和恢复
     
      首先进入Oracle的trace目录
      [oracle@ENMOEDU trace]$ cd /u01/app/oracle/diag/rdbms/enmoedu/ENMOEDU/trace
     
      用tail命令来打开alert_ENMOEDU.log文件
      [oracle@ENMOEDU trace]$ tail -100f alert_ENMOEDU.log
     
      此时打开另一窗口,执行如下命令
      SYS@ENMOEDU > alter database backup controlfile to trace;
      Database altered.
     
      我们可以在alert.ENMOEDU.log看到如下信息
      Mon Mar 10 15:22:20 2014
      alter database backup controlfile to trace
      Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/enmoedu/ENMOEDU/trace/ENMOEDU_ora_18205.trc
      Completed: alter database backup controlfile to trace
     
      根据上述信息,我们去查看提示的文件
      [oracle@ENMOEDU ~]$ cat /u01/app/oracle/diag/rdbms/enmoedu/ENMOEDU/trace/ENMOEDU_ora_18205.trc
     
      在浩如烟海的信息中,我们可以找到创建控制文件的命令
      CREATE CONTROLFILE REUSE DATABASE "ENMOEDU" RESETLOGS  ARCHIVELOG
              MAXLOGFILES 16
              MAXLOGMEMBERS 3
              MAXDATAFILES 100
              MAXINSTANCES 8
              MAXLOGHISTORY 292
        LOGFILE
            GROUP 1 '/u01/app/oracle/oradata/ENMOEDU/redo01.log'  SIZE 50M BLOCKSIZE 512,
            GROUP 2 '/u01/app/oracle/oradata/ENMOEDU/redo02.log'  SIZE 50M BLOCKSIZE 512,
            GROUP 3 '/u01/app/oracle/oradata/ENMOEDU/redo03.log'  SIZE 50M BLOCKSIZE 512
        -- STANDBY LOGFILE
        DATAFILE
            '/u01/app/oracle/oradata/ENMOEDU/system01.dbf',
            '/u01/app/oracle/oradata/ENMOEDU/sysaux01.dbf',
            '/u01/app/oracle/oradata/ENMOEDU/undotbs01.dbf',
            '/u01/app/oracle/oradata/ENMOEDU/users01.dbf',
            '/u01/app/oracle/oradata/ENMOEDU/example01.dbf',
            '/u01/app/oracle/oradata/ENMOEDU/test01.dbf',
            '/u01/app/oracle/oradata/ENMOEDU/test02.dbf'
        CHARACTER SET AL32UTF8;
     
      稍后我们就可以用这些命令来创建控制文件了。下面来模拟控制文件丢失和损坏的实验环境:
      [root@ENMOEDU ~]# rm -rf /u01/app/oracle/oradata/ENMOEDU/control01.ctl
      [root@ENMOEDU ~]# rm -rf /u01/app/oracle/fast_recovery_area/ENMOEDU/control02.ctl
     
      笔者将两个控制文件都删除了,很彻底~然后尝试启动数据库。
      [oracle@ENMOEDU ~]$ sqlplus / as sysdba
        SQL*Plus: Release 11.2.0.3.0 Production on Mon Mar 10 15:47:54 2014
        Copyright (c) 1982, 2011, Oracle.  All rights reserved.
        Connected to an idle instance.
        SYS@ENMOEDU > startup
        ORACLE instance started.
 
      Total System Global Area  422670336 bytes
        Fixed Size                  1345380 bytes
        Variable Size            352323740 bytes
        Database Buffers          62914560 bytes
        Redo Buffers                6086656 bytes
        ORA-00205: error in identifying control file, check alert log for more info
       
        可以看出,数据库已经无法正常启动了。那么我们就将数据库启动到nomount状态下进行恢复。
        SYS@ENMOEDU > shutdown abort
        ORACLE instance shut down.
        SYS@ENMOEDU > startup nomount
        ORACLE instance started.
 
      Total System Global Area  422670336 bytes
        Fixed Size                  1345380 bytes
        Variable Size            352323740 bytes
        Database Buffers          62914560 bytes
        Redo Buffers                6086656 bytes
      SYS@ENMOEDU > CREATE CONTROLFILE REUSE DATABASE "ENMOEDU" RESETLOGS  ARCHIVELOG
          2                MAXLOGFILES 16
          3                MAXLOGMEMBERS 3
          4                MAXDATAFILES 100
          5                MAXINSTANCES 8
          6                MAXLOGHISTORY 292
          7        LOGFILE
          8            GROUP 1 '/u01/app/oracle/oradata/ENMOEDU/redo01.log'  SIZE 50M BLOCKSIZE 512,
          9            GROUP 2 '/u01/app/oracle/oradata/ENMOEDU/redo02.log'  SIZE 50M BLOCKSIZE 512,
          10            GROUP 3 '/u01/app/oracle/oradata/ENMOEDU/redo03.log'  SIZE 50M BLOCKSIZE 512
          11        -- STANDBY LOGFILE
          12        DATAFILE
          13              '/u01/app/oracle/oradata/ENMOEDU/system01.dbf',
          14              '/u01/app/oracle/oradata/ENMOEDU/sysaux01.dbf',
          15              '/u01/app/oracle/oradata/ENMOEDU/undotbs01.dbf',
          16              '/u01/app/oracle/oradata/ENMOEDU/users01.dbf',
          17              '/u01/app/oracle/oradata/ENMOEDU/example01.dbf',
          18              '/u01/app/oracle/oradata/ENMOEDU/test01.dbf',
          19              '/u01/app/oracle/oradata/ENMOEDU/test02.dbf'
          20        CHARACTER SET AL32UTF8;
 
      Control file created.
       
      尝试开启数据库
        SYS@ENMOEDU > alter database open
          2  ;
        alter database open
        *
        ERROR at line 1:
        ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

Statement
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
Explain the InnoDB Buffer Pool and its importance for performance.Explain the InnoDB Buffer Pool and its importance for performance.Apr 19, 2025 am 12:24 AM

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

MySQL vs. Other Programming Languages: A ComparisonMySQL vs. Other Programming Languages: A ComparisonApr 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.

Learning MySQL: A Step-by-Step Guide for New UsersLearning MySQL: A Step-by-Step Guide for New UsersApr 19, 2025 am 12:19 AM

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL: Essential Skills for Beginners to MasterMySQL: Essential Skills for Beginners to MasterApr 18, 2025 am 12:24 AM

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL: Structured Data and Relational DatabasesMySQL: Structured Data and Relational DatabasesApr 18, 2025 am 12:22 AM

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL: Key Features and Capabilities ExplainedMySQL: Key Features and Capabilities ExplainedApr 18, 2025 am 12:17 AM

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

The Purpose of SQL: Interacting with MySQL DatabasesThe Purpose of SQL: Interacting with MySQL DatabasesApr 18, 2025 am 12:12 AM

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

MySQL for Beginners: Getting Started with Database ManagementMySQL for Beginners: Getting Started with Database ManagementApr 18, 2025 am 12:10 AM

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

See all articles

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

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software