search
HomeDatabaseMysql TutorialOracle Db Rname datafile/redofile on ASM

oracle db在omf自动管理文件下并在文件存放在ASM里,如果手工rename 一个文件OMF文件,oracle会自动删除原有文件,以下是测试 SQL SELECT file#,name FROM v$datafile; FILE# NAME---------- ----------------------------------------------------------------

oracle db在omf自动管理文件下并在文件存放在ASM里,如果手工rename 一个文件OMF文件,oracle会自动删除原有文件,以下是测试

SQL> SELECT file#,name FROM v$datafile;
 
     FILE# NAME
---------- --------------------------------------------------------------------------------
         1 +ASMDATA/racdb/datafile/system.256.814462679
         2 +ASMDATA/racdb/datafile/sysaux.257.814462681
         3 +ASMDATA/racdb/datafile/undotbs1.258.814462681
         4 +ASMDATA/racdb/datafile/users.259.814462681
         5 +ASMDATA/racdb/datafile/undotbs2.264.814462949
         6 +ASMDATA/racdb/datafile/test.268.815753637
         7 +ASMDATA/racdb/datafile/goldengate.341.820339679
         8 +ASMDATA/racdb/datafile/ccdata.375.844202017
         9 +ASMDATA/racdb/datafile/soe.460.844203543
        10 +ASMDATA/racdb/datafile/big_test.661.852999379
 
10 ROWS selected.

这里先通过rman backup as copy 备份一个文件

[oracle@rac1 ~]$ rman target /
 
Recovery Manager: Release 11.2.0.3.0 - Production ON Fri Jul 18 11:59:24 2014
 
Copyright (c) 1982, 2011, Oracle AND/OR its affiliates.  ALL rights reserved.
 
connected TO target DATABASE: RACDB (DBID=812079559)
 
RMAN> backup AS copy datafile 10 format '+ASMDATA/racdb/datafile/big_test01.dbf';
 
Starting backup at 18-JUL-14
USING target DATABASE control file instead OF recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=76 instance=racdb1 device TYPE=DISK
channel ORA_DISK_1: starting datafile copy
INPUT datafile file NUMBER=00010 name=+ASMDATA/racdb/datafile/big_test.661.852999379
output file name=+ASMDATA/racdb/datafile/big_test01.dbf tag=TAG20140718T115951 RECID=4 STAMP=853243196
channel ORA_DISK_1: datafile copy complete, elapsed TIME: 00:00:08
Finished backup at 18-JUL-14
 
RMAN>
[grid@rac1 ~]$ asmcmd
ls -lASMCMD>  
 
State    TYPE    Rebal  Name
MOUNTED  EXTERN  N      ASMDATA/
MOUNTED  EXTERN  N      DATA/
ASMCMD> ASMCMD> 
ASMCMD> ls -l +ASMDATA/racdb/datafile/big_test01.dbf
TYPE      Redund  Striped  TIME             Sys  Name
                                            N    big_test01.dbf => +ASMDATA/RACDB/DATAFILE/BIG_TEST.664.853243193
ASMCMD> ls -l +ASMDATA/racdb/datafile/big_test.661.852999379
TYPE      Redund  Striped  TIME             Sys  Name
DATAFILE  UNPROT  COARSE   JUL 18 11:00:00  Y    big_test.661.852999379
ASMCMD> ls -l +ASMDATA/racdb/datafile/big_test*
TYPE      Redund  Striped  TIME             Sys  Name
DATAFILE  UNPROT  COARSE   JUL 18 11:00:00  Y    BIG_TEST.661.852999379
DATAFILE  UNPROT  COARSE   JUL 18 11:00:00  Y    BIG_TEST.664.853243193
                                            N    big_test01.dbf => +ASMDATA/RACDB/DATAFILE/BIG_TEST.664.853243193

这里直切swtich datafile 看下

RMAN> switch  datafile 10 TO copy;
 
USING target DATABASE control file instead OF recovery catalog
datafile 10 switched TO datafile copy "+ASMDATA/racdb/datafile/big_test01.dbf"
RMAN> recover datafile 10;
 
Starting recover at 18-JUL-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=80 instance=racdb1 device TYPE=DISK
 
starting media recovery
media recovery complete, elapsed TIME: 00:00:02
 
Finished recover at 18-JUL-14
 
RMAN> SQL 'alter database datafile 10 online';
 
SQL statement: ALTER DATABASE datafile 10 online
 
ASMCMD> ls -l +ASMDATA/racdb/datafile/big_test*
TYPE      Redund  Striped  TIME             Sys  Name
DATAFILE  UNPROT  COARSE   JUL 18 12:00:00  Y    BIG_TEST.661.852999379
DATAFILE  UNPROT  COARSE   JUL 18 12:00:00  Y    BIG_TEST.664.853243193
                                            N    big_test01.dbf => +ASMDATA/RACDB/DATAFILE/BIG_TEST.664.853243193

从这里在看两个文件都存在,所以说在文件OMF命名格式下,rman的switch datafile 不会删除文件

下面看下在sqlplus下直接rename

SQL> ALTER DATABASE datafile 10 offline;
 
DATABASE altered.
 
SQL> 
SQL> ALTER DATABASE RENAME file '+ASMDATA/racdb/datafile/big_test01.dbf' TO '+ASMDATA/racdb/datafile/big_test.661.852999379';
 
DATABASE altered.
 
SQL> recover datafile 10;
Media recovery complete.
SQL> ALTER DATABASE datafile 10 online;
 
DATABASE altered.
 
 
Completed: ALTER DATABASE RENAME file '+ASMDATA/racdb/datafile/big_test01.dbf' TO '+ASMDATA/racdb/datafile/big_test.661.852999379'
Fri Jul 18 12:08:21 2014
ALTER DATABASE RECOVER  datafile 10  
Media Recovery START
Serial Media Recovery started
WARNING! Recovering DATA file 10 FROM a fuzzy backup. It might be an online
backup taken WITHOUT entering the BEGIN backup command.
Recovery OF Online Redo Log: Thread 1 GROUP 2 Seq 337 Reading mem 0
  Mem# 0: +ASMDATA/racdb/onlinelog/group_2.262.814462797
Media Recovery Complete (racdb1)
Completed: ALTER DATABASE RECOVER  datafile 10  
ALTER DATABASE datafile 10 online
Completed: ALTER DATABASE datafile 10 onlin
ASMCMD> ls -l +ASMDATA/racdb/datafile/big_test*
Type      Redund  Striped  Time             Sys  Name
DATAFILE  UNPROT  COARSE   JUL 18 12:00:00  Y    BIG_TEST.661.852999379
DATAFILE  UNPROT  COARSE   JUL 18 12:00:00  Y    BIG_TEST.664.853243193
                                            N    big_test01.dbf => +ASMDATA/RACDB/DATAFILE/BIG_TEST.664.853243193

这里看到从手工命令的文件切换到OMF命令的文件,原文件也没用被删除。

看下omf切换到手工命令文件

SQL> ALTER DATABASE datafile 10 offline;
 
DATABASE altered.
 
 
SQL> ALTER DATABASE RENAME file '+ASMDATA/racdb/datafile/big_test.661.852999379' TO '+ASMDATA/racdb/datafile/big_test01.dbf';
 
DATABASE altered.
 
SQL> recover datafile 10;
Media recovery complete.
SQL>  ALTER DATABASE datafile 10 online;
 
DATABASE altered.

alter日志文件如下

alter database rename file '+ASMDATA/racdb/datafile/big_test.661.852999379' to '+ASMDATA/racdb/datafile/big_test01.dbf'
Deleted Oracle managed file +ASMDATA/racdb/datafile/big_test.661.852999379
Completed: alter database rename file '+ASMDATA/racdb/datafile/big_test.661.852999379' to '+ASMDATA/racdb/datafile/big_test01.dbf'
Fri Jul 18 12:12:35 2014

明显看出文件被delete ,Deleted Oracle managed file

ASMCMD> ls -l +ASMDATA/racdb/datafile/big_test*
Type      Redund  Striped  Time             Sys  Name
DATAFILE  UNPROT  COARSE   JUL 18 12:00:00  Y    BIG_TEST.664.853243193
                                            N    big_test01.dbf => +ASMDATA/RACDB/DATAFILE/BIG_TEST.664.853243193

从asmcmd看到只剩下一个文件

Statement
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
Explain the role of InnoDB redo logs and undo logs.Explain the role of InnoDB redo logs and undo logs.Apr 15, 2025 am 12:16 AM

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.

What are the key metrics to look for in an EXPLAIN output (type, key, rows, Extra)?What are the key metrics to look for in an EXPLAIN output (type, key, rows, Extra)?Apr 15, 2025 am 12:15 AM

Key metrics for EXPLAIN commands include type, key, rows, and Extra. 1) The type reflects the access type of the query. The higher the value, the higher the efficiency, such as const is better than ALL. 2) The key displays the index used, and NULL indicates no index. 3) rows estimates the number of scanned rows, affecting query performance. 4) Extra provides additional information, such as Usingfilesort prompts that it needs to be optimized.

What is the Using temporary status in EXPLAIN and how to avoid it?What is the Using temporary status in EXPLAIN and how to avoid it?Apr 15, 2025 am 12:14 AM

Usingtemporary indicates that the need to create temporary tables in MySQL queries, which are commonly found in ORDERBY using DISTINCT, GROUPBY, or non-indexed columns. You can avoid the occurrence of indexes and rewrite queries and improve query performance. Specifically, when Usingtemporary appears in EXPLAIN output, it means that MySQL needs to create temporary tables to handle queries. This usually occurs when: 1) deduplication or grouping when using DISTINCT or GROUPBY; 2) sort when ORDERBY contains non-index columns; 3) use complex subquery or join operations. Optimization methods include: 1) ORDERBY and GROUPB

Describe the different SQL transaction isolation levels (Read Uncommitted, Read Committed, Repeatable Read, Serializable) and their implications in MySQL/InnoDB.Describe the different SQL transaction isolation levels (Read Uncommitted, Read Committed, Repeatable Read, Serializable) and their implications in MySQL/InnoDB.Apr 15, 2025 am 12:11 AM

MySQL/InnoDB supports four transaction isolation levels: ReadUncommitted, ReadCommitted, RepeatableRead and Serializable. 1.ReadUncommitted allows reading of uncommitted data, which may cause dirty reading. 2. ReadCommitted avoids dirty reading, but non-repeatable reading may occur. 3.RepeatableRead is the default level, avoiding dirty reading and non-repeatable reading, but phantom reading may occur. 4. Serializable avoids all concurrency problems but reduces concurrency. Choosing the appropriate isolation level requires balancing data consistency and performance requirements.

MySQL vs. Other Databases: Comparing the OptionsMySQL vs. Other Databases: Comparing the OptionsApr 15, 2025 am 12:08 AM

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.

How does MySQL index cardinality affect query performance?How does MySQL index cardinality affect query performance?Apr 14, 2025 am 12:18 AM

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.

MySQL: Resources and Tutorials for New UsersMySQL: Resources and Tutorials for New UsersApr 14, 2025 am 12:16 AM

The MySQL learning path includes basic knowledge, core concepts, usage examples, and optimization techniques. 1) Understand basic concepts such as tables, rows, columns, and SQL queries. 2) Learn the definition, working principles and advantages of MySQL. 3) Master basic CRUD operations and advanced usage, such as indexes and stored procedures. 4) Familiar with common error debugging and performance optimization suggestions, such as rational use of indexes and optimization queries. Through these steps, you will have a full grasp of the use and optimization of MySQL.

Real-World MySQL: Examples and Use CasesReal-World MySQL: Examples and Use CasesApr 14, 2025 am 12:15 AM

MySQL's real-world applications include basic database design and complex query optimization. 1) Basic usage: used to store and manage user data, such as inserting, querying, updating and deleting user information. 2) Advanced usage: Handle complex business logic, such as order and inventory management of e-commerce platforms. 3) Performance optimization: Improve performance by rationally using indexes, partition tables and query caches.

See all articles

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

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool