oracleRAC--归档日志的开启方法
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracleRAC--归档日志的开启方法相关的知识,希望对你有一定的参考价值。
参考技术Aoracle RAC——归档日志的开启方法
==================================
g R 要修改cluster_database参数 G R 和以后的版本就不需要了
例子( g R 或之前) srvctl stop database d RAC节点 sql>startup mount SQL> alter system set log_archive_dest_ = location=/racdb _arch scope=spfile sid= RAC SQL> alter system set log_archive_dest_ = location=/racdb _arch scope=spfile sid= RAC SQL> alter system set log_archive_dest_ = service=rac scope=spfile sid= RAC SQL> alter system set log_archive_dest_ = service=rac scope=spfile sid= RAC SQL> alter system set standby_archive_dest= /racdb _arch scope=spfile sid= RAC SQL> alter system set standby_archive_dest= /racdb _arch scope=spfile sid= RAC sql>alter system set cluster_database=false scope=spfile sql>shutdown immediate sql>startup mount sql>alter database archivelog sql>alter database open sql>alter system set cluster_database=true scope=spfile sql>shutdown immediate srvctl start database d RAC
例子( g R 或之后) 节点 SQL>startup mount SQL> alter system set log_archive_dest_ = location=/racdb _arch scope=spfile sid= RAC SQL> alter system set log_archive_dest_ = location=/racdb _arch scope=spfile sid= RAC SQL> alter system set log_archive_dest_ = service=rac scope=spfile sid= RAC SQL> alter system set log_archive_dest_ = service=rac scope=spfile sid= RAC SQL> alter system set standby_archive_dest= /racdb _arch scope=spfile sid= RAC SQL> alter system set standby_archive_dest= /racdb _arch scope=spfile sid= RAC srvctl stop database d RAC节点 SQL> startup mount SQL> alter database archivelog srvctl start database d RAC
测试归档日志的切换
节点一 二上分别执行切换日志操作如下 SQL> alter system switch logfile 操作执行这条语句 次
节点一查询 SQL> !ls l /racdb* /racdb _arch total rw r—— oracle oinstall Oct _ _ dbf rw r—— oracle oinstall Oct _ _ dbf rw r—— oracle oinstall Oct _ _ dbf rw r—— oracle oinstall Oct _ _ dbf rw r—— oracle oinstall Oct _ _ dbf /racdb _arch total rw rw—— oracle oinstall Oct _ _ dbf rw rw—— oracle oinstall Oct _ _ dbf rw rw—— oracle oinstall Oct _ _ dbf rw rw—— oracle oinstall Oct _ _ dbf rw rw—— oracle oinstall Oct _ _ dbf
节点二查询
SQL> !ls l /racdb* /racdb _arch total rw rw—— oracle oinstall Oct _ _ dbf rw rw—— oracle oinstall Oct _ _ dbf rw rw—— oracle oinstall Oct _ _ dbf rw rw—— oracle oinstall Oct _ _ dbf rw rw—— oracle oinstall Oct _ _ dbf /racdb _arch total rw r—— oracle oinstall Oct _ _ dbf rw r—— oracle oinstall Oct _ _ dbf rw r—— oracle oinstall Oct _ _ dbf rw r—— oracle oinstall Oct _ _ dbf rw r—— oracle oinstall Oct _ _ dbf
节点一 SQL> show parameter archive_dest NAME TYPE VALUE
log_archive_dest string log_archive_dest_ string location=/racdb _arch log_archive_dest_ string log_archive_dest_ string service=rac log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable standby_archive_dest string /racdb _arch
节点二
SQL> show parameter archive_dest NAME TYPE VALUE
log_archive_dest string log_archive_dest_ string location=/racdb _arch log_archive_dest_ string log_archive_dest_ string service=rac log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_ string log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable log_archive_dest_state_ string enable standby_archive_dest string /racdb _arch
lishixinzhi/Article/program/Oracle/201311/18379
Oracle RMAN删除归档日志脚本
Oracle 开启归档模式后,会一直不停的产生归档日志,如果不定时删除,迟早会撑爆磁盘空间,所以就需要布置定时删除归档日志的脚本!
至于为什么要开启归档模式,还有怎么开启归档模式!请参考:Oracle 开启归档模式
Linux 下删除归档脚本:
mkdir -p /home/oracle/scripts/log
vi /home/oracle/scripts/del_arch.sh
#!/bin/bash
source ~/.bash_profile
DAY_TAG=`date +"%Y-%m-%d"`
rman target / nocatalog msglog /home/oracle/scripts/log/del_arch_$DAY_TAG.log<<EOF
crosscheck archivelog all;
delete noprompt archivelog until time '(sysdate-7)';
delete noprompt force archivelog until time 'SYSDATE-10';
EOF
## 写入crontab
crontab -e
# 00 07 * * * /home/oracle/scripts/del_arch.sh
Windows 下删除归档脚本:
编辑 del_arch.bat
脚本:
@echo off
set ORACLE_SID=orcl
set "filename=del_arch_task_log_%date:~0,4%%date:~5,2%%date:~8,2%.log"
(
echo.
echo ====================cleaning %date% %time% =========================
echo.
rman target / cmdfile=G:\\scripts\\del_arch.sql
echo.
echo ===================== finish %date% %time% =========================
echo.
)>>G:\\scripts\\%filename% 2>&1<nul
编辑 del_arch.sql
脚本:
run{
crosscheck archivelog all;
delete noprompt archivelog until time 'sysdate-1/2';
delete noprompt force archivelog until time 'SYSDATE-1';
}
📢 注意:脚本中的目录位置,请根据实际情况进行修改!
本次分享到此结束啦~
如果觉得文章对你有帮助,点赞、收藏、关注、评论,一键四连支持,你的支持就是我创作最大的动力。
❤️ 技术交流可以 关注公众号:Lucifer三思而后行 ❤️
以上是关于oracleRAC--归档日志的开启方法的主要内容,如果未能解决你的问题,请参考以下文章