Tuesday, November 21, 2017

Oracle Database Health Check Report In HTML Format

Update: This post is considered obsolete, the main script can now send the report in either HTML/TEXT format, please refer to the original post:

 
If you don't have "sendmail" package installed on your Linux OS then this post will help you out.



I've got numerous requests asking to make the original health check report script to send its report in HTML format. In this post, I'll explain how to do so.

1- Download sendEmail executables which will allow the script to send the report as an attachment:
http://caspian.dotconf.net/menu/Software/SendEmail/

2- Extract sendEmail package files under the home directory of the Oracle software Owner e.g. /home/oracle:
# cd /home/oracle
# tar xvf sendEmail-v1.56.tar

3- Download the HTML version of Oracle Health Check Report script:
https://www.dropbox.com/s/5wh557fddiydsip/dbdailychk_html.sh?dl=0

Open the script with "vi" editor and replace "youremail@yourcompany.com" with your right email address at line# 90:
e.g. 
MAIL_LIST="john.smith@abc.com"

Please note that due to the limitation of the HTML options in OS commands, I've excluded some checks from being reported by this script [HTML version], like: Local File system & Cluster ware Service.

In case you don't like the HTML version and want to use the text based version [I encourage you to do so :-)] please visit the original post and download the text-based output version of this script:

Wednesday, November 1, 2017

Shell Script To Monitor/Check The Lag/Sync Status Between Primary And Standby Oracle Database

Script Description:
This Linux shell script runs from the PRIMARY DB server to monitor and checks the lag/synchronization status between Primary and Standby Oracle DBs and reports the lag [if happened] to the user.

Download the script:
https://www.dropbox.com/s/a9k3rn928vj3ooc/check_standby_lag.sh?dl=0

How to use the script:
 
First: On the Primary DB: Create a DBA user to be used inside the script to check the dataguard status:
e.g. This is just n example, you can create the user with a proper name and password.
 
SQL> create user DBA_USER identified by "ABC123" profile;
SQL> grant dba to
DBA_USER;
 

Second: Unfortunately, this script will not be able to know what is the primary, standby database names itself; so you must manually modify the variables' values in orange color in the Variables section to match your environment: [Those variables are at the begging of the script]

# ######################################
# Variables MUST be modified by the user: [Otherwise the script will not work]
# ######################################

# Here you replace youremail@yourcompany.com with your Email address:
EMAIL="youremail@yourcompany.com"

# Replace ${ORACLE_SID} with the Primary DB instance SID:
ORACLE_SID=${ORACLE_SID}

# Replace STANDBY_TNS_ENTRY with the Standby Instance TNS entry you configured in the primary site tnsnames.ora file: e.g. orcl_standby
DRDBNAME=STANDBY_DB

# Replace ${ORACLE_HOME} with the ORACLE_HOME path on the primary server:
ORACLE_HOME=${ORACLE_HOME}

# Log Directory Location:
LOG_DIR='/tmp'
 
# Here you replace DBA_USER with a real user having DBA privilege:
ID=DBA_USER

# Here you replace ABC123 with the DBA user password on the standby DB:
CRD='ABC123'

# Replace "5" with the number of LAGGED ARCHIVELOGS if reached an Email alert will be sent to the receiver:
LAGTHRESHOLD=5


You can schedule this script in the crontab to run e.g. every 15 minutes to get you alerted if the number of lagged archive logs cross the predefined threshold.

Reminder: This script runs from the primary DB server NOT from the standby server.
Hope you will find it useful.

This script is part of DBA Bundle scripts: http://dba-tips.blogspot.ae/2014/02/oracle-database-administration-scripts.html

Friday, March 10, 2017

RMAN Backup Shell Script for Oracle

This hassle free RMAN backup Shell script helps the DBA to take an on-demand self-contained & consistent RMAN backup for Oracle database resides on Linux OS. It will help to easily specify the number of channels, select backup options (Compression/Encryption) and then it will run in the background in nohup mode.

Script download:
https://www.dropbox.com/s/l3g17oxz6j56cdz/RMAN_full.sh?dl=0

How it works:

This script should run by the Oracle installation owner (e.g. oracle) it will do the following:
 - Will ask you to select the database number you want to backup from the list (in case multiple databases found).
 - Then it will ask for the backup location, and the number of channels to be allocated during the backup.
 - Then you will be asked to use special features such as Compression and Encryption for the backup.
 - Finally, RMAN script will be created and will run automatically in the background in nohup mode, and thus no need to bother about your session disconnect during the backup operation.


Tuesday, January 17, 2017

Script to delete applied archivelogs on a STANDBY database

This script is designed to run against STANDBY databases to deleted applied archives older than specific number of hours defined by the user. It maintains that un-applied archives remain un-touched.

Download the script:
https://www.dropbox.com/s/xx5o6b94rv5ps30/delete_applied_archives_on_standby.sh?dl=0


How to use the script:

⏩ Set MAIL_LIST variable to your E-mail to receive an email alert if archives are not applied. 
    e.g. MAIL_LIST="john.smith@abc.com"

Specify the candidate archives for deletion older than N hours by setting LAST_N_HOURS variable to the number of hours.

    e.g. Deleting applied archives older than 24 hours:
     LAST_N_HOURS=24

⏩ You can EXCLUDE any instance from having the script to run against by passing the INSTANCE_NAME you want to exclude to EXL_DB variable.

e.g. excluding orcl from archive deletion:

EXL_DB="\-MGMTDB|ASM|orcl"


⏩ You can use FORCE option when deleting the archives from RMAN console: [Y|N] [Default is NO]
    e.g. FORCE_DELETION=Y

⏩ You can decide to CROSSCHECK the archivelogs after the archivelogs deletion: [Y|N] [Default is YES]
    e.g. VALIDATE_ARCHIVES=Y

⏩ Also you can schedule it to run periodically in the Oracle's user crontab as well.

DISCLAIMER: THIS SCRIPT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY. IT IS PROVIDED "AS IS".