Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Brother Kang teaches you how to manage redo log files effectively.

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Some people may not know what redo log files are, but they are actually the redo.log files under your oradata directory.

Role: when your database crashes, the administrator can restore the database to the state it was last logged by redoing log files and database backup files.

When creating an oracle database, three redo log groups are created by default (for the database, at least two redo log groups are required), each containing one or more redo log files.

Each redo log group has its own internal sequence number, and oracle writes log information to the log group in the order from smallest to largest. When a redo log group is full, the background process LGWR begins to write to the next redo log group, and so on, if all redo log groups are full, overwrite the rewrite from the first log group, so write in a loop.

Where the redo log file has three states:

Current (current state): being written by the lgwr process

Active (active): is being used by the instance for database recovery

Inactive (inactive state): as the name implies, it is the state that is not used.

Log group status can be viewed through the view v$log:

OK, next, let's start with the following technical points:

⒈ adds log group and its members

In practice, in order to prevent the background process LGWR waiting to write to the log group, which leads to low efficiency, as an administrator, we need to increase the redo log group. Note: the size of the redo log file is generally between 10m and 50m, and the default is 50m.

Next, I add a log group to the database (the log group is made up of log files, we can only find the log group sequence number, and all we see is the log file):

As shown in the image above, log group 4 is created directly in the red box, and the default sequence number is automatically arranged later. You can also specify the group sequence number directly when you add a log group, such as the statement in the blue box.

⒉ creates log files in log groups

Example: add a new log file to the fifth redo log group

Note:

A: if we find that the disk where a log file is stored is damaged during our work, we need to delete the log file of the corrupted disk to prevent oracle from continuing to write the redo log to the corrupted log file.

① if the entire log filegroup is no longer needed (delete the log group, the member log files in it will also be deleted)

Where:

Ⅰ. A database requires at least two redo log groups. This limit cannot be exceeded when deleting.

Ⅱ. Only log groups in the inactive state can be deleted. If you want to delete a log group in the current state, you must manually switch the log to the inactive state.

The method to switch log groups is as follows:

Ⅲ. If the database is archived, you must make sure that the target log group is archived before deleting the redo log group.

② simply deletes members of the log group

For example: delete the member redo4_2.log in the fourth log group, as shown in the following figure:

It should be noted that whether you delete a log group or delete a log member, only the log group and log member information in the data dictionary and control files are deleted, and the corresponding physical files are not deleted. Open my Linux and show it to everyone and you will find that my physical files still exist. If you want to delete it, you need to kill it manually. (window is simpler, not here.)

③ empties the log file

Example: clear all log file contents in the 4th log group

B: if one of your log files is stored in the / home directory and there is not enough disk space, should you move the log files to another disk? How do you move it? The steps are as follows:

① shuts down the database

② manually copies the source file to the destination location

③ starts the instance and loads the database, but does not open the database

④ resets the path to the redo log file

Note: above the to is the source file path, and below is the destination file path.

⑤ opens the database

OK, so far, the path of the redo log file has been successfully changed. Now the path of redo4*.log used by the system is redo4_1bak.log under / home/oracle/backup. Let's confirm this by looking at the data dictionary view v$logfile:

In particular, view the common view of redo log information:

V$log view redo log group information

V$logfile views log file information in log group

V$log_history View Log History Information

. .

Ha!

Did you see that?

It's just that fun.

That's it. 6.

Are there any?

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 219

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report