使用trace文件重建控制文件时的只读表空间处理
使用trace文件重建控制文件的时候会经常忽略其中只读表空间,这种方式重建后的只读表空间的其实在置成读写的时候会出现类似ORA-0
使用trace文件重建控制文件的时候会经常忽略其中只读表空间,,这种方式重建后的只读表空间的其实在置成读写的时候会出现类似
ORA-01135: file 6 accessed for DML/query is offline
ORA-01111: name for data file 6 is unknown - rename to correct file
ORA-01110: data file 6: '/u01/app/Oracle/product/10.2.1/db_1/dbs/MISSING00006'
的错误,大体分类一下:
当存在read only表空间时,重建控制文件分两种情况:
1、重建controlfile的脚本中包含read only所对应的datafile,datafile不需要rename。
2、重建controlfile的脚本中不包含read only所对应的datafile;重建controlfile之后需要rename datafile到正确的位置。
测试环境:Oracle 10G database:PROD
演示:
1,查看表空间状态
注意此时oltp表空间是read only状态。
SYS@PROD>select tablespace_name,STATUS from dba_tablespaces;
TABLESPACE_NAME STATUS
------------------------------ ---------
SYSTEM ONLINE
UNDOTBS ONLINE
SYSAUX ONLINE
TEMP01 ONLINE
TEMP02 ONLINE
USERS ONLINE
TOOLS ONLINE
OLTP READ ONLY
MSSM ONLINE
9 rows selected.
2,备份控制文件到trace
SYS@PROD>alter database backup controlfile to trace;
Database altered.
3,开始重建控制文件过程:(停库=>nomount状态=>执行trace重建脚本)
SYS@PROD>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SYS@PROD>startup nomount;
ORACLE instance started.
Total System Global Area 314572800 bytes
Fixed Size 1219184 bytes
Variable Size 100664720 bytes
Database Buffers 209715200 bytes
Redo Buffers 2973696 bytes
4,此处模拟删除唯一的控制文件
SYS@PROD>show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string /u01/app/oracle/oradata/PROD/d
isk1/control1.ctl
PROD@rhel1$ rm disk1/control1.ctl
5,执行trace脚本
1)如果打开备份产生的trace文件我们可以在后面看到控制文件的重建语句(仔细研究trace文件可以发现很多关于控制文件的重要信息)
产生的trace文件位于$ORACLE_BASE/admin/$ORACLE_SID/udump/目录下,如果不知道是哪个文件可以使用如下语句查找:
select
d.value||'/'||lower(rtrim(i.instance, chr(0)))||'_ora_'||p.spid||'.trc' trace_file_name
from
( select p.spid
from sys.v$mystat m,sys.v$session s,sys.v$process p
where m.statistic# = 1 and s.sid = m.sid and p.addr = s.paddr) p,
( select t.instance from sys.v$thread t,sys.v$parameter v
where v.name = 'thread' and (v.value = 0 or t.thread# = to_number(v.value))) i,
( select value from sys.v$parameter where name = 'user_dump_dest') d ;
返回:
TRACE_FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/admin/PROD/udump/prod_ora_13341.trc
或这使用下列方法获取pid
select a.spid from
v$process a,v$session b
where a.addr=b.paddr and b.username = 'SYS';
返回:
SPID
------------
13341
2)找到trace文件中的这段:
===========================================================
CREATE CONTROLFILE REUSE DATABASE "PROD" NORESETLOGS ARCHIVELOG
MAXLOGFILES 30
MAXLOGMEMBERS 5
MAXDATAFILES 100
MAXINSTANCES 1
MAXLOGHISTORY 292
LOGFILE
GROUP 1 (
'/u01/app/oracle/oradata/PROD/disk1/redo01.log',
'/u01/app/oracle/oradata/PROD/disk2/redo01_b.log'
) SIZE 100M,
GROUP 2 (
'/u01/app/oracle/oradata/PROD/disk1/redo02.log',
'/u01/app/oracle/oradata/PROD/disk2/redo02_b.log'
) SIZE 100M,
GROUP 3 (
'/u01/app/oracle/oradata/PROD/disk1/redo03.log',
'/u01/app/oracle/oradata/PROD/disk2/redo03_b.log'
) SIZE 100M
-- STANDBY LOGFILE
DATAFILE
'/u01/app/oracle/oradata/PROD/disk1/system01.dbf',
'/u01/app/oracle/oradata/PROD/disk1/undotbs01.dbf',
'/u01/app/oracle/oradata/PROD/disk1/sysaux01.dbf',
'/u01/app/oracle/oradata/PROD/disk1/users_01.dbf',
'/u01/app/oracle/oradata/PROD/disk1/tools_01.dbf',
'/u01/app/oracle/oradata/PROD/disk1/mssm_01.dbf'
CHARACTER SET US7ASCII;
===========================================================
==注意此时的trace文件中没有只读表空间的信息,如果在这个脚本的datafile后面加上oltp的正确位置名就没有rename的过程了。
3)保存成脚本恢复使用:
PROD@rhel1 /home/oracle$ vi con.sql

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











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.

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'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

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.

MySQL is suitable for small and large enterprises. 1) Small businesses can use MySQL for basic data management, such as storing customer information. 2) Large enterprises can use MySQL to process massive data and complex business logic to optimize query performance and transaction processing.

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.

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

MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.
