dataguard oracle 归档管理脚本

前端之家收集整理的这篇文章主要介绍了dataguard oracle 归档管理脚本前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

管理部分

如果没有启用database force logging,则备库对/*+ append */操作,nologging操作,会报坏块;

建议表空间force logging或者database force logging;

--force logging /nologging 测试

  1. alterdatabaseforcelogging;
  2. selectforce_loggingfromdba_tablespaces;
  3. selectforce_loggingfromv$database;
  4. altertablespacetestforcelogging;
  5. selectlogging,table_name,tablespace_namefromuser_tableswheretable_name='TEST';
  6. altertablespacetestnoforcelogging;
  7. selecttablespace_name,logging,force_loggingfromdba_tablespaces;

##配置主库的归档删除策略

  1. CONFIGUREARCHIVELOGDELETIONPOLICYTOAPPLIEDONSTANDBY;

--传过去就删除

  1. CONFIGUREARCHIVELOGDELETIONPOLICYTOSHIPPEDTOSTANDBY;

备库删除脚本

vi delete_archive.sh

  1. #!/bin/sh
  2. source/home/oracle/.bash_profile
  3. exportORACLE_SID=standby
  4. TABLE='v$archived_log'
  5. $ORACLE_HOME/bin/sqlplus-silent"/assysdba"<<EOF
  6. setheadingoff;
  7. setpagesize0;
  8. settermoff;
  9. setFeedbackoff;
  10. setlinesize199;
  11. settrimson;
  12. setverifoff;
  13. spool/home/oracle/scripts/del_arch.sh;
  14. select'rm-rf'||namefromv\$archived_logwhereDELETED='NO'andAPPLIED='YES';
  15. spooloff;
  16. exit;
  17. EOF
  18. chmod+x/home/oracle/scripts/del_arch.sh
  19. sh/home/oracle/scripts/del_arch.sh
  20. rmantarget/<<EOF
  21. crosscheckarchivelogall;
  22. deletenopromptexpiredarchivelogall;
  23. exit;
  24. EOF

增加定时任务:crontab -e

  1. 01***su-oracle-c/home/oracle/scripts/delete_archive.sh1

备库自启动脚本:

vi /etc/rc.local

  1. su-oracle-c/home/oracle/scripts/start_db.sh
  2. vistart_db.sh
  3. source/home/oracle/.bash_profile
  4. lsnrctlstart
  5. exportORACLE_SID=standby
  6. sqlplus/assysdba<<EOF
  7. startup;
  8. recovermanagedstandbydatabaseusingcurrentlogfiledisconnectfromsession;
  9. exit

猜你在找的Oracle相关文章