ORACLE归档日志满,没法访问

一、临时解决归档日志满,没法访问的问题:
su - oracle
rman target/

crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt archivelog until time ‘sysdate-1’;
delete noprompt archivelog all completed before ‘sysdate-1’;

可以看到归档日志被删除。
此刻,尝试连接数据库,仍旧连不上。
采用重启lsnrctl 的方式:
从rman模式quit出来:
lsnrctl stop
lsnrctl start

再试图尝试连接,成功。

二、写 定时任务 定期删归档

#su - oracle
$ mkdir -p /home/oracle/scripts/log
$ vi /home/oracle/scripts/rm_archivelog.sh

#!/bin/sh
#rm archivelog Script 
export ORACLE_HOME=/u01/app/oracle/product/11.2
export ORACLE_SID=sugondb
export DBNAME=sugondb
export PATH=$ORACLE_HOME/bin:$PATH
year=`date "+%Y"`
month=`date "+%m"`
day=`date "+%d"`
hour=`date "+%H"`
min=`date "+%M"`
sec=`date "+%S"`
bakdate=$year$month$day
baktime=$hour$min$sec
SCRIPT_DIR=/home/oracle/scripts
CMDFILE=$SCRIPT_DIR/rm_archivelog.rman
LOGFILE=$SCRIPT_DIR/log/${bakdate}_${baktime}_rmarch.log
cd /home/oracle
>$CMDFILE
cat <<EOF >>$CMDFILE
run{
crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt archivelog until time 'sysdate-1';
delete noprompt archivelog all completed before 'sysdate-1';
}
EOF
rman target /  log=${LOGFILE} < $CMDFILE

#给文件提权
$ chmod u+x /home/oracle/scripts/rm_archivelog.sh

#创建计划任务
#su - oracle
$ crontab -e
25 3 * * 3 /home/oracle/scripts/rm_archivelog.sh > /dev/null


ps:rm_archivelog.sh 文件中的3个值:
export ORACLE_HOME=/u01/app/oracle/product/11.2
export ORACLE_SID=sugondb
export DBNAME=sugondb
要根据实际部署环境的值来修改

你可能感兴趣的:(数据库技术,#,ORACLE,oracle,数据库)