Home Database Mysql Tutorial DBA经验谈:更改数据文件的可用性

DBA经验谈:更改数据文件的可用性

Jun 07, 2016 pm 04:54 PM
o oracle database

Oracle数据库中的数据文件有一个特性,即可以设置是否脱机。如果将数据文件设置为脱机,数据库就无法读取这个数据文件。只有

  Oracle数据库中的数据文件有一个特性,,即可以设置是否脱机。如果将数据文件设置为脱机,数据库就无法读取这个数据文件。只有在文件联机,时数据库才能够读取其中的内容。为此有时候改变这个数据文件的状态也是数据库维护过程中的一个必要手段。

  一、为什么要更改其可用性?

  1、 处于更改数据文件名或者位置的需要。

  在数据库部署的时候,如果没有给数据文件取一个合适的名字,或者说没有给其选择一个合适的分区。此时在后续的维护中可能就需要更改数据文件的名字或者位置。如有时候处于性能优化的考虑,会将一些存在并发性访问的数据文件存放在不同的硬盘分区上,以减少I/O冲突提高数据库性能。在这种情况下,就必须要移动数据文件的位置。要实现这个目的的话,就必须首先要让数据文件脱机,然后再将其启动到合适的位置。

  2、 系统遇到数据文件故障时会自动关闭。

  有时候数据库系统也会自动关闭数据文件。如当数据库系统往数据文件中写入数据的时候,如果发现写入过程中出现错误的话,就会将这个数据文件设置为脱机,并将这个信息写入到日志中。数据库管理员接到报警信息后,就需要修复这个数据文件。修复完毕后,还需要手工的将这个数据文件设置为联机。此时数据库系统才会重新启用这个数据文件。可见,当数据文件无法正确写入时,也是数据文件脱机的一个原因。

  将某个数据文件设置为脱机时,不会影响到其他数据文件的可用性。如数据库管理员在规划数据文件的时候,是按照部门来规划的。即其他部门的用户仍然可以在系统中访问自己若需要的数据。为此这个特性的话可以有效的的减少数据库当机的时间,实现数据库的最大可用性。  分步启动数据库以重命名数据文件

  二、归档模式与非归档模式下分别如何更改?

  Oracle数据库工作模式大致分为归档模式与非归档模式。在不同的操作模式下,其数据文件可用性维护的方法稍有差异。为此各位数据库管理员要了解在不同操作模式下的维护方式。只有如此,才能够采取合适的方式来改变数据文件的可用性。

  若数据库处于归档模式,则要使一个单独的数据文件联机或者脱机,则只需要使用ALTER DATABASE的DATEFILE字句即可。即按照如下的形式就可以将某个数据文件设置为脱机或者联机。当以下命令执行成功后,系统会提示“数据库已经更改”。

  ALTER DATABASE DATAFILE ‘数据文件存储路径与名字’ OFFLINE/ONLINE;

  但是要注意,如果数据库不是处于归档模式,则执行上面的语句更改数据文件的可用性时,数据库会提示错误信息。若将某个数据文件设置为脱机时,“除非使用介质恢复,否则不允许立即脱机”。如将某个数据文件设置为联机时,会提示“数据文件5,需要介质恢复”。注意这里的5代表的是数据文件的绝对文件号。在Oracle数据库中文件号是数据库系统标识数据文件的一个工具,就好像人的身份证一样,唯一标识了一个数据文件。在Oracle中,文件号分为绝对文件号和相对文件号。绝对文件号是在整个数据库中唯一的标识一个数据文件。而相对文件号是在表空间中唯一的标识一个数据文件。也就是说,相对文件号在同一个表空间内是唯一的,但是并不保障在整个数据库内是唯一的。此时数据库可能需要表空间与相对文件号两个参数才能够唯一的定位数据文件。对于中等规模以下的数据库系统,往往相对文件号与绝对文件号是相同的。但是当数据库变得很大时,相对文件号与决定文件号就可能有所差异。由于在错误信息中没有直接说明数据文件的名称,为此数据库管理员不得不先将这个文件号转换到对应的数据文件名字,然后再去想解决方法。IT专家网独家:重定位数据文件的位置

  可见,如果当数据库采用非归档模式时,就无法采用上面方式将数据文件联机或者脱机。此时需要稍微修改一下上面的语句来完成。如可以将这个语句改为:

  ALTER DATABASE DATAFILE ‘数据文件存储路径与名字’ OFFLINE DROP;

  即需要在原先的语句后面加入DROP关键字。此时就可以正常将非归档模式下的数据文件脱机了。不过需要注意的一点就是,无非采用正常的方式将非归档模式下的数据文件设置为联机。正常情况下,只有采用介质恢复的形式才能够将非归档模式下的数据文件设置为联机。所以说,如果数据库采用的是非归档模式,那么在将数据文件设置为脱机时,就需要慎重了。因为此时再想将脱机的数据文件设置为联机,可没有这么简单了。

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

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 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
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)

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

How does Go WebSocket integrate with databases? How does Go WebSocket integrate with databases? Jun 05, 2024 pm 03:18 PM

How to integrate GoWebSocket with a database: Set up a database connection: Use the database/sql package to connect to the database. Store WebSocket messages to the database: Use the INSERT statement to insert the message into the database. Retrieve WebSocket messages from the database: Use the SELECT statement to retrieve messages from the database.

How to use database callback functions in Golang? How to use database callback functions in Golang? Jun 03, 2024 pm 02:20 PM

Using the database callback function in Golang can achieve: executing custom code after the specified database operation is completed. Add custom behavior through separate functions without writing additional code. Callback functions are available for insert, update, delete, and query operations. You must use the sql.Exec, sql.QueryRow, or sql.Query function to use the callback function.

How to install and register the btc trading app? How to install and register the btc trading app? Feb 21, 2025 pm 07:09 PM

This article will provide a detailed introduction to how to install and register a Bitcoin trading application. The Bitcoin trading app allows users to manage and trade cryptocurrencies such as Bitcoin. The article guides users through the installation and registration process step by step, including downloading applications, creating accounts, performing identity verification, and first deposit. The goal of the article is to provide beginners with clear and easy-to-understand guidelines to help them easily enter the world of Bitcoin trading.

Top 10 global digital currency trading apps recommended (2025 currency trading software ranking) Top 10 global digital currency trading apps recommended (2025 currency trading software ranking) Mar 12, 2025 pm 05:48 PM

This article recommends the top ten digital currency trading apps in the world, including Binance, OKX, Huobi Global, Coinbase, Kraken, Gate.io, KuCoin, Bitfinex, Gemini and Bitstamp. These platforms have their own characteristics in terms of transaction pair quantity, transaction speed, security, compliance, user experience, etc. For example, Binance is known for its high transaction speed and extensive services, while Coinbase is more suitable for novices. Choosing a platform that suits you requires comprehensive consideration of your own needs and risk tolerance. Learn about the world's mainstream digital currency trading platforms to help you conduct digital asset trading safely and efficiently.

How to save JSON data to database in Golang? How to save JSON data to database in Golang? Jun 06, 2024 am 11:24 AM

JSON data can be saved into a MySQL database by using the gjson library or the json.Unmarshal function. The gjson library provides convenience methods to parse JSON fields, and the json.Unmarshal function requires a target type pointer to unmarshal JSON data. Both methods require preparing SQL statements and performing insert operations to persist the data into the database.

See all articles