Home Database Mysql Tutorial 使用trace文件重建控制文件时的只读表空间处理

使用trace文件重建控制文件时的只读表空间处理

Jun 07, 2016 pm 05:17 PM
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                            

linux

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

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 solve the problem of mysql cannot open shared library How to solve the problem of mysql cannot open shared library Mar 04, 2025 pm 04:01 PM

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

Reduce the use of MySQL memory in Docker Reduce the use of MySQL memory in Docker Mar 04, 2025 pm 03:52 PM

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Run MySQl in Linux (with/without podman container with phpmyadmin) Run MySQl in Linux (with/without podman container with phpmyadmin) Mar 04, 2025 pm 03:54 PM

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

What is SQLite? Comprehensive overview What is SQLite? Comprehensive overview Mar 04, 2025 pm 03:55 PM

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

How do I configure SSL/TLS encryption for MySQL connections? How do I configure SSL/TLS encryption for MySQL connections? Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Running multiple MySQL versions on MacOS: A step-by-step guide Running multiple MySQL versions on MacOS: A step-by-step guide Mar 04, 2025 pm 03:49 PM

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

See all articles