当前位置:网站首页> Oracle删除归档日志及添加定时任务
Oracle删除归档日志及添加定时任务
2022-06-28 22:08:00 【1024问】
一、删除归档日志
1.切换用户
2.使用RMAN工具
3.连接本地数据库
4.检查控制文件和实际物理文件的差别
5.同步检查控制文件和实际物理文件的信息
6.删除n天前的归档日志
7.退出RMAN
二、添加定时任务
1.创建归档日志删除脚本
2.授予脚本文件执行权限
3.测试归档日志删除脚本
4.添加定时任务
5.查看定时任务
总结
一、删除归档日志1.切换用户# 切换至oracle用户su – oracle2.使用RMAN工具# 使用RMAN工具,删除失效的归档日志rman注:RMAN(Recovery Manager)是一种用于备份(backup)、还原(restore)和恢复(recover)数据库的 Oracle 工具。
3.连接本地数据库# 使用target命令连接本地数据库RMAN> connect target /4.检查控制文件和实际物理文件的差别执行crosscheck命令,检查控制文件和实际物理文件的差别,如果物理文件不存在于介质上,将标记为expired(失效/不可用),crosscheck之后,就可以删除这些失效的归档日志了(执行脚本后,删除的归档日志状态会变为“失效”)
RMAN> crosscheck archivelog all;5.同步检查控制文件和实际物理文件的信息# 删除状态为expired(失效/不可用)的归档日志RMAN> delete expired archivelog all;6.删除n天前的归档日志# 删除 3 天前的归档日志:RMAN> delete archivelog all completed before 'sysdate-3';# 删除 1 天前RMAN> delete archivelog until time 'sysdate-1'区别:第一条带complete的语句,主要是删除已备份过的归档,没有备份的归档,不会被删除。而第二个语句, 则会删除掉归档,无论备份与否。
7.退出RMAN# 退出RMANRMAN> exit二、添加定时任务1.创建归档日志删除脚本archivelog_clear.sh
#!/bin/bashBACK_DIR=/home/oracle/clear_archlog/dataexport DATE=`date +%F`mkdir -p $BACK_DIR/$DATEtouch $BACK_DIR/$DATE/rman_backup.logecho "--------------------------------`date`-------------------------------"source ~/.bash_profile # 记录日志rman_backup.log 可以后期检查是否执行成功rman target / >> $BACK_DIR/$DATE/rman_backup.log <<EOF # 把无效的expired的archivelog标出来crosscheck archivelog all;# 直接全部删除过期的归档日志#delete noprompt expired archivelog all;# 直接删除7天前所有的归档日志delete noprompt archivelog all completed before 'sysdate-7';exitEOFecho -e "\n"echo "------------------------------ FINISHED ----------------------------"2.授予脚本文件执行权限#授予执行权限chmod +x archivelog_clear.sh3.测试归档日志删除脚本./archivelog_clear.sh4.添加定时任务输入命令:crontab -e 编辑并且添加一行新的任务
30 3 15 * * /home/oracle/archivelog_clear.sh5.查看定时任务crontab -l总结到此这篇关于Oracle删除归档日志及添加定时任务的文章就介绍到这了,更多相关Oracle删除归档日志内容请搜索软件开发网以前的文章或继续浏览下面的相关文章希望大家以后多多支持软件开发网!
边栏推荐
- How many stages did the development and evolution of data analysis go through?
- Common tool classes and Commons class libraries
- 5毛VS600亿,食品安全问题是卫龙上市最大的拦路虎?
- The example application of histogram in data visualization makes the public performance results clear at a glance
- 【HackTheBox】dancing(SMB)
- [dynamic programming] p1018 linear DP: maximum product
- IC Nansha|AMD高级副总裁、大中华区总裁潘晓明:制程、架构、平台优化突破计算边界
- 常用工具类与commons 类库
- 【selenium自动化过程中的api抓包】browsermobproxy的安装和配置
- F1tenth gym of ROS 2 humble hawksbill
猜你喜欢

ansible生产环境使用场景(七):批量部署elk客户端

Use of axurer9 option group

VR全景制作的前景如何?

PyTorch搭建Transformer实现多变量多步长时间序列预测(负荷预测)

Description détaillée du schéma technique du sous - environnement syntonique auto - test de Zadig pour les développeurs

Safety innovation practice | Haitai Fangyuan was invited to participate in the technical exchange Seminar on "network information innovation and value co creation in the digital age"

【selenium自动化过程中的api抓包】browsermobproxy的安装和配置

Appium automated test Jiugongge unlock

Use of dynamic panels

Progress in visual weakly supervised learning
随机推荐
代码复查
How many stages did the development and evolution of data analysis go through?
Pat 1024 palindromic number (25 points) sum of large integers
用指针计算数组的个数
如何制作精美的图片
In order to control the risks, how to choose a franchise company?
code review
If you are a C developer, look at these three explicit programming techniques
The technology giants set up the meta universe standard forum to open up or build a besieged city?
Detailed explanation of Zadig's self-test and joint debugging sub environment for developers
IDC:阿里云获2021中国数据治理平台市场份额第一
阿海的忠告
ansible生产环境使用场景(七):批量部署elk客户端
Visual studio 2022 17.1 is now available!
TCP three handshakes and four waves
职业问诊 | 面试中被问到意向薪资时,该怎么回答?
10、标准I/O输入输出重定向及管道
There is no picture problem when using tcpdf to generate pdf
Appium automated test Jiugongge unlock
BOE was brilliant for the Winter Olympics, but revealed another Chinese technology enterprise dominating the world