Pages

Thursday, February 18, 2021

GG Restart from crontab

=========================
General
=========================

 Restart GG processes from crontab

=========================
Code
=========================
crontab entry
1 06 1 * * /software/oracle/oracle/scripts/gg_restart/gg_restart_all_groups.sh

gg_restart_all_groups.sh
#!/bin/bash

WORK_HOME=/software/oracle/oracle/scripts/gg_restart
LOG_FILE=gg_restart.log

cd $WORK_HOME

./gg_restart_log.sh "${WORK_HOME}" "${LOG_FILE}" "START"

./gg_restart_group.sh EXT_S "ext ext_s*" "${WORK_HOME}" "${LOG_FILE}"
./gg_restart_group.sh EXT_P "ext ext_p*" "${WORK_HOME}" "${LOG_FILE}"
./gg_restart_group.sh EXT_I "ext ext_i*" "${WORK_HOME}" "${LOG_FILE}"

./gg_restart_group.sh DPM_S "ext dpm_s*" "${WORK_HOME}" "${LOG_FILE}"
./gg_restart_group.sh DPM_P "ext dpm_p*" "${WORK_HOME}" "${LOG_FILE}"
./gg_restart_group.sh DPM_I "ext dpm_i*" "${WORK_HOME}" "${LOG_FILE}"

./gg_restart_group.sh REP_S "rep rep_s*" "${WORK_HOME}" "${LOG_FILE}"
./gg_restart_group.sh REP_P "rep rep_p*" "${WORK_HOME}" "${LOG_FILE}"
./gg_restart_group.sh REP_I "rep rep_i*" "${WORK_HOME}" "${LOG_FILE}"

./gg_restart_log.sh "${WORK_HOME}" "${LOG_FILE}" "FINISH" 


gg_restart_log.sh

#!/bin/bash

WORK_HOME=$1
LOG_FILE_NAME=$2
VERB=$3

cd $WORK_HOME

LOG_FILE=${WORK_HOME}/${LOG_FILE_NAME}
RUN_DATE=`date "+%Y%m%d"_"%H%M%S"`

touch $LOG_FILE

if [[ $VERB == "START" ]]; then

 echo "" >>$LOG_FILE
 echo ========================================== >>$LOG_FILE
 echo Start at $RUN_DATE >>$LOG_FILE
 echo ========================================== >>$LOG_FILE
 echo "" >>$LOG_FILE
 echo "Before Restart: " >>$LOG_FILE
 echo "" >>$LOG_FILE 
 free -m >> $LOG_FILE
 echo "" >> $LOG_FILE
 sar -r >> $LOG_FILE
  echo "" >>$LOG_FILE 
fi

if [[ $VERB == "FINISH" ]]; then
  echo "" >>$LOG_FILE
  echo "---------------------------" >>$LOG_FILE
  echo "After Restart: " >>$LOG_FILE
  echo "---------------------------" >>$LOG_FILE  
  echo "" >>$LOG_FILE  
  free -m >> $LOG_FILE
  echo "" >> $LOG_FILE
  sar -r >> $LOG_FILE
  echo "" >>$LOG_FILE    
  echo ========================================== >>$LOG_FILE
  echo Finished at $RUN_DATE >>$LOG_FILE
  echo ========================================== >>$LOG_FILE
  echo "" >>$LOG_FILE
fi

exit 0 

gg_restart_group.sh
#!/bin/bash

GROUP_NAME=$1
RESTART_GROUP=$2
WORK_DIR=$3
LOG_FILE_NAME=$4

#GROUP_NAME=EXT_S
#RESTART_GROUP="ext ext_s*"

LOG_FILE=${WORK_DIR}/${LOG_FILE_NAME}


clear
echo "Restarting ${GROUP_NAME} ${RESTART_GROUP}" >> ${LOG_FILE}
echo "Log File is: ${LOG_FILE}"
exit 0

. /etc/profile > /dev/null 2> /dev/null
TEMP_LOG_FILE="/tmp/restart_temp.tmp"

RUN_DATE=`date "+%Y%m%d"_"%H%M%S"`

# Setting Oracle GoldenGate environments
if [ "$OGGSH" = "" ]; then
   OGGSH=$INFRA_ROOT/oggsh
fi

if [ "$ORACLE_SID" = "" ]; then
   INSTANCE=igt
else
   INSTANCE=$ORACLE_SID
fi
. $OGGSH/gg_login.sh $INSTANCE

touch $LOG_FILE
touch $TEMP_LOG_FILE

echo "" >>$LOG_FILE
echo ========================================== >>$LOG_FILE
echo Start Restart for ${GROUP_NAME} group ${RESTART_GROUP} at $RUN_DATE >>$LOG_FILE
echo ========================================== >>$LOG_FILE
echo "" >>$LOG_FILE
echo ========================================== >>$LOG_FILE
echo Initial State >>$LOG_FILE
echo ========================================== >>$LOG_FILE
echo "" >>$LOG_FILE

$GG_HOME/ggsci >$TEMP_LOG_FILE <<EOD
info all
exit
EOD
cat  $TEMP_LOG_FILE | grep ${GROUP_NAME} >>$LOG_FILE

echo about to do  "stop ext $RESTART_GROUP" >>$LOG_FILE

$GG_HOME/ggsci >$TEMP_LOG_FILE <<EOF
stop ${RESTART_GROUP}
exit
EOF
cat  $TEMP_LOG_FILE >>$LOG_FILE

echo "" >>$LOG_FILE
echo ========================================== >>$LOG_FILE
echo After Stop >>$LOG_FILE
echo ========================================== >>$LOG_FILE
echo "" >>$LOG_FILE

sleep 10

$GG_HOME/ggsci >$TEMP_LOG_FILE <<EOD
info all
exit
EOD
cat  $TEMP_LOG_FILE | grep ${GROUP_NAME}  >>$LOG_FILE


echo "Starting  ${RESTART_GROUP}" >> $LOG_FILE

$GG_HOME/ggsci >$TEMP_LOG_FILE <<EOF
start ${RESTART_GROUP}
exit
EOF
cat $TEMP_LOG_FILE >>$LOG_FILE

echo "" >>$LOG_FILE
echo ========================================== >>$LOG_FILE
echo After Start >>$LOG_FILE
echo ========================================== >>$LOG_FILE
echo "" >>$LOG_FILE

sleep 10

$GG_HOME/ggsci >$TEMP_LOG_FILE <<EOD
info all
exit
EOD
cat  $TEMP_LOG_FILE | grep ${GROUP_NAME} >>$LOG_FILE


NOT_RUNNING=`grep STOPPED $TEMP_LOG_FILE |grep ${GROUP_NAME} | wc -l`

if [ $NOT_RUNNING -gt 0 ]; then

echo "Some Processes were not started. Attempting restart" >>$LOG_FILE

$GG_HOME/ggsci >$TEMP_LOG_FILE <<EOF
start ${RESTART_GROUP}
exit
EOF
cat $TEMP_LOG_FILE >>$LOG_FILE

fi

#============================================================
# Second restart
#============================================================
sleep 10

$GG_HOME/ggsci >$TEMP_LOG_FILE <<EOD
info all
exit
EOD
cat  $TEMP_LOG_FILE | grep ${GROUP_NAME} >>$LOG_FILE

NOT_RUNNING=`grep STOPPED $TEMP_LOG_FILE | wc -l`
if [ $NOT_RUNNING -gt 0 ]; then

echo "Some Processes were not started. Attempting restart" >>$LOG_FILE

$GG_HOME/ggsci > $TEMP_LOG_FILE <<EOF
start ${RESTART_GROUP}
exit
EOF
cat $TEMP_LOG_FILE >>$LOG_FILE

sleep 10

$GG_HOME/ggsci >$TEMP_LOG_FILE <<EOD
info all
exit
EOD
cat  $TEMP_LOG_FILE | grep ${GROUP_NAME} >>$LOG_FILE

fi

echo "" >>$LOG_FILE
echo ========================================== >>$LOG_FILE
echo Finished Restart for $GROUP_NAME $RESTART_GROUP at $RUN_DATE >>$LOG_FILE
echo ========================================== >>$LOG_FILE
echo "" >>$LOG_FILE
 




Monday, February 8, 2021

sftp script example

sftp script example

sftp user@111.222.333.444 << EOF
cd /some/path/on/target/server
put /some/path/on/from/server/some_file.*.dat
exit
EOF

Tuesday, February 2, 2021

expdp is slow. AWR showing Streams AQ: enqueue block as main wait event

===============
Issue
===============
expdp is running for several hours
AWR is showing Streams AQ: enqueue blocked as main Foreground Wait Event
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 

===============
AWR Evidences
===============

Foreground Wait Events                   DB/Inst: IGT/igt  Snaps: 39049-39050
-> s  - second, ms - millisecond -    1000th of a second
-> Only events with Total Wait Time (s) >= .001 are shown
-> ordered by wait time desc, waits desc (idle events last)
-> %Timeouts: value of 0 indicates value was < .5%.  Value of null is truly 0
                                                             Avg
                                        %Time Total Wait    wait    Waits   % DB
Event                             Waits -outs   Time (s)    (ms)     /txn   time
-------------------------- ------------ ----- ---------- ------- -------- ------
Streams AQ: enqueue blocke        1,767     0      2,656    1503      0.2   95.2
db file sequential read          74,898     0          8       0      6.8     .3
log file sync                     2,564     0          2       1      0.2     .1
enq: RO - fast object reus          216     0          1       5      0.0     .0
SQL*Net message to client     2,475,101     0          1       0    224.9     .0
local write wait                    504     0          0       1      0.0     .0
library cache: mutex X            4,931     0          0       0      0.4     .0
SQL*Net more data from cli       21,140     0          0       0      1.9     .0



SQL ordered by Elapsed Time              DB/Inst: IGT/igt  Snaps: 39049-39050
-> Resources reported for PL/SQL code includes the resources used by all SQL
   statements called by the code.
-> % Total DB Time is the Elapsed Time of the SQL statement divided
   into the Total Database Time multiplied by 100
-> %Total - Elapsed Time  as a percentage of Total DB time
-> %CPU   - CPU Time      as a percentage of Elapsed Time
-> %IO    - User I/O Time as a percentage of Elapsed Time
-> Captured SQL account for    3.0% of Total DB Time (s):           2,789
-> Captured PL/SQL account for  445.8% of Total DB Time (s):           2,789

        Elapsed                  Elapsed Time
        Time (s)    Executions  per Exec (s)  %Total   %CPU    %IO    SQL Id
---------------- -------------- ------------- ------ ------ ------ -------------
         3,536.5              0           N/A  126.8     .6     .0 bja07yskmzxn1
 BEGIN SYS.KUPW$WORKER.MAIN('SYS_EXPORT_FULL_01', 'SHDAEMON', 0); END;

         3,482.5          1,769          1.97  124.9     .1     .0 8rgw5q94paqsg
Module: Data Pump Master
BEGIN sys.kupc$que_int.send(:1, :2, :3); END;

         2,660.5              0           N/A   95.4     .1     .0 a103q4nq8cdj7
 BEGIN SYS.KUPM$MCP.MAIN('SYS_EXPORT_FULL_01', 'SHDAEMON', 0, 0); END;

         2,592.6          1,718          1.51   93.0     .0     .0 87nt40c5wj7y5
Module: Data Pump Master
BEGIN sys.kupc$que_int.put_status(:1, :2, :3); END;

====================
What to check
====================
1. streams_pool_size Parameter

COL name FOR A30
COL value FOR A30
SELECT name, value 
  FROM V$PARAMETER WHERE name LIKE '%stream%';

NAME                VALUE
------------------- ------------
streams_pool_size   0

2. streams pool size Hidden Parameters

set pagesize 35
set linesize 150
col NAME format a40
col VALUE format a20
col DESCRIPTION format a60
set pause on
set pause 'Hit enter to continue'

SELECT x.ksppinm NAME, y.ksppstvl VALUE, x.ksppdesc DESCRIPTION
FROM x$ksppi x, x$ksppcv y
WHERE x.inst_id = userenv('Instance')
AND y.inst_id = userenv('Instance')
AND x.indx = y.indx
AND SUBSTR(LOWER(x.ksppinm),1,1) = '_'
AND x.ksppinm LIKE '%streams%'
ORDER BY 1;

NAME                                     VALUE                DESCRIPTION
---------------------------------------- -------------------- 
------------------------------------------------------------
__streams_pool_size                      33554432             
Actual size in bytes of streams pool
_disable_streams_diagnostics             0                    
streams diagnostics
_disable_streams_pool_auto_tuning        FALSE                
disable streams pool auto tuning
_memory_broker_shrink_streams_pool       900                  
memory broker allow policy to shrink streams pool
_streams_pool_max_size                   0                    
streams pool maximum size when auto SGA enabled

_streams_pool_size is set to 32 Mb which is too small for this big DB
 

====================
Solution
====================
Although streams_pool_size is set to zero, Oracle does not really tune streams_pool_size.
It just is using the default value of hidden parameter __streams_pool_size.

Option A - Set a high value to streams_pool_size to override Oracle default.

SQL> ALTER SYSTEM SET STREAMS_POOL_SIZE=256M SCOPE=MEMORY;
System altered.

And check results

or
ALTER SYSTEM SET STREAMS_POOL_SIZE=256M SCOPE=SPFILE;
And restart Instance.


Option B - Alter hidden parameter _disable_streams_pool_auto_tuning set value to TRUE. 
This is will disable  Oracle tuning to streams pool size.

ALTER SYSTEM SET "_disable_streams_pool_auto_tuning"=TRUE SCOPE=SPFILE;
And restart Instance.


Backup to pfile:
CREATE PFILE = '/software/oracle/112/dbs/igt_init_pfile_20210202.ora' FROM SPFILE;

File created.

!ls /software/oracle/112/dbs/igt_init_pfile_20210202.ora
/software/oracle/112/dbs/igt_init_pfile_20210202.ora

====================
Oracle Metalink #1596645:
====================
Oracle has this issue documented:
EXPDP And IMPDP Slow Performance In 11R2 and 12R1 And Waits On Streams AQ: Enqueue Blocked On Low Memory (Doc ID 1596645.1)
Version: Oracle Release 11.2.0.4 

Issue:
There is high wait for "Streams AQ: enqueue blocked on low memory"

Solution:
Increase streams_pool_size.  Say to 256M
CONNECT / as sysdba
ALTER SYSTEM SET streams_pool_size=256m SCOPE=both;

If above does not help, perform:
ALTER SYSTEM SET "_disable_streams_pool_auto_tuning"=TRUE SCOPE=spfile;
SHUTDOWN IMMEDIATE
STARTUP

If increasing streams_pool_size, you may have to increase your SGA_TARGET or MEMORY_TARGET also.
SGA_TARGET or MEMORY_TARGET should be high enough

SELECT name, value 
  FROM V$PARAMETER 
WHERE name LIKE '%target%';

NAME                           VALUE
------------------------------ ------------------------------
sga_target                     0
memory_target                  8589934592
memory_max_target              8589934592



SELECT component, 
       ROUND(current_size/1024/1024)current_size_Mb, 
       ROUND(MAX_SIZE/1024/1024)max_size_mb, 
       ROUND(USER_SPECIFIED_SIZE/1024/1024) user_def_size_mb
  FROM V$SGA_DYNAMIC_COMPONENTS;


COMPONENT               CURRENT_SIZE_MB MAX_SIZE_MB USER_DEF_SIZE_MB
----------------------- --------------- ----------- ----------------
shared pool                        2944        2944                0
large pool                          640         768                0
java pool                           384         512                0
streams pool                       1152        1152              512
DEFAULT buffer cache              21376       21504                0
KEEP buffer cache                     0           0                0
RECYCLE buffer cache                  0           0                0
DEFAULT 2K buffer cache               0           0                0
DEFAULT 4K buffer cache               0           0                0
DEFAULT 8K buffer cache               0           0                0
DEFAULT 16K buffer cache           6144        6144             6144
DEFAULT 32K buffer cache              0           0                0
Shared IO Pool                      512         512              512
Data Transfer Cache                   0           0                0
In-Memory Area                        0           0                0
ASM Buffer Cache                      0           0                0

Monday, January 18, 2021

Memory Usage Monitoring script. For SWAP using processes, Golden Gate, Top 20 oracle processes.

crontab

 0,15,30,45 * * * * /software/oracle/oracle/scripts/memory_usage/gg_mem_usage_wrapper.sh

gg_mem_usage_wrapper.sh
#!/bin/bash
WORK_DIR=/software/oracle/oracle/scripts/memory_usage
LOG_FILE=gg_memory.log
RUN_DATE=`date +"%Y%m%d"_"%H%M%S"`

cd ${WORK_DIR}
touch ${LOG_FILE}
echo " " >> ${LOG_FILE}
echo "=================" >> ${LOG_FILE}
echo ${RUN_DATE} >> ${LOG_FILE}
./gg_mem_usage.sh >> ${LOG_FILE}
echo " " >> ${LOG_FILE}
free -m >> ${LOG_FILE}
echo " " >> ${LOG_FILE}

echo "Top 20 Processes" >> ${LOG_FILE}
ps -eo rss,pid,euser,lstart,args:100 --sort %mem | grep -v grep | sort -n | tail -20 | awk '{printf $1/1024 "MB"; $1=""; print }' >> ${LOG_FILE}
echo " " >> ${LOG_FILE}

echo "Top SWAP Using Processes" >> ${LOG_FILE}
echo " " >> ${LOG_FILE}
echo "SWAP Usage from free -m" >> ${LOG_FILE}
free -m | grep Swap >> ${LOG_FILE}
echo " " >> ${LOG_FILE}
echo "SWAP Usage from /proc" >> ${LOG_FILE}
find /proc -maxdepth 2 -path "/proc/[0-9]*/status" -readable -exec awk -v FS=":" '{process[$1]=$2;sub(/^[ \t]+/,"",process[$1]);} END {if(process["VmSwap"] && process["VmSwap"] != "0 kB") printf "%10s %-30s %20s\n",process["Pid"],process["Name"],process["VmSwap"]}' '{}' \; | awk '{print $(NF-1),$0}' | sort -hr | head | cut -d " " -f2- >> ${LOG_FILE}
echo " " >> ${LOG_FILE}

exit

gg_mem_usage.sh
#!/bin/bash
###############################
# determine the OS type
###############################
OSNAME=`uname`
case "$OSNAME" in
  "SunOS")
    echo "OSNAME = $OSNAME"
    ;;
  "Linux")
    echo "OSNAME = $OSNAME"
    ;;
  "*")
    echo "This script has not been verified on $OSNAME"
    exit 1
    ;;
esac
###############################
# set the temp file
###############################
TMPFILE=/tmp/pmem.tmp
if [ -f $TMPFILE ]
then
  rm -f $TMPFILE
fi
################################
# loop over the gg process types
################################
PROCESSES="extract replicat"
for PROCESS in $PROCESSES
do
  FLAG=""
  FLAG=`ps -ef | grep $PROCESS`
  if [ -z "FLAG" ]
  then
    echo "No $PROCESS processes found"
  else
    echo
    echo "#####################################"
    echo "# Individual $PROCESS Process Usage #"
    echo "#####################################"
    case "$OSNAME" in
      "Linux")
        ps -C $PROCESS -O rss > $TMPFILE
        cat $TMPFILE | grep $PROCESS | awk '{print $2/1024, "MB", $12}' | sort -k 2
        ;;
      "SunOS")
        ps -efo vsz,uid,pid,ppid,pcpu,args | grep -v grep | grep $PROCESS > $TMPFILE
        cat $TMPFILE | grep $PROCESS | awk '{print $1/1024, "MB", $8}' | sort -k 2
        ;;
      "*")
        echo "This script has not been verified on $OSNAME"
        exit 1
        ;;
    esac
    rm -f $TMPFILE
    echo
    echo "#####################################"
    echo "#   Total $PROCESS Process Usage    #"
    echo "#####################################"
    case "$OSNAME" in
      "Linux")
        ps -C $PROCESS -O rss > $TMPFILE
        cat $TMPFILE | grep $PROCESS | awk '{count ++; sum=sum+$2; } END \
          { print "Number of processes      =",count; \
          print "AVG Memory usage/process =",sum/1024/count, "MB"; \
          print "Total memory usage       =", sum/1024,  " MB"}'
        ;;
      "SunOS")
        ps -efo vsz,uid,pid,ppid,pcpu,comm | grep -v grep | grep $PROCESS > $TMPFILE
        cat $TMPFILE | awk '{count ++; sum=sum+$1; } END \
          { print "Number of processes      =",count; \
          print "AVG Memory usage/process =",sum/1024/count, "MB"; \
          print "Total memory usage       =", sum/1024,  " MB"}'
        ;;
      "*")
        echo "This script has not been verified on $OSNAME"
        exit 1
        ;;
    esac
    rm -f $TMPFILE
  fi
done
exit

=================
Sample output
=================
20210118_181502
OSNAME = Linux

#####################################
# Individual extract Process Usage #
#####################################
38.7109 MB DPM_I_01
42.125 MB DPM_P_01
41.8672 MB DPM_S_01
70.8867 MB EXT_I_01
78.9297 MB EXT_P_01
361.016 MB EXT_S_01

#####################################
#   Total extract Process Usage    #
#####################################
Number of processes      = 6
AVG Memory usage/process = 105.589 MB
Total memory usage       = 633.535  MB

#####################################
# Individual replicat Process Usage #
#####################################
32.4219 MB REP_I_01
37.2383 MB REP_P_01
34.8789 MB REP_S_01

#####################################
#   Total replicat Process Usage    #
#####################################
Number of processes      = 3
AVG Memory usage/process = 34.8464 MB
Total memory usage       = 104.539  MB

             total       used       free     shared    buffers     cached
Mem:         64175      62568       1607       9373        384      57889
-/+ buffers/cache:       4294      59880
Swap:        10239        122      10117

Top 20 Processes
361.016MB 30432 oracle Sat Jan 16 20:46:19 2021 /software/ogg/1212/extract PARAMFILE /software/ogg/1212/dirprm/ext_s_01.prm REPORTFILE /software/ogg/1212/dirrpt/EXT_S_01.rpt PROCESSID EXT_S_01 USESUBDIRS
371.129MB 30853 oracle Sat Jan 16 20:46:24 2021 ora_ms03_igt
392.086MB 30851 oracle Sat Jan 16 20:46:24 2021 ora_ms02_igt
488.648MB 28170 oracle Sat Jan 16 20:46:05 2021 ora_smon_igt
512.262MB 28454 oracle Sat Jan 16 20:46:10 2021 oracleigt (LOCAL=NO)
607.949MB 28162 oracle Sat Jan 16 20:46:05 2021 ora_mman_igt
682.445MB 28392 oracle Sat Jan 16 20:46:10 2021 oracleigt (LOCAL=NO)
724.746MB 29669 oracle Sat Jan 16 20:46:13 2021 oracleigt (LOCAL=NO)
972.762MB 30606 oracle Sat Jan 16 20:46:19 2021 oracleigt (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
1046.21MB 29663 oracle Sat Jan 16 20:46:13 2021 oracleigt (LOCAL=NO)
1173.61MB 32712 oracle Sat Jan 16 20:46:47 2021 oracleigt (LOCAL=NO)
1208.2MB 20575 oracle Sun Jan 17 09:59:59 2021 oracleigt (LOCAL=NO)
1278.24MB 28830 oracle Sat Jan 16 20:46:11 2021 oracleigt (LOCAL=NO)
1934.22MB 30150 oracle Sat Jan 16 20:46:16 2021 oracleigt (LOCAL=NO)
2697.98MB 28386 oracle Sat Jan 16 20:46:10 2021 oracleigt (LOCAL=NO)
3556.99MB 28390 oracle Sat Jan 16 20:46:10 2021 oracleigt (LOCAL=NO)
5853.8MB 28388 oracle Sat Jan 16 20:46:10 2021 oracleigt (LOCAL=NO)
5938.82MB 28443 oracle Sat Jan 16 20:46:10 2021 oracleigt (LOCAL=NO)
6263.12MB 28298 oracle Sat Jan 16 20:46:10 2021 oracleigt (LOCAL=NO)
6995.96MB 28164 oracle Sat Jan 16 20:46:05 2021 ora_dbw0_igt

Top SWAP Using Processes

SWAP Usage from free -m
Swap:        10239        122      10117

SWAP Usage from /proc
     30649 splunkd                                    49264 kB
      8260 vxconfigd                                  24152 kB


Thursday, January 14, 2021

Golden Gate Extract Error: ERROR OGG-01091 Unable to open file

=========================
General
=========================
 Golden Gate Pump Extract Error
2021-01-14 14:29:10  ERROR   OGG-01091  Unable to open file "/software/ogg/191/dirdat/01/out/ep000000065" (error 2, No such file or directory)
Indeed, there is no such file. There is only file ep000000066.
Need to advance extract to read from existing file.
=========================
Solution
=========================
GGSCI (qanfv-2-dbs-01) 4> INFO ALL
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     ABENDED     DPM_I_01    00:00:00      00:01:38
EXTRACT     STOPPED     DPM_P_01    00:00:00      00:00:19
> ALTER EXTRACT DPM_P_01, EXTSEQNO 66
EXTRACT altered.
> START DPM_P_01
Sending START request to MANAGER ...
EXTRACT DPM_P_01 starting
> INFO DPM_P_01
EXTRACT    DPM_P_01  Last Started 2021-01-14 14:34   Status RUNNING
Checkpoint Lag       00:00:00 (updated 00:00:07 ago)
Process ID           16129
Log Read Checkpoint  File /software/ogg/191/dirdat/01/out/ep000000066
                     2020-12-17 13:55:12.649300  RBA 294731942

Fix Datapump
DBLOGIN USERID ogg PASSWORD pass INFO DPM_I_01 SHELL ls -ltr /software/ogg/191/dirdat/01/out/ei0000000*
STOP DPM_I_01
ALTER EXTRACT DPM_I_01, EXTSEQNO 9789, EXTRBA 0
ALTER EXTRACT DPM_I_01 ETROLLOVER
START DPM_I_01 INFO DPM_I_01


On the other sire, for REPLICAT need to do:
INFO REPLICAT REP_I_01
SHELL ls -ltr /software/ogg/191/dirdat/01/in/ei0000000*
STOP REPLICAT REP_I_01
SEND REPLICAT REP_I_01, FORCESTOP
ALTER REPLICAT REP_I_01, EXTSEQNO 25 EXTRBA 0
START REPLICAT REP_I_01

Sunday, January 10, 2021

ORA-00354: corrupt redo log block header

=================
General
=================
There are large trace files with same error:

-rw-r----- 1 oracle dba 658132992 Jan  8 18:57 ./diag/rdbms/igt/igt/trace/igt_arc1_30193.trc
-rw-r----- 1 oracle dba 649527296 Jan  8 18:57 ./diag/rdbms/igt/igt/trace/igt_arc0_30185.trc
-rw-r----- 1 oracle dba 537001984 Jan 11 00:46 ./diag/rdbms/igt/igt/trace/igt_arc0_30446.trc

=================
Error in trace files
=================

============================================================
/software/oracle/diag/rdbms/igt/igt/trace/igt_arc1_30193.trc
============================================================

Trace file /software/oracle/diag/rdbms/igt/igt/trace/igt_arc1_30193.trc

krsv_proc_add: Request to add process to V$MANAGED_STANDBY [krss.c:2851]
*** 2021-01-08T17:30:31.928588+05:45
Corrupt redo block 691858 detected: BAD BLOCK HEADER
 header size = 16, block size = 512
Seq: 0x00000000 Block: 0x00000000 Time: 134217728 Beg: 0x0 Cks: 0x0
Dump of memory from 0x00007FBE4B0FE400 to 0x00007FBE4B0FE600
7FBE4B0FE400 00000000 00000000 08000000 00000000  [................]

Corrupt redo block 691858 detected: BAD BLOCK HEADER
 header size = 16, block size = 512
Seq: 0x00000000 Block: 0x00000000 Time: 134217728 Beg: 0x0 Cks: 0x0

DDE: Problem Key 'ORA 312' was flood controlled (0x1) (no incident)
ORA-00312: online log 3 thread 1: '/oracle_db/db1/db_igt/ora_redo_03_a.rdo'

2021-01-08T17:30:32.068886+05:45
Incident 128315 created, dump file: /software/oracle/diag/rdbms/igt/igt/incident/incdir_128315/igt_arc1_30193_i128315.trc

ORA-00353: log corruption near block 691858 change 38994289 time 01/08/2021 17:00:25
ORA-00312: online log 3 thread 1: '/oracle_db/db1/db_igt/ora_redo_03_a.rdo'

<error barrier> at 0x7fff9511adc8 placed krse.c@7386
ORA-00354: corrupt redo log block header
ORA-00353: log corruption near block 691858 change 38994289 time 01/08/2021 17:00:25
ORA-00312: online log 3 thread 1: '/oracle_db/db1/db_igt/ora_redo_03_a.rdo'
*** 2021-01-08 17:30:33.201232 [krsh.c:6348]
Error 354  while archiving
DDE: Problem Key 'ORA 312' was flood controlled (0x1) (no incident)
ORA-00312: online log 3 thread 1: '/oracle_db/db1/db_igt/ora_redo_03_a.rdo'
<error barrier> at 0x7fff9511f820 placed krse.c@1876
ORA-16038: log 3 sequence# 4695 cannot be archived
ORA-00354: corrupt redo log block header
ORA-00312: online log 3 thread 1: '/oracle_db/db1/db_igt/ora_redo_03_a.rdo'

*** 2021-01-08T17:30:37.150427+05:45

Corrupt redo block 691858 detected: BAD BLOCK HEADER
 header size = 16, block size = 512
Seq: 0x00000000 Block: 0x00000000 Time: 134217728 Beg: 0x0 Cks: 0x0

=================
Check Current Status
=================

SET LINESIZE 160

COL STATUS FOR A20
COL REDOLOG_FILE_NAME FOR A60
SELECT
a.GROUP#,
a.THREAD#,
a.SEQUENCE#,
a.ARCHIVED,
a.STATUS,
b.MEMBER AS REDOLOG_FILE_NAME,
(a.BYTES/1024/1024) AS SIZE_MB
FROM v$log a
JOIN v$logfile b ON a.Group#=b.Group#
ORDER BY a.GROUP#;

    GROUP#    THREAD#  SEQUENCE# ARCHIVED     STATUS               REDOLOG_FILE_NAME                           SIZE_MB

---------- ---------- ---------- ------------ -------------------- ---------------------------------------- ----------
         1          1       4782 YES          ACTIVE               /oracle_db/db1/db_igt/ora_redo_01_a.rdo        1024

         2          1       4783 NO           CURRENT              /oracle_db/db1/db_igt/ora_redo_02_a.rdo        1024

         3          1       4695 NO           INACTIVE             /oracle_db/db1/db_igt/ora_redo_03_a.rdo        1024


All errors are from redo 03 group

oracle@my_server:/software/oracle/diag/rdbms/igt/igt/trace>% grep ORA-00312 *.trc | sort -u

igt_arc0_30446.trc:ORA-00312: online log 3 thread 1: '/oracle_db/db1/db_igt/ora_redo_03_a.rdo'

igt_arc1_30466.trc:ORA-00312: online log 3 thread 1: '/oracle_db/db1/db_igt/ora_redo_03_a.rdo'

igt_arc2_30476.trc:ORA-00312: online log 3 thread 1: '/oracle_db/db1/db_igt/ora_redo_03_a.rdo'

igt_arc3_30487.trc:ORA-00312: online log 3 thread 1: '/oracle_db/db1/db_igt/ora_redo_03_a.rdo'


================
Solution
================
SQL>ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 3;

Database altered.

SQL>SET LINESIZE 160

COL STATUS FOR A20
COL REDOLOG_FILE_NAME FOR A60
SELECT
a.GROUP#,
a.THREAD#,
a.SEQUENCE#,
a.ARCHIVED,
a.STATUS,
b.MEMBER AS REDOLOG_FILE_NAME,
(a.BYTES/1024/1024) AS SIZE_MB
FROM V$LOG a
JOIN V$LOGFILE b ON a.Group#=b.Group#
ORDER BY a.GROUP#;

    GROUP#    THREAD#  SEQUENCE# ARCHIVED     STATUS               REDOLOG_FILE_NAME                                               SIZE_MB
---------- ---------- ---------- ------------ -------------------- ------------------------------------------------------------ ----------
         1          1       4782 YES          INACTIVE             /oracle_db/db1/db_igt/ora_redo_01_a.rdo                            1024

         2          1       4783 NO           CURRENT              /oracle_db/db1/db_igt/ora_redo_02_a.rdo                            1024

         3          1          0 YES          UNUSED               /oracle_db/db1/db_igt/ora_redo_03_a.rdo                            1024


Group Log status meaning:
CURRENT - Current redo log. This implies that the redo log is active. 

ACTIVE - 
Log is active but is not the current log. It is needed for crash recovery. 

INACTIVE - 
Log is no longer needed for instance recovery. 

UNUSED
- Online redo log has never been written to. 
                      This is the state of a redo log that was just added, or just after a RESETLOGS, when it is not the current redo log, or after CLEAR UNARCHIVED LOGFILE command

CLEARING
- Log is being re-created as an empty log after an ALTER DATABASE CLEAR LOGFILE statement. After the log is cleared, the status changes to UNUSED.

CLEARING_CURRENT
- Current log is being cleared of a closed thread. The log can stay in this status if there is some failure in the switch such as an I/O error writing the new log header.


In alert.log:

Clearing online log 3 of thread 1 sequence number 4695

2021-01-11T01:17:54.055476+05:45

Errors in file /software/oracle/diag/rdbms/igt/igt/trace/igt_arc3_30487.trc:

ORA-00354: corrupt redo log block header

ORA-00353: log corruption near block 691858 change 38994289 time 01/08/2021 17:00:25

ORA-00312: online log 3 thread 1: '/oracle_db/db1/db_igt/ora_redo_03_a.rdo'

2021-01-11T01:17:54.055551+05:45

ARC3 (PID:30487): Error 354  while archiving

2021-01-11T01:17:54.055628+05:45

Closing local archive destination LOG_ARCHIVE_DEST_1 '/oracle_db/db2/db_igt/arch/arch0001_4695_1040477025.arc', error=354 (igt)

ARC3 (PID:30487): Committing creation of archive log '/oracle_db/db2/db_igt/arch/arch0001_4695_1040477025.arc', error=354

ARC3 (PID:30487): LNO:3 mismatch, expected sequence 4695 found T-1.S-0

2021-01-11T01:17:54.078378+05:45

Errors in file /software/oracle/diag/rdbms/igt/igt/trace/igt_arc3_30487.trc:

ORA-16038: log 3 sequence# 4695 cannot be archived

ORA-00354: corrupt redo log block header

ORA-00312: online log 3 thread 1: '/oracle_db/db1/db_igt/ora_redo_03_a.rdo'

ARC3 (PID:30487): Archival error occurred on a closed thread, archiver continuing

2021-01-11T01:17:54.078511+05:45

ORACLE Instance igt, archival error, archiver continuing

2021-01-11T01:17:57.357756+05:45

Completed: ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 3

2021-01-11T01:22:42.413279+05:45

ALTER SYSTEM ARCHIVE LOG

2021-01-11T01:22:42.483945+05:45

Thread 1 advanced to log sequence 4784 (LGWR switch)

  Current log# 3 seq# 4784 mem# 0: /oracle_db/db1/db_igt/ora_redo_03_a.rdo

2021-01-11T01:22:44.306443+05:45

NET  (PID:7901): Archived Log entry 4417 added for T-1.S-4783 ID 0x4c386ae1 LAD:1

2021-01-11T01:22:48.774541+05:45

Control autobackup written to DISK device



SQL> /

    GROUP#    THREAD#  SEQUENCE# ARCHIVED     STATUS               REDOLOG_FILE_NAME                                               SIZE_MB

---------- ---------- ---------- ------------ -------------------- ------------------------------------------------------------ ----------

         1          1       4782 YES          INACTIVE             /oracle_db/db1/db_igt/ora_redo_01_a.rdo                            1024

         2          1       4783 YES          ACTIVE               /oracle_db/db1/db_igt/ora_redo_02_a.rdo                            1024

         3          1       4784 NO           CURRENT              /oracle_db/db1/db_igt/ora_redo_03_a.rdo                            1024

Now, the redo log group 3 could be archived.
Issue fixed.


======================
Force Oracle to switch log file
======================
Option A - ALTER SYSTEM  SWITCH LOGFILE
This command is asynchronous.
This command is fast to return to the invoking program because the writing of the redo log to the OS filesystem is done in the background.  

Option B - ALTER SYSTEM ARCHIVE LOG CURRENT
This command is synchronous:  
This command waits until the online redo log has completed the writing of the redo log file to the filesystem.  
This command is safer because it waits for the OS to acknowledge (ACK) that the redo log has been successfully written.  

Tuesday, December 1, 2020

Increase Oracle memory; Increase /dev/shm; ORA-00838; ORA-00845

====================
General
====================
Increase Oracle memory
Increase /dev/shm 


====================
Try to increase Oracle memory
====================
Start Point:


SQL> 

COL name FOR A30
COL value for A30
SELECT name, value FROM V$PARAMETER WHERE name like 'memory%';
NAME                           VALUE
------------------------------ ------------------------------
memory_target                  1073741824
memory_max_target              1073741824


Oracle has 1 Gb memory,
Linux server has 40Gb memory
SQL> !free -m
     total       used       free     shared    buffers  cached
Mem: 38154       1628      36526        672         31    1040
-/+ buffers/cache:        556      37598
Swap:         9215          0       9215
Let increase MEMORY_MAX_TARGET to 30Gb: 
ALTER SYSTEM SET MEMORY_MAX_TARGET=30000M scope=spfile;

SQL> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP;

ORA-01078: failure in processing system parameters

ORA-00838: Specified value of MEMORY_TARGET is too small, needs to be at least 1408M


SQL> ALTER SYSTEM SET MEMORY_TARGET=3000M scope=spfile;

ALTER SYSTEM SET MEMORY_TARGET=3000M scope=spfile
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 0
Session ID: 866 Serial number: 23

SQL> create pfile='/software/oracle/admin/igt/pfile/pfile_20201201_initigt.ora' from spfile='/software/oracle/admin/igt/pfile/spfileigt.ora';

File created.

Edit manually file pfile.
set MEMORY_TARGET to be 2000M
*.memory_target=2147483648


SQL> startup pfile='/software/oracle/admin/igt/pfile/pfile_20201201_initigt.ora'

ORA-00845: MEMORY_TARGET not supported on this system


Check Alert Log for more details:

Tue Dec 01 09:35:05 2020
Cannot set memory_target (1073741824) < min sga_target (1476395008) + pga_aggregate_target (0)
Starting ORACLE instance (normal)
WARNING: You are trying to use the MEMORY_TARGET feature. 
This feature requires the /dev/shm file system to be mounted for at least 31474057216 bytes. 
/dev/shm is either not mounted or is mounted with available space less than this size. 
Please fix this so that MEMORY_TARGET can work as expected. 
Current available is 4294967296 and used is 0 bytes. 
Ensure that the mount point is /dev/shm for this directory.
memory_target needs larger /dev/shm


Checking the Linux server

SQL> !df -h /dev/shm
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           4.0G     0  4.0G   0% /dev/shm

/dev/shm cannot support memory more than 4G memory
Need to change max_memory_target and memory_target to 2Gb for now

*.memory_max_target=2000M
*.memory_target=2000M

SQL> startup pfile='/software/oracle/admin/igt/pfile/pfile_20201201_initigt.ora'

ORACLE instance started.
Total System Global Area 2087780352 bytes
Fixed Size                  2254824 bytes
Variable Size            1577060376 bytes
Database Buffers          503316480 bytes
Redo Buffers                5148672 bytes
Database mounted.
Database opened.

Re-Create spfile from pfile

SQL> create spfile='/software/oracle/admin/igt/pfile/spfileigt.ora' from pfile='/software/oracle/admin/igt/pfile/pfile_20201201_initigt.ora';

File created.

Increase /dev/shm from current 4Gb to 30Gb, out of server total 40Gb

oracle@avilab-1-aps-01:~>% df -hP
Filesystem                     Size  Used Avail Use% Mounted on
tmpfs                          4.0G  331M  3.7G   9% /dev/shm

Step 1: 
vi /etc/fstab

Step 2: 

Change size for /dev/shm to 30G
change from :

tmpfs                   /dev/shm                tmpfs   size=4g,nodev,nosuid,noexec             0 0

to: 

tmpfs                   /dev/shm                tmpfs   size=30g,nodev,nosuid,noexec             0 0


stop oracle!!

Step 3: 
Remount 
/dev/shm filesystem

mount -o remount /dev/shm

Step 4: 
Check status:

df -hP | grep shm

Filesystem                     Size  Used Avail Use% Mounted on
tmpfs                           30G  700M   30G   3% /dev/shm

start oracle

Back to Oracle:
--8192M
ALTER SYSTEM SET MEMORY_MAX_TARGET=8192M scope=spfile;
ALTER SYSTEM SET MEMORY_TARGET=8192M scope=spfile;


SQL> ALTER SYSTEM SET MEMORY_MAX_TARGET=4000M scope=spfile;
System altered.
SQL> ALTER SYSTEM SET MEMORY_TARGET=4000M scope=spfile;
System altered.
SQL> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP;
ORACLE instance started.

Total System Global Area 3.1334E+10 bytes

Fixed Size                  2268632 bytes

Variable Size            3.0803E+10 bytes

Database Buffers          469762048 bytes

Redo Buffers               58535936 bytes

Database mounted.

Database opened.


>% df -hP
Filesystem                     Size  Used Avail Use% Mounted on
tmpfs                           30G  1.2G   29G   4% /dev/shm