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

How to implement a script that automatically deletes archive logs

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces how to automatically delete the archive log script, the article is very detailed, has a certain reference value, interested friends must read it!

Scripts that automatically delete archive logs (especially in dataguard environments)

There have been 236 reads 2011-12-16 21:02 | personal category: oracle data guard

Scripts that automatically delete archive logs (especially in dataguard environments)

In archive mode, always be careful not to burst the disk space, especially in the dataguard environment, you need to clean the logs that have already been apply regularly so as not to burst the hard disk.

There are several points to consider when deleting logs automatically:

1. The log must have been apply

two。 Log backups have already been backed up

3. In order to ensure some management leeway, do not delete immediately after apply, but should set a deletion policy according to the actual situation.

4. The script should be compatible with both primary and standby states, and automatically judge the state and execute different logic, otherwise it may be unfortunate if you forget to modify the script after switching.

The following is a script I used to delete the archive log. To run this script, you need to enter a parameter to control the retention time of the log.

This script can be used for either the standard side or the standby side

1. For the standby side, as long as the archive is within the save cycle and is archived by apply, it will be deleted.

two。 For the backup side, in addition to meeting the preservation cycle and apply conditions, it is also necessary to ensure that the archive has been backed up before it is deleted.

For dataguard environment, although backup can be performed on primary and standby side, if the pressure is not very high, it is recommended to perform backup on standard side for convenience of management.

The detailed script is as follows:

[oracle@dwapp1 DBA] $cat delete_arch.sh

#! / bin/bash

#

#

# This script is to delete the arch logs for the standby database after it has applied the logs to the instance.

#

#

Source / home/oracle/.bash_profile

#

Usage ()

{# usage

Echo "USAGE: `basename $0` $retention"

Exit 2

}

ArgNum=1

If [! $#-eq $ArgNum]; then

Echo ""

Echo "Incorrect parameter"

Usage

Fi

Retention=$1

Script= `basename $0`

Dir=/tmp

Tmpf=$dir/.$script.tmp

# get archived log list for standby database

Function GetLogListForStandby

{

Sqlplus-S / nolog

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: 0

*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

Development

Wechat

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

12
Report