xzero 2019-06-07
端午节又给叫醒了...好吧,又是ASM归档空间问题导致,说一下背景,因ASM空间不够,硬盘槽也插满了,每天归档量大概100G,所以在对UNDO表空间增加20G空间后隔天归档又爆了。
正常情况是3点执行增备脚本备份归档到本地并把ASM的归档清理掉,ASM保留的归档都是从3点往后算的,增加20G后终于达到了临界值,导致到3点前归档空间已经满了,无法执行相关的脚本并自动清理。
这里大概有几个解决方案:
1、对数据库瘦身,腾出空间
2、数据库整体迁移
3、买个主机,大概30万(领导否决了)
前面2个不是一时半会解决的,所以这里取个巧,把增备脚本改成每天多次执行,这样ASM的归档就不会保留一天了。
#!/bin/bash #this is rman auto incr backup script backtime=$(date +%Y%m%d%H%M) if [ -f ~/.bash_profile ]; then . ~/.bash_profile fi rman target / log=/backup/log/incr_$backtime.log <<EOF run { sql 'alter system archive log current'; allocate channel c1 type disk; allocate channel c2 type disk; backup as compressed backupset tag incr_backup_level1 incremental level 1 format '/backup/oradata/level1_%T_%t_s%s_p%p.bak' database; sql 'alter system archive log current'; backup as compressed backupset format '/backup/arch/archlog_%T_t%t_s%s_p%p.bak' archivelog all delete input; release channel c1; release channel c2; allocate channel d1 type disk; backup format '/backup/control/controlfile_%T_s%s_p%p.bak' current controlfile; crosscheck backup; crosscheck copy; delete noprompt expired backup; delete noprompt obsolete; delete noprompt backup of database completed before'sysdate-7'; release channel d1; } EOF
这里是利用backup ...all delete input的特性来清理掉ASM上的归档。
执行脚本后查看日志
可以看到空间已经减下来了。
00 03,12,23 * * 2-6,0 /home/oracle/scripts/level1_backup.sh
后面会分享更多devops和DBA方面内容,感兴趣的朋友可以关注下!