Tuesday 28 January 2020

sendmail: command not found)

i am not able to receive mail from my schedule job. when i check crontab log i find the below error.

 sendmail: command not found

So, Linux run crontab jobs with minimal environment variable settings. sendmail command located under /usr/sbin
so if you include PATH=/usr/sbin:$PATH is included in your script, issue will be fixed.

crontab log location in linux

crontab log location will be under /var/log.
log file name will be cron

[root@localhost]# ls -lrt /var/log/cron
-rw-------. 1 root root 1291442 Jan 28 16:00 /var/log/cron



running script in remote machine using ssh and redirecting output to local


If i want to run a script in remote server using ssh, the best method is copy using scp to any temp location in remote server then run using ssh, Lets say if you have numer of DB servers you want to check backup log status of all the servers and generate a report to get mail everyday. this post will be usefull.

in this case i want to run ora_fullbkp_check.sh in remote server and redirect output to local. this script will send hostname, db name, date, status

#!/bin/bash
Logfilecheck() {
DBNAME=`cat $LOGFILE|grep DBID|awk '{ print $5 }'`
DAY=`ls -lrt /u01/RMAN/logs/*FULL*|tail -1 |awk '{ print $6 $7}'`
ERRORLIST=`egrep "^RMAN-[0-9]*:|^ORA-[0-9]*:" $LOGFILE`
if [ -n "$ERRORLIST" ]
    then
        echo -e "`hostname`  $DBNAME  $DAY    Full_Backup    Failed"
    else
        echo -e "`hostname`  $DBNAME  $DAY    Full_Backup    success"
    fi
}

LOGFILE=`ls -lrt /u01/RMAN/logs/*FULL*|tail -2|head -1 |awk '{ print $9 }'`
if [ -n "$LOGFILE" ]; then
        Logfilecheck;
        else
        echo -e "`hostname`  NA  NA  Full_Backup    No_FUll_Backups"
        exit;
fi

we can run above script as below first scp then run using ssh, example as below:

scp ora_fullbkp_check.sh 192.168.52.101:/tmp/
ssh 192.168.52.101 "sh /tmp/ora_fullbkp_check.sh" > ora_full_bkp_report.log


output file ora_full_bkp_report.log will create locally and content as below.

test_serv oradb Jan28 success

oyou can put it in differnt shell script and run both commands in at a time as below.

cat  get_bkp_status.sh
scp ora_fullbkp_check.sh 192.168.52.101:/tmp/
ssh 192.168.52.101 "sh /tmp/ora_fullbkp_check.sh" > ora_full_bkp_report.log

Wednesday 8 January 2020

ORA-19809: limit exceeded for recovery files


When i try to switch logfile am getting below error.

SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;
ALTER SYSTEM ARCHIVE LOG CURRENT
*
ERROR at line 1:
ORA-16038: log 1 sequence# 6865 cannot be archived
ORA-19809: limit exceeded for recovery files
ORA-00312: online log 1 thread 1: '+DATA/ORCL/ONLINELOG/group_1.258.997872353'


 Check recovery dest and recovery dest size properly set or not. in my case recovery dest size set to 20 instead of 20G. it means its can alocate only 20 bytes and not sufficient for archive creation at all.

SQL> show parameter recovery

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string      +DATA
db_recovery_file_dest_size           big integer 20

i corrected it to 20G, issue resolved.

SQL> alter system set db_recovery_file_dest_size=20G;

System altered.

SQL> show parameter recovery

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string      +DATA
db_recovery_file_dest_size           big integer 20G


SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;

System altered.


Saturday 4 January 2020

ORA-27104: system-defined limits for shared memory was misconfigured

When i try to start the instance, i am getting below error.

ORA-27104: system-defined limits for shared memory was misconfigured


Solution:

In this case i have increased the kernel.shmmax to 75GB and SGA_TARGET is 50, after changes if i try to start the database getting below error.

SQL*Plus: Release 12.2.0.1.0 Production on Fri Jan 3 22:37:58 2020

Copyright (c) 1982, 2016, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup pfile='/tmp/pfile.ora';
ORA-27104: system-defined limits for shared memory was misconfigured


Note: when ever you increase shmmax we should also increase kernel.shmall.

Now kernal values as below:

kernel.shmmni = 4096
kernel.shmall = 12261931
kernel.shmmax = 75161927680

but shmall value should be as below.

kernel.shmall =  kernel.shmmax/kernel.shmmni

as per my kernal values  75161927680/4096=18350080, but currently its 12261931, i changed kernel.shmall  to 18350080, issue resolved i am able to start the database.

kernel.shmall = 18350080

Hope this help.