總覺得使用windows跑oracle是不靠譜的事情,可以這個世界上總有很多人喜歡做類似這樣的事情,對于數(shù)據(jù)庫比較常見的兩件事情:rman和刪除dg備庫歸檔日志,在linux/unix平臺上使用shell實(shí)現(xiàn)很簡單,可是跑到win里面,就變的煩了,不是因?yàn)槠渎闊?而是因?yàn)橛玫娜松?不知道怎么下手處理該事情,我編寫了簡單的實(shí)現(xiàn)初級功能的win下面rman備份和刪除備庫歸檔日志腳本,供大家參考,也更加歡迎朋友提出來更加好的處理方法(win是真心的不懂)
rman備份腳本
復(fù)制代碼 代碼如下:
--backup_oracle.bat文件
rman target / cmdfile=D:/backup/rman/backup_db.rman
log=d:/backup/rman/logfile/rmanlog%date:~0,4%%date:~5,2%%date:~8,2%.log
--backup_db.rman文件
CONFIGURE RETENTION POLICY TO REDUNDANCY = 2;
CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
backup filesperset = 5 as compressed backupset database format 'd:/backup/rman/full_%U.rman';
sql 'alter system archive log current';
backup filesperset = 50 as compressed backupset archivelog all format 'd:/backup/rman/arch_%U.rman' delete input;
DELETE noprompt OBSOLETE;
crosscheck backup;
delete noprompt expired backup;
backup format 'd:/backup/rman/ctl_%U.rman' current controlfile;
backup spfile format 'd:/backup/rman/spfile_%U.rman' ;
exit;
backup_oracle.bat
文件加入到計劃任務(wù)即可
刪除dg備庫歸檔日志(已經(jīng)應(yīng)用)
復(fù)制代碼 代碼如下:
--delete_dg_archivelog.bat
rem 注意修改 部署目錄
cd D:/win_xifenfei
d:
rem 注意delete_archive.sql 查詢是否有記錄
echo delete archivelog staring > delete_archivelog.bak
sqlplus / as sysdba @delete_archive.sql
echo rman target / cmdfile=rman_checkcross.rman>>delete_archivelog.bat
delete_archivelog.bat >>delete_dg_archivelog_%DATE:~0,4%%DATE:~5,2%%DATE:~8,2%".log
exit
--delete_archive.sql
set lines 150
col name for a150
set pagesize 0 feedback off verify off heading off echo off
spool delete_archivelog.bat
select 'del '||name from v$archived_log where APPLIED='YES' AND NAME IS NOT NULL and DEST_ID=1;
spool off
exit;
--rman_checkcross.rman
crosscheck archivelog all;
delete noprompt expired archivelog all;
exit
delete_dg_archivelog.bat
加入到計劃任務(wù)即可
您可能感興趣的文章:- DBCA命令行搭建Oracle ADG的流程
- Oracle 給rac創(chuàng)建單實(shí)例dg并做主從切換功能
- Oracle 10g DG 數(shù)據(jù)文件遷移的實(shí)現(xiàn)
- 詳解Oracle dg 三種模式切換
- Oracle數(shù)據(jù)庫 DGbroker三種保護(hù)模式的切換
- Oracle區(qū)別ADG與DG案例詳解