Announcements

Oracle training based on real-time expertise as per industry standards. Upcoming batch details are here.

View batch schedule

Free Oracle mock interview. Register using the link.

Register

#DBAchallenge: submit your questions.

Ask questions
Swipe for more →
Browse by Topic
Latest Posts

    Tuesday, April 2, 2024

    Automation Script | Archive Log Deletion

    1. List all the database running on the server 


    [oracle@oracledb ~]$ ps -ef|grep smon
    oracle    2524     1  0 12:53 ?        00:00:00 ora_smon_GGSOURCE
    oracle    3122     1  0 12:54 ?        00:00:00 ora_smon_ORA12C
    oradev    4029     1  0 12:56 ?        00:00:00 ora_smon_ORACDB
    oracle   13118     1  0 Feb22 ?        00:00:56 ora_smon_ORCL
    oracle   19878 18177  0 17:14 pts/0    00:00:00 grep --color=auto smon
    [oracle@oracledb ~]$

    2. Check the archivelog deletion script scheduled via crontab job which is scheduled to run every Sunday 


    [oracle@oracledb ~]$ crontab -l
    0 0 * * SUN /home/oracle/RMAN/delete_archivelog.sh
    [oracle@oracledb ~]$

    3. Archive log deletion script 


    [oracle@oracledb ~]$ more /home/oracle/RMAN/delete_archivelog.sh
    unset PATH
    export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/oracle/.local/bin:/home/oracle/bin
    export ORACLE_SID=ORCL
    export ORACLE_BASE=/u01/app/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/19.0.0.0/dbhome_1
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib
    export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
    export PATH=$PATH:$ORACLE_HOME/bin
    rman target / <<EOF
    crosscheck archivelog all;
    delete noprompt archivelog all completed before 'sysdate-2';
    quit;
    EOF

    unset PATH
    export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/oracle/.local/bin:/home/oracle/bin
    export ORACLE_SID=ORA12C
    export ORACLE_BASE=/u01/app/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/12.2.0.1/dbhome_1
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib
    export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
    export PATH=$PATH:$ORACLE_HOME/bin
    rman target / <<EOF
    crosscheck archivelog all;
    delete noprompt archivelog all completed before 'sysdate-2';
    quit;
    EOF

    unset PATH
    export PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/oracle/.local/bin:/home/oracle/bin
    export ORACLE_SID=GGSOURCE
    export ORACLE_BASE=/u01/app/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/19.0.0.0/dbhome_1
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib
    export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
    export PATH=$PATH:$ORACLE_HOME/bin
    rman target / <<EOF
    crosscheck archivelog all;
    delete noprompt archivelog all completed before 'sysdate-2';
    quit;
    EOF
    [oracle@oracledb ~]$

    4. On-demand execution of the archive log deletion script


    [oracle@oracledb ~]$ sh /home/oracle/RMAN/delete_archivelog.sh

    Recovery Manager: Release 19.0.0.0.0 - Production on Mon Apr 1 17:16:25 2024
    Version 19.11.0.0.0

    Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

    connected to target database: ORCL (DBID=1607315920)

    RMAN>
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=148 device type=DISK
    validation succeeded for archived log
    archived log file name=/u01/backup/1_11052_1153385377.dbf RECID=20840 STAMP=1164979956
    validation succeeded for archived log
    archived log file name=/u01/backup/1_11053_1153385377.dbf RECID=20843 STAMP=1164980856
    validation succeeded for archived log
    archived log file name=/u01/backup/1_11054_1153385377.dbf RECID=20844 STAMP=1164981756
    Crosschecked 3 objects


    RMAN>
    released channel: ORA_DISK_1
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=148 device type=DISK
    List of Archived Log Copies for database with db_unique_name ORCL
    =====================================================================

    Key     Thrd Seq     S Low Time
    ------- ---- ------- - ---------
    20840   1    11052   A 30-MAR-24
            Name: /u01/backup/1_11052_1153385377.dbf

    20843   1    11053   A 30-MAR-24
            Name: /u01/backup/1_11053_1153385377.dbf

    20844   1    11054   A 30-MAR-24
            Name: /u01/backup/1_11054_1153385377.dbf

    deleted archived log
    archived log file name=/u01/backup/1_11052_1153385377.dbf RECID=20840 STAMP=1164979956
    deleted archived log
    archived log file name=/u01/backup/1_11053_1153385377.dbf RECID=20843 STAMP=1164980856
    deleted archived log
    archived log file name=/u01/backup/1_11054_1153385377.dbf RECID=20844 STAMP=1164981756
    Deleted 3 objects


    RMAN>

    Recovery Manager complete.

    Recovery Manager: Release 12.2.0.1.0 - Production on Mon Apr 1 17:16:28 2024

    Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

    connected to target database: ORA12C (DBID=535155273)

    RMAN>
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=392 device type=DISK
    specification does not match any archived log in the repository

    RMAN>
    released channel: ORA_DISK_1
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=392 device type=DISK
    specification does not match any archived log in the repository

    RMAN>

    Recovery Manager complete.

    Recovery Manager: Release 19.0.0.0.0 - Production on Mon Apr 1 17:16:30 2024
    Version 19.11.0.0.0

    Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

    connected to target database: GGSOURCE (DBID=3191778824)

    RMAN>
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=148 device type=DISK
    specification does not match any archived log in the repository

    RMAN>
    released channel: ORA_DISK_1
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=148 device type=DISK
    specification does not match any archived log in the repository

    RMAN>

    Recovery Manager complete.
    [oracle@oracledb ~]$


    Regards,
    Mallikarjun / Vismo Technologies
    WhatsApp: +91 9880616848 / +91 9036478079
    Cell: +91 9880616848 / +91 9036478079
    Email: mallikarjun.ramadurg@gmail.com / vismotechnologies@gmail.com / info@vismotechnologies.com

    No comments:

    Post a Comment

    🌟 Proud to be an Oracle ACE Pro! 🚀

    🌟 Proud to be an Oracle ACE Pro! 🚀 I’m excited to share my official Oracle ACE Profile with the Oracle community. 👨‍💻 Mallikarjun ...