oracle Control Files 杂谈
最近在群里,看到很多群友都是控制文件出问题了,所以今天我想说一下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>
我们大家都知道,一般数据库之间各个文件之间的SCN号不一致的时候,要恢复的,那么怎么看呢。
这张图就说明了,控制文件的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>
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.
[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]$
那么什么时候我们要备份控制文件呢?就一个原则,控制文件变化了,我们需要备份了,一般下面命令出现的时候,建议大家备份
看来以后控制文件要好好的看着啊。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Solutions to Oracle cannot be opened include: 1. Start the database service; 2. Start the listener; 3. Check port conflicts; 4. Set environment variables correctly; 5. Make sure the firewall or antivirus software does not block the connection; 6. Check whether the server is closed; 7. Use RMAN to recover corrupt files; 8. Check whether the TNS service name is correct; 9. Check network connection; 10. Reinstall Oracle software.

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.

Oracle database paging uses ROWNUM pseudo-columns or FETCH statements to implement: ROWNUM pseudo-columns are used to filter results by row numbers and are suitable for complex queries. The FETCH statement is used to get the specified number of first rows and is suitable for simple queries.

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

To stop an Oracle database, perform the following steps: 1. Connect to the database; 2. Shutdown immediately; 3. Shutdown abort completely.

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

SQL statements can be created and executed based on runtime input by using Oracle's dynamic SQL. The steps include: preparing an empty string variable to store dynamically generated SQL statements. Use the EXECUTE IMMEDIATE or PREPARE statement to compile and execute dynamic SQL statements. Use bind variable to pass user input or other dynamic values to dynamic SQL. Use EXECUTE IMMEDIATE or EXECUTE to execute dynamic SQL statements.

The steps to open an Oracle database are as follows: Open the Oracle database client and connect to the database server: connect username/password@servername Use the SQLPLUS command to open the database: SQLPLUS
