Hi,
Archivelogs in Oracle database are accumulated or kept when they are not deleted automatically.
You should define any deletion job for Standby database to delete older archivelogs automatically.
To delete archivelogs automatically, we need to create Crontab job in linux like following.
[[email protected] ~] crontab -e
Type following query in crontab to run RunDeleteArchive.sh bash script in 23:00
00 23 * * * sh /oracle/script/RunDeleteArchive.sh >/oracle/script/Delete.log [[email protected] ~]
You can list crontab job like following if it is created or not.
[[email protected] ~] crontab -l 00 23 * * * sh /oracle/script/RunDeleteArchive.sh >/oracle/script/Delete.log [[email protected] ~]
Open /oracle/script/RunDeleteArchive.sh bash script file with vi or vim editor and paste following scripts.
Firstly we set Oracle database environments after that we want to execute /oracle/script/DeleteArchive.rman script to connect rman and delete archivelogs.
[[email protected] ~] vi RunDeleteArchive.sh export ORACLE_BASE=/oracle/app export ORACLE_HOME=/oracle/app/product/12.1.0.2/db export LD_LIBRARY_PATH=$ORACLE_HOME/lib export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P9 export ORACLE_SID=DEVECIDG export PATH=$ORACLE_HOME/bin:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin:$PATH rman target / @/oracle/script/DeleteArchive.rman exit
you can see the content of /oracle/script/RunDeleteArchive.sh like following.
[[email protected] ~] cat RunDeleteArchive.sh export ORACLE_BASE=/oracle/app export ORACLE_HOME=/oracle/app/product/12.1.0.2/db export LD_LIBRARY_PATH=$ORACLE_HOME/lib export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P9 export ORACLE_SID=DEVECIDG export PATH=$ORACLE_HOME/bin:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin:$PATH rman target / @/oracle/script/DeleteArchive.rman exit
We need to insert following rman commands to the /oracle/script/DeleteArchive.rman file like following.
[[email protected] ~] vi DeleteArchive.rman run{ delete noprompt archivelog until time 'sysdate -1'; crosscheck archivelog all; } [[email protected] ~]
you can see the content of /oracle/script/DeleteArchive.rman like following.
[[email protected] ~] cat DeleteArchive.rman run{ delete noprompt archivelog until time 'sysdate -1'; crosscheck archivelog all; } [[email protected] ~]
Now Archivelogs older than 1 day in Standby database will be deleted automatically in Oracle dataguard.
Do you want to learn Oracle Database for Beginners, then read the following articles.
https://ittutorial.org/oracle-database-19c-tutorials-for-beginners/
2,470 views last month, 1 views today