Home Database Mysql Tutorial oracle Control Files 杂谈

oracle Control Files 杂谈

Jun 07, 2016 pm 03:37 PM
control files oracle

最近在群里,看到很多群友都是控制文件出问题了,所以今天我想说一下Control Files的特性。 Control Files 的特性如下 Control Files是声明在数据库属性文件(SPFILE|PFILE)里面的,每次数据库启动的时候,都会读取第一个控制文件的,但是如果 Control Files有

       最近在群里,看到很多群友都是控制文件出问题了,所以今天我想说一下Control Files的特性。

     Control Files的特性如下

     Control Files是声明在数据库属性文件(SPFILE|PFILE)里面的,每次数据库启动的时候,都会读取第一个控制文件的,但是如果 Control Files有改变的话,会同时写入所有声明的控制文件。如果所有声明的控制文件有一个坏了,那么数据库也mount不了。如果你物理上面删除一个 Control Files文件,数据库可能不会马上报错,只有在数据库需要写入 Control Files文件的时候,才会报错。

[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sat May 31 10:07:29 2014

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show parameter control_files

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_files                        string      /u01/app/oracle/oradata/PROD/c
                                                 ontrol01.ctl, /u01/app/oracle/
                                                 oradata/PROD/control02.ctl
SQL> 
Copy after login
      这里面有2个控制文件,一般都是3个放在不同硬盘上面。

      我们大家都知道,一般数据库之间各个文件之间的SCN号不一致的时候,要恢复的,那么怎么看呢。

oracle Control Files 杂谈

    这张图就说明了,控制文件的SCN号与数据文件SCN不同时候,数据库的反应。去哪里看相应的SCN号呢?

SQL> desc v$datafile;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 FILE#                                              NUMBER
 CREATION_CHANGE#                                   NUMBER
 CREATION_TIME                                      DATE
 TS#                                                NUMBER
 RFILE#                                             NUMBER
 STATUS                                             VARCHAR2(7)
 ENABLED                                            VARCHAR2(10)
 CHECKPOINT_CHANGE#                                 NUMBER
 CHECKPOINT_TIME                                    DATE
 UNRECOVERABLE_CHANGE#                              NUMBER
 UNRECOVERABLE_TIME                                 DATE
 LAST_CHANGE#                                       NUMBER
 LAST_TIME                                          DATE
 OFFLINE_CHANGE#                                    NUMBER
 ONLINE_CHANGE#                                     NUMBER
 ONLINE_TIME                                        DATE
 BYTES                                              NUMBER
 BLOCKS                                             NUMBER
 CREATE_BYTES                                       NUMBER
 BLOCK_SIZE                                         NUMBER
 NAME                                               VARCHAR2(513)
 PLUGGED_IN                                         NUMBER
 BLOCK1_OFFSET                                      NUMBER
 AUX_NAME                                           VARCHAR2(513)
 FIRST_NONLOGGED_SCN                                NUMBER
 FIRST_NONLOGGED_TIME                               DATE
 FOREIGN_DBID                                       NUMBER
 FOREIGN_CREATION_CHANGE#                           NUMBER
 FOREIGN_CREATION_TIME                              DATE
 PLUGGED_READONLY                                   VARCHAR2(3)
 PLUGIN_CHANGE#                                     NUMBER
 PLUGIN_RESETLOGS_CHANGE#                           NUMBER
 PLUGIN_RESETLOGS_TIME                              DATE

SQL> select FILE# ,CHECKPOINT_CHANGE# from v$datafile;

     FILE# CHECKPOINT_CHANGE#
---------- ------------------
         1            1210981
         2            1210981
         3            1210981
         4            1210981
         5            1210981

SQL> 
SQL> desc v$datafile_header;
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 FILE#                                              NUMBER
 STATUS                                             VARCHAR2(7)
 ERROR                                              VARCHAR2(18)
 FORMAT                                             NUMBER
 RECOVER                                            VARCHAR2(3)
 FUZZY                                              VARCHAR2(3)
 CREATION_CHANGE#                                   NUMBER
 CREATION_TIME                                      DATE
 TABLESPACE_NAME                                    VARCHAR2(30)
 TS#                                                NUMBER
 RFILE#                                             NUMBER
 RESETLOGS_CHANGE#                                  NUMBER
 RESETLOGS_TIME                                     DATE
 CHECKPOINT_CHANGE#                                 NUMBER
 CHECKPOINT_TIME                                    DATE
 CHECKPOINT_COUNT                                   NUMBER
 BYTES                                              NUMBER
 BLOCKS                                             NUMBER
 NAME                                               VARCHAR2(513)
 SPACE_HEADER                                       VARCHAR2(40)
 LAST_DEALLOC_CHANGE#                               VARCHAR2(16)
 UNDO_OPT_CURRENT_CHANGE#                           VARCHAR2(40)

SQL> select FILE# ,CHECKPOINT_CHANGE# from v$datafile_header;

     FILE# CHECKPOINT_CHANGE#
---------- ------------------
         1            1210981
         2            1210981
         3            1210981
         4            1210981
         5            1210981

SQL> 
Copy after login

    v$datafile:从控制文件里面查询的SCN

  v$datafile_header:从数据文件里面查询的SCN


 看来控制文件是很重要的啊,那么怎么备份控制文件呢。

SQL> alter database backup controlfile to '/home/oracle/controlfile.bkp'; #备份出一个二进制的文件,可以直接使用

Database altered.

SQL> 
SQL> alter database backup controlfile to trace as '/home/oracle/controlfile.txt'; #备份出一个文本文件里面有SQL脚本

Database altered.
Copy after login
    备份的方式当然还有rman命令啊
[root@localhost ~]# su - oracle
[oracle@localhost ~]$ ls
controlfile.bkp  controlfile.txt  database  my.txt  sql.html
[oracle@localhost ~]$ 
[oracle@localhost ~]$ ll
total 9576
-rw-r----- 1 oracle oinstall 9748480 May 31 10:19 controlfile.bkp --刚才二进制方式的备份文件
-rw-r--r-- 1 oracle oinstall    5816 May 31 10:20 controlfile.txt --备份的带文本文件,以后说明怎么用
drwxr-xr-x 7 oracle oinstall    4096 Aug 27  2013 database
-rw-r--r-- 1 oracle oinstall   10134 Jan 18 20:58 my.txt
-rw-r--r-- 1 oracle oinstall   14731 Jan 18 21:00 sql.html
[oracle@localhost ~]$ 
[oracle@localhost ~]$ cd /u01/app/oracle/oradata/PROD/
[oracle@localhost PROD]$ ll
total 1949180
-rw-r----- 1 oracle oinstall   9748480 May 31 10:22 control01.ctl  --这个是数据库里面正在使用的控制文件,大小和<span style="font-family: Arial, Helvetica, sans-serif;">二进制方式的备份文件一样</span>
-rw-r----- 1 oracle oinstall   9748480 May 31 10:22 control02.ctl
-rw-r----- 1 oracle oinstall 362422272 May 31 10:06 example01.dbf
-rw-r----- 1 oracle oinstall  52429312 May 31 10:06 redo01.log
-rw-r----- 1 oracle oinstall  52429312 May 31 10:06 redo02.log
-rw-r----- 1 oracle oinstall  52429312 May 31 10:21 redo03.log
-rw-r----- 1 oracle oinstall 534781952 May 31 10:17 sysaux01.dbf
-rw-r----- 1 oracle oinstall 807411712 May 31 10:12 system01.dbf
-rw-r----- 1 oracle oinstall  20979712 Feb  6 09:31 temp01.dbf
-rw-r----- 1 oracle oinstall  52436992 May 31 10:17 undotbs01.dbf
-rw-r----- 1 oracle oinstall  57679872 May 31 10:06 users01.dbf
[oracle@localhost PROD]$ 
[oracle@localhost PROD]$ 
Copy after login

      那么什么时候我们要备份控制文件呢?就一个原则,控制文件变化了,我们需要备份了,一般下面命令出现的时候,建议大家备份

oracle Control Files 杂谈

    看来以后控制文件要好好的看着啊。



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)

How to check tablespace size of oracle How to check tablespace size of oracle Apr 11, 2025 pm 08:15 PM

To query the Oracle tablespace size, follow the following steps: Determine the tablespace name by running the query: SELECT tablespace_name FROM dba_tablespaces; Query the tablespace size by running the query: SELECT sum(bytes) AS total_size, sum(bytes_free) AS available_space, sum(bytes) - sum(bytes_free) AS used_space FROM dba_data_files WHERE tablespace_

How to view instance name of oracle How to view instance name of oracle Apr 11, 2025 pm 08:18 PM

There are three ways to view instance names in Oracle: use the "sqlplus" and "select instance_name from v$instance;" commands on the command line. Use the "show instance_name;" command in SQL*Plus. Check environment variables (ORACLE_SID on Linux) through the operating system's Task Manager, Oracle Enterprise Manager, or through the operating system.

How to encrypt oracle view How to encrypt oracle view Apr 11, 2025 pm 08:30 PM

Oracle View Encryption allows you to encrypt data in the view, thereby enhancing the security of sensitive information. The steps include: 1) creating the master encryption key (MEk); 2) creating an encrypted view, specifying the view and MEk to be encrypted; 3) authorizing users to access the encrypted view. How encrypted views work: When a user querys for an encrypted view, Oracle uses MEk to decrypt data, ensuring that only authorized users can access readable data.

How to uninstall Oracle installation failed How to uninstall Oracle installation failed Apr 11, 2025 pm 08:24 PM

Uninstall method for Oracle installation failure: Close Oracle service, delete Oracle program files and registry keys, uninstall Oracle environment variables, and restart the computer. If the uninstall fails, you can uninstall manually using the Oracle Universal Uninstall Tool.

How to delete all data from oracle How to delete all data from oracle Apr 11, 2025 pm 08:36 PM

Deleting all data in Oracle requires the following steps: 1. Establish a connection; 2. Disable foreign key constraints; 3. Delete table data; 4. Submit transactions; 5. Enable foreign key constraints (optional). Be sure to back up the database before execution to prevent data loss.

How to set up users of oracle How to set up users of oracle Apr 11, 2025 pm 08:21 PM

To create a user in Oracle, follow these steps: Create a new user using the CREATE USER statement. Grant the necessary permissions using the GRANT statement. Optional: Use the RESOURCE statement to set the quota. Configure other options such as default roles and temporary tablespaces.

How to solve the problem of closing oracle cursor How to solve the problem of closing oracle cursor Apr 11, 2025 pm 10:18 PM

The method to solve the Oracle cursor closure problem includes: explicitly closing the cursor using the CLOSE statement. Declare the cursor in the FOR UPDATE clause so that it automatically closes after the scope is ended. Declare the cursor in the USING clause so that it automatically closes when the associated PL/SQL variable is closed. Use exception handling to ensure that the cursor is closed in any exception situation. Use the connection pool to automatically close the cursor. Disable automatic submission and delay cursor closing.

How to check invalid numbers of oracle How to check invalid numbers of oracle Apr 11, 2025 pm 08:27 PM

Oracle Invalid numeric errors may be caused by data type mismatch, numeric overflow, data conversion errors, or data corruption. Troubleshooting steps include checking data types, detecting digital overflows, checking data conversions, checking data corruption, and exploring other possible solutions such as configuring the NLS_NUMERIC_CHARACTERS parameter and enabling data verification logging.

See all articles