Home Database Mysql Tutorial Oracle元数据对象Invalid修复过程

Oracle元数据对象Invalid修复过程

Jun 07, 2016 pm 05:15 PM

在Oracle的运行过程中,由于操作失误可能会造成内部元数据的损坏,进而影响到系统的一些基础功能和正常处理。一旦发生这种故障,

在Oracle的运行过程中,由于操作失误可能会造成内部元数据的损坏,进而影响到系统的一些基础功能和正常处理。一旦发生这种故障,对内部数据字典的重建就是我们需要进行的处理。

本篇从一个损坏故障为入手点,介绍了如何进行Oracle元数据对象的重建。

1、故障场景

一个朋友的测试库最近出现很多“古怪”的错误,比如exp/imp操作异常中断、pl/sql中元数据信息无法展现和异常报错。这种情况下,笔者向朋友索要的对应的alert_log日志文件。结果发现很多错误信息。

Sat Jun 23 06:36:37 2012

Errors in file /u01/diag/rdbms/wilson/wilson/trace/wilson_m001_3667.trc:

ORA-00604: error occurred at recursive SQL level 1

ORA-04063: package body "SYS.PRVT_HDM" has errors

ORA-06508: PL/SQL: could not find program unit being called: "SYS.PRVT_HDM"

ORA-06512: at line 1

(篇幅原因,有省略…..)

Sat Jun 23 06:53:39 2012

Exception [type: SIGSEGV, Address not mapped to object] [ADDR:0x34] [PC:0x92C0E13, kzpchkc()+4425] [flags: 0x0, count: 1]

Errors in file /u01/diag/rdbms/wilson/wilson/trace/wilson_ora_3619.trc (incident=12215):

ORA-07445: °é”è: è¨ [kzpchkc()+4425] [SIGSEGV] [ADDR:0x34] [PC:0x92C0E13] [Address not mapped to object] []

Incident details in: /u01/diag/rdbms/wilson/wilson/incident/incdir_12215/wilson_ora_3619_i12215.trc

Sat Jun 23 06:53:40 2012

Trace dumping is performing id=[cdmp_20120623065340]

Sat Jun 23 06:53:45 2012

Sweep [inc][12215]: completed

Sweep [inc2][12215]: completed

Sat Jun 23 06:55:23 2012

ORA-942 encountered when generating server alert SMG-4120

ORA-942 encountered when generating server alert SMG-4121

如此类型的错误信息,遍布在近几天错误日志中。但执行一些失败的命令时(如desc),还会有异常错误信息在日志中展现。

在上面的错误日志中,,还有是关于MMON进程异常中断之后,反复重新启动。

MMON进程是AWR报告库收集进程,定期(每小时)收集系统状态保存在数据库字典中。MMON异常中断后反复重启,似乎意味着AWR收集受到影响。

和朋友联系,获取进一步信息。

当日的AWR snapshot只有两条,看来真正出现了问题。同时,发现自动作业中的sys.standard包失效(invalid),合并的还有很多包和方法失效。

经过朋友回忆,应该是执行了exp/imp的重置脚本catexp.sql。看来是该脚本在执行中,破坏了内部的字典信息和数据,导致了一系列问题。

2、问题解决准备

发现了问题的根源,我们就可以有解决问题的基本思路:重新创建数据字典视图和程序对象。我们在Oracle程序安装目录中,均有保存建库脚本和程序,所以可以调用对应脚本,来更新数据字典和程序对象。

由于处理信息比较敏感,所以在处理之前,要进行一次完全备份。笔者选择停机冷备的方法。

首先,定位控制文件和数据文件位置信息,准备拷贝。

[root@ /]# chown -R oracle:oinstall backup

[root@ /]# ls -l | grep backup

drwxr-xr-x 2 oracle oinstall 4096 Jun 25 20:23 backup

 

--控制文件

SQL> select 'cp '||name||' /backup' from v$controlfile;

'CP'||NAME||'/BACKUP'

--------------------------------------------------------------------------------

cp /u01/app/oradata/ORA11G/controlfile/o1_mf_7vpyvypo_.ctl /backup

cp /u01/app/flash_recovery_area/ORA11G/controlfile/o1_mf_7vpyw16z_.ctl /backup

 

--数据文件

SQL> select 'cp '||file_name||' /backup' from dba_data_files;

'CP'||FILE_NAME||'/BACKUP'

--------------------------------------------------------------------------------

cp /u01/app/oradata/ORA11G/datafile/o1_mf_users_7vpyc2xd_.dbf /backup

cp /u01/app/oradata/ORA11G/datafile/o1_mf_undotbs1_7vpyc2py_.dbf /backup

cp /u01/app/oradata/ORA11G/datafile/o1_mf_sysaux_7vpyc2hb_.dbf /backup

cp /u01/app/oradata/ORA11G/datafile/o1_mf_system_7vpyc1x7_.dbf /backup

之后,关机将文件拷贝到备份目录上。

[oracle@bsplinux ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Mon Jun 25 20:42:06 2012

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

 

SQL> conn / as sysdba

Connected.

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL>

使用生成脚本语句,实现拷贝。

[oracle@bsplinux backup]$ ls -l

total 1720628

-rw-r----- 1 oracle oinstall  9748480 Jun 25 20:44 o1_mf_7vpyvypo_.ctl

-rw-r----- 1 oracle oinstall  9748480 Jun 25 20:44 o1_mf_7vpyw16z_.ctl

-rw-r----- 1 oracle oinstall 723525632 Jun 25 20:55 o1_mf_sysaux_7vpyc2hb_.dbf

-rw-r----- 1 oracle oinstall 744497152 Jun 25 21:08 o1_mf_system_7vpyc1x7_.dbf

-rw-r----- 1 oracle oinstall 267395072 Jun 25 20:47 o1_mf_undotbs1_7vpyc2py_.dbf

-rw-r----- 1 oracle oinstall  5251072 Jun 25 20:45 o1_mf_users_7vpyc2xd_.dbf

冷备份完成。

注意:在进行所有的修复操作前,如果有可能,一定要进行数据现场保留备份!这样起码可以做到不会将情况恶化。

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

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)

When might a full table scan be faster than using an index in MySQL? When might a full table scan be faster than using an index in MySQL? Apr 09, 2025 am 12:05 AM

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

Can I install mysql on Windows 7 Can I install mysql on Windows 7 Apr 08, 2025 pm 03:21 PM

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

Explain InnoDB Full-Text Search capabilities. Explain InnoDB Full-Text Search capabilities. Apr 02, 2025 pm 06:09 PM

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

Difference between clustered index and non-clustered index (secondary index) in InnoDB. Difference between clustered index and non-clustered index (secondary index) in InnoDB. Apr 02, 2025 pm 06:25 PM

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values ​​and pointers to data rows, and is suitable for non-primary key column queries.

MySQL: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

The relationship between mysql user and database The relationship between mysql user and database Apr 08, 2025 pm 07:15 PM

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

Can mysql and mariadb coexist Can mysql and mariadb coexist Apr 08, 2025 pm 02:27 PM

MySQL and MariaDB can coexist, but need to be configured with caution. The key is to allocate different port numbers and data directories to each database, and adjust parameters such as memory allocation and cache size. Connection pooling, application configuration, and version differences also need to be considered and need to be carefully tested and planned to avoid pitfalls. Running two databases simultaneously can cause performance problems in situations where resources are limited.

Explain different types of MySQL indexes (B-Tree, Hash, Full-text, Spatial). Explain different types of MySQL indexes (B-Tree, Hash, Full-text, Spatial). Apr 02, 2025 pm 07:05 PM

MySQL supports four index types: B-Tree, Hash, Full-text, and Spatial. 1.B-Tree index is suitable for equal value search, range query and sorting. 2. Hash index is suitable for equal value searches, but does not support range query and sorting. 3. Full-text index is used for full-text search and is suitable for processing large amounts of text data. 4. Spatial index is used for geospatial data query and is suitable for GIS applications.

See all articles