Showing posts with label DB performance. Show all posts
Showing posts with label DB performance. Show all posts

Tuesday, December 2, 2025

shell script to build oracle database with easy interactive mode

 Here is the full  script which will get few input and build the oracle database and configure the listener,tnsnames.ora.pfile/spfile and convert the database to archive log 

#########################################################################################################

#purpose       : Script used to build oracle DB,pass requested info                                     #

#Input needed  :DB_NAME,ORACLE_HOME,PORT#,DB CHARSET,sys,system,PDB pws,Redlog size in MB               #

#script will do: create DB,convert archive mode,setup listener& tns and start,add /etc/oratab,BCT       #

#Developed by  :Bala P  3March2025  v2                                                                  #

#########################################################################################################

#!/bin/sh



# Prompt for database name and convert to uppercase

echo "Enter the database name:"

read DB_NAME

DB_NAME=$(echo $DB_NAME | tr '[:lower:]' '[:upper:]')

# Prompt the user for   port number


read -p "Enter the port number: " PORT_NUMBER

# Prompt the user for   Redolog size in MB


read -p "Enter the Redolog size in MB: " RLOG



# Prompt for Oracle DB Home

echo "Enter the Oracle DB Home full Path:"

read  ORACLE_HOME


# Check if sqlplus /oracle_home status

if [ ! -x "$ORACLE_HOME/bin/sqlplus" ]; then

echo " sqlplus not found at $ORACLE_HOME/bin. Please check ORACLE_HOME."

exit 1

else

  echo "Oracle_Home FOUND ,proceeding with next steps"

fi

echo -e "\n \n"

#Prompt for  DB CHARACTER SET

echo "Enter the DB  CHARACTER SET"

read charset


# Prompt for passwords

echo "Enter new password for SYS:"

read -s sysPassword

echo "Enter new password for SYSTEM:"

read -s systemPassword

echo "Enter new password for PDBADMIN:"

read -s pdbAdminPassword



export ORACLE_HOME=$ORACLE_HOME

export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib

export ORACLE_SID=$DB_NAME



# Create necessary directories

OLD_UMASK=`umask`

umask 0027

mkdir -p /oracle/${DB_NAME}

mkdir -p $ORACLE_HOME/dbs

mkdir -p /oracle/${DB_NAME}/admin/${DB_NAME}/adump

mkdir -p /oracle/${DB_NAME}/admin/${DB_NAME}/dpdump

mkdir -p /oracle/${DB_NAME}/admin/${DB_NAME}/pfile

mkdir -p /oracle/${DB_NAME}/audit

mkdir -p /oracle/${DB_NAME}/cfgtoollogs/dbca/${DB_NAME}

mkdir -p /oracle/${DB_NAME}/control1

mkdir -p /oracle/${DB_NAME}/control2

mkdir -p /oracle/${DB_NAME}/control3

mkdir -p /oracle/${DB_NAME}/mirrlogA

mkdir -p /oracle/${DB_NAME}/mirrlogB

mkdir -p /oracle/${DB_NAME}/origlogA

mkdir -p /oracle/${DB_NAME}/origlogB

mkdir -p /oracle/${DB_NAME}/data1

mkdir -p /oracle/${DB_NAME}/SystemTBS

mkdir -p /oracle/${DB_NAME}/UndoTBS

mkdir -p /oracle/${DB_NAME}/tempTBS

mkdir -p /oracle/${DB_NAME}/admin/scripts

umask ${OLD_UMASK}


# Create init<DB_NAME>.ora file

rm -f /oracle/${DB_NAME}/admin/scripts/init${DB_NAME}.ora


cat <<EOL > /oracle/${DB_NAME}/admin/scripts/init${DB_NAME}.ora

${DB_NAME}.__oracle_base='/oracle/${DB_NAME}'#ORACLE_BASE set from environment

${DB_NAME}.__db_cache_size=1451700

${DB_NAME}.__java_pool_size=16686

${DB_NAME}.__large_pool_size=16686

${DB_NAME}.__sga_target=1067918334

${DB_NAME}.__shared_io_pool_size=216920

${DB_NAME}.__shared_pool_size=2552992

${DB_NAME}.__data_transfer_cache_size=0

${DB_NAME}.__streams_pool_size=0

*.audit_file_dest='/oracle/${DB_NAME}/admin/${DB_NAME}/adump'

*.audit_trail='db'

*.compatible='19.0.0'

*.control_file_record_keep_time=30

*.control_files='/oracle/${DB_NAME}/control1/control01.ctl','/oracle/${DB_NAME}/control2/control02.ctl','/oracle/${DB_NAME}/control3/control03.ctl'

*.db_block_size=8192

*.db_domain='abc.domain.com'

*.db_files=200

*.db_name='${DB_NAME}'

*.diagnostic_dest='/oracle/${DB_NAME}'

*.filesystemio_options='SETALL'

*.log_archive_dest='/oracle/${DB_NAME}/oraarch/${DB_NAME}arch'

*.log_archive_format='%t_%s_%r.arc'

*.log_checkpoints_to_alert=TRUE

*.max_dump_file_size='20000'

*.open_cursors=3000

*.parallel_execution_message_size=16384

*.parallel_max_servers=20

*.parallel_threads_per_cpu=1

*.pga_aggregate_target=675m

*.processes=500

*.replication_dependency_tracking=FALSE

*.sessions=1000

*.sga_target=1g

*.undo_management='AUTO'

*.undo_retention=21600

*.undo_tablespace='UNDOTBS'

_disable_directory_link_check=TRUE

CONTROL_MANAGEMENT_PACK_ACCESS = "NONE"

EOL


# Create Oracle password file

rm -f $ORACLE_HOME/dbs/orapw${DB_NAME}

$ORACLE_HOME/bin/orapwd file=$ORACLE_HOME/dbs/orapw${DB_NAME} force=y format=12


# Run SQL scripts for DB creation and configuration

export ORACLE_HOME=$ORACLE_HOME

export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib

export ORACLE_SID=$DB_NAME

echo -e "\n \n creating the DB...."

sqlplus /nolog <<EOF

CONNECT SYS/${sysPassword} AS SYSDBA

conn / as sysdba

SET VERIFY OFF

SPOOL /oracle/${DB_NAME}/admin/scripts/CreateDB.log

STARTUP NOMOUNT PFILE='/oracle/${DB_NAME}/admin/scripts/init${DB_NAME}.ora';

CREATE DATABASE "${DB_NAME}"

MAXINSTANCES 8

MAXLOGHISTORY 1

MAXLOGFILES 16

MAXLOGMEMBERS 3

MAXDATAFILES 1000

DATAFILE '/oracle/${DB_NAME}/SystemTBS/system01.dbf' SIZE 2072M REUSE AUTOEXTEND ON NEXT  10240K MAXSIZE UNLIMITED

EXTENT MANAGEMENT LOCAL

SYSAUX DATAFILE '/oracle/${DB_NAME}/SystemTBS/sysaux01.dbf' SIZE 2192M REUSE AUTOEXTEND ON NEXT  10240K MAXSIZE UNLIMITED

SMALLFILE DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/oracle/${DB_NAME}/tempTBS/temp01.dbf' SIZE 1024M REUSE AUTOEXTEND ON NEXT  640K MAXSIZE UNLIMITED

SMALLFILE UNDO TABLESPACE "UNDOTBS" DATAFILE  '/oracle/${DB_NAME}/UndoTBS/undotbs01.dbf' SIZE 1024M REUSE AUTOEXTEND ON NEXT  5120K MAXSIZE UNLIMITED

CHARACTER SET "${charset}"

NATIONAL CHARACTER SET AL16UTF16

LOGFILE

GROUP 1(

    '/oracle/${DB_NAME}/origlogA/redo_g1m1.log',

    '/oracle/${DB_NAME}/mirrlogA/redo_g1m2.log'

  ) SIZE ${RLOG}M BLOCKSIZE 512,

  GROUP 2 (

    '/oracle/${DB_NAME}/origlogB/redo_g2m1.log',

    '/oracle/${DB_NAME}/mirrlogB/redo_g2m2.log'

  ) SIZE ${RLOG}M BLOCKSIZE 512,

  GROUP 3 (

    '/oracle/${DB_NAME}/origlogB/redo_g3m1.log',

    '/oracle/${DB_NAME}/mirrlogB/redo_g3m2.log'

  ) SIZE ${RLOG}M BLOCKSIZE 512,

  GROUP 4 (

    '/oracle/${DB_NAME}/origlogA/redo_g4m1.log',

    '/oracle/${DB_NAME}/mirrlogA/redo_g4m2.log'

  ) SIZE ${RLOG}M BLOCKSIZE 512

USER SYS IDENTIFIED BY "${sysPassword}" USER SYSTEM IDENTIFIED BY "${systemPassword}";


SPOOL OFF

----creating the needed tablespaces--------

conn / as sysdba

SPOOL /oracle/${DB_NAME}/admin/scripts/CreateDBFiles.log



CREATE SMALLFILE TABLESPACE "USERS" LOGGING  DATAFILE  '/oracle/${DB_NAME}/data1/users01.dbf' SIZE 500M REUSE AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED  EXTENT MANAGEMENT LOCAL  SEGMENT SPACE MANAGEMENT  AUTO;

ALTER DATABASE DEFAULT TABLESPACE "USERS";

SPOOL OFF


------loading oracle binaries--------------

conn / as sysdba

SPOOL /oracle/${DB_NAME}/admin/scripts/CreateDBCatalog.log

@$ORACLE_HOME/rdbms/admin/catalog.sql;

@$ORACLE_HOME/rdbms/admin/catproc.sql;

@$ORACLE_HOME/rdbms/admin/catoctk.sql;


@$ORACLE_HOME/rdbms/admin/owminst.plb;

CONNECT SYSTEM/${systemPassword}

@$ORACLE_HOME/sqlplus/admin/pupbld.sql;

CONNECT SYS/${sysPassword} AS SYSDBA

@$ORACLE_HOME/sqlplus/admin/pupdel.sql;

CONNECT SYSTEM/${systemPassword};

SPOOL /oracle/${DB_NAME}/admin/scripts/sqlPlusHelp.log

@$ORACLE_HOME/sqlplus/admin/help/hlpbld.sql helpus.sql;

SPOOL OFF

conn / as sysdba


SPOOL /oracle/${DB_NAME}/admin/scripts/JServer.log

@$ORACLE_HOME/javavm/install/initjvm.sql;

@$ORACLE_HOME/xdk/admin/initxml.sql;

@$ORACLE_HOME/xdk/admin/xmlja.sql;

@$ORACLE_HOME/rdbms/admin/catjava.sql;

@$ORACLE_HOME/rdbms/admin/catxdbj.sql;

SPOOL OFF

---checked above  this

conn / as sysdba

SPOOL /oracle/${DB_NAME}/admin/scripts/context.log

@$ORACLE_HOME/ctx/admin/catctx.sql Xbkfsdcdf1ggh_123 SYSAUX TEMP LOCK; --no path

ALTER USER CTXSYS ACCOUNT UNLOCK IDENTIFIED BY "CTXSYS";

CONNECT CTXSYS/CTXSYS

@$ORACLE_HOME/ctx/admin/defaults/dr0defin.sql "AMERICAN";

CONNECT SYS/${sysPassword} AS SYSDBA

conn / as sysdba

ALTER USER CTXSYS PASSWORD EXPIRE ACCOUNT LOCK;

@$ORACLE_HOME/rdbms/admin/dbmsxdbt.sql;

SPOOL OFF

conn / as sysdba

SPOOL /oracle/${DB_NAME}/admin/scripts/ordinst.log

@$ORACLE_HOME/ord/admin/ordinst.sql SYSAUX SYSAUX;

SPOOL OFF

conn / as sysdba

SPOOL /oracle/${DB_NAME}/admin/scripts/interMedia.log

@$ORACLE_HOME/ord/im/admin/iminst.sql;

SPOOL OFF

conn / as sysdba

SPOOL /oracle/${DB_NAME}/admin/scripts/cwmlite.log

@$ORACLE_HOME/olap/admin/olap.sql SYSAUX TEMP;

SPOOL OFF

conn / as sysdba

SPOOL /oracle/${DB_NAME}/admin/scripts/spatial.log

@$ORACLE_HOME/md/admin/mdinst.sql;

SPOOL OFF

conn / as sysdba

SPOOL /oracle/${DB_NAME}/admin/scripts/apex.log APPEND

@$ORACLE_HOME/apex/catapx.sql Xbkfsdcdf1ggh_123 SYSAUX SYSAUX TEMP /i/ NONE;

SPOOL OFF

conn / as sysdba

SPOOL /oracle/${DB_NAME}/admin/scripts/postDBCreation.log

host $ORACLE_HOME/OPatch/datapatch -skip_upgrade_check -db ${DB_NAME};

CREATE SPFILE='$ORACLE_HOME/dbs/spfile${DB_NAME}.ora' FROM PFILE='/oracle/${DB_NAME}/admin/scripts/init${DB_NAME}.ora';

SELECT 'utlrp_begin: ' || TO_CHAR(SYSDATE, 'HH:MI:SS') FROM DUAL;

@$ORACLE_HOME/rdbms/admin/utlrp.sql;

SELECT 'utlrp_end: ' || TO_CHAR(SYSDATE, 'HH:MI:SS') FROM DUAL;

SELECT comp_id, status FROM dba_registry;

SHUTDOWN IMMEDIATE;

STARTUP;

SPOOL OFF

conn / as sysdba




SPOOL /oracle/${DB_NAME}/admin/scripts/lockAccount.log

BEGIN

FOR item IN ( SELECT USERNAME, AUTHENTICATION_TYPE FROM DBA_USERS WHERE ACCOUNT_STATUS IN ('OPEN', 'LOCKED', 'EXPIRED') AND USERNAME NOT IN (

'SYS','SYSTEM') )

LOOP

IF item.AUTHENTICATION_TYPE='PASSWORD' THEN

  DBMS_OUTPUT.PUT_LINE('Locking and Expiring: ' || item.USERNAME);

  EXECUTE IMMEDIATE 'ALTER USER ' ||

         SYS.DBMS_ASSERT.ENQUOTE_NAME(

         SYS.DBMS_ASSERT.SCHEMA_NAME(

         item.USERNAME),FALSE) || ' PASSWORD EXPIRE ACCOUNT LOCK' ;

ELSE

  DBMS_OUTPUT.PUT_LINE('Locking: ' || item.USERNAME);

  EXECUTE IMMEDIATE 'ALTER USER ' ||

         SYS.DBMS_ASSERT.ENQUOTE_NAME(

         SYS.DBMS_ASSERT.SCHEMA_NAME(

         item.USERNAME),FALSE) || ' ACCOUNT LOCK' ;

END IF;

END LOOP;

END;

/

SPOOL OFF

EOF

# Set ORACLE_HOME

export ORACLE_HOME=$ORACLE_HOME


# Get the current hostname

SERVER_NAME=$(hostname)


# Define paths

TNS_PATH="$ORACLE_HOME/network/admin/tnsnames.ora"

LISTENER_PATH="$ORACLE_HOME/network/admin/listener.ora"

TNS_BACKUP_PATH="${TNS_PATH}_backup_$(date +%Y%m%d_%H%M%S)"

LISTENER_BACKUP_PATH="${LISTENER_PATH}_backup_$(date +%Y%m%d_%H%M%S)"


# Backup tnsnames.ora

if [ -f "$TNS_PATH" ]; then

  cp "$TNS_PATH" "$TNS_BACKUP_PATH"

  echo "Backup of tnsnames.ora created at $TNS_BACKUP_PATH"

fi


# Append to tnsnames.ora

cat <<EOF >> "$TNS_PATH"


${DB_NAME}.WORLD=

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS =

        (PROTOCOL = TCP)

        (HOST = ${SERVER_NAME})

        (PORT = ${PORT_NUMBER})

      )

    )

    (CONNECT_DATA =

      (SID = ${DB_NAME})

      (GLOBAL_NAME = ${DB_NAME}.WORLD)

    )

  )

#for PROD

RMANCATPRD.WORLD=

  (DESCRIPTION =

    (SDU = 32768)

    (ADDRESS_LIST =

        (ADDRESS =

          (PROTOCOL = TCP)

          (HOST = <catlog_server>)

          (PORT = 1591)

        )

    )

    (CONNECT_DATA =

       (SID = KRMANCATPRD)

       (GLOBAL_NAME = RMANCATPRD.WORLD)

    )

  )

#prod end

EOF


echo "New TNS entry for ${DB_NAME} added to $TNS_PATH"


# Backup listener.ora

if [ -f "$LISTENER_PATH" ]; then

  cp "$LISTENER_PATH" "$LISTENER_BACKUP_PATH"

  echo "Backup of listener.ora created at $LISTENER_BACKUP_PATH"

fi


# Create listener.ora

cat <<EOF > "$LISTENER_PATH"

LISTENER_${DB_NAME} =

  (ADDRESS_LIST =

    (ADDRESS =

      (PROTOCOL = IPC)

      (KEY = ${DB_NAME}.WORLD)

    )

    (ADDRESS =

      (PROTOCOL = IPC)

      (KEY = ${DB_NAME})

    )

    (ADDRESS =

      (PROTOCOL = TCP)

      (HOST = ${SERVER_NAME})

      (PORT = ${PORT_NUMBER})

    )

  )

STARTUP_WAIT_TIME_LISTENER_${DB_NAME} = 0

CONNECT_TIMEOUT_LISTENER_${DB_NAME} = 10

TRACE_LEVEL_LISTENER_${DB_NAME} = OFF

SID_LIST_LISTENER_${DB_NAME} =

  (SID_LIST =

    (SID_DESC =

      (SID_NAME = ${DB_NAME})

      (ORACLE_HOME = $ORACLE_HOME)

    )

  )

EOF

echo "New listener entry for ${DB_NAME} added to $LISTENER_PATH"


# Define paths for sqlnet.ora

SQLNET_PATH="$ORACLE_HOME/network/admin/sqlnet.ora"

SQLNET_BACKUP_PATH="${SQLNET_PATH}_backup_$(date +%Y%m%d_%H%M%S)"


# Backup sqlnet.ora

if [ -f "$SQLNET_PATH" ]; then

  cp "$SQLNET_PATH" "$SQLNET_BACKUP_PATH"

  echo "Backup of sqlnet.ora created at $SQLNET_BACKUP_PATH"

fi


# Append to sqlnet.ora

cat <<EOF >> "$SQLNET_PATH"


AUTOMATIC_IPC = ON

TRACE_LEVEL_CLIENT = OFF

NAMES.DEFAULT_DOMAIN = WORLD

NAME.DEFAULT_ZONE = WORLD

SQLNET.EXPIRE_TIME = 0

TCP.NODELAY=YES


EOF



#start the listener

export ORACLE_HOME=$ORACLE_HOME

export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib

export ORACLE_SID=$DB_NAME


lsnrctl start LISTENER_${DB_NAME}


TNSPING_LOG="tnsping_${DB_NAME}.log"


# Run tnsping and log the output

tnsping ${DB_NAME}.WORLD > "$TNSPING_LOG" 2>&1


# Check tnsping result

if grep -q "OK" "$TNSPING_LOG"; then

  echo "TNSPING successful: This is good"

else

  echo "TNSPING failed: Please check the configuration"

fi



# Check logs for errors or warnings

LOG_FILES="/oracle/${DB_NAME}/admin/scripts/*.log"

OUTPUT_FILE="/oracle/${DB_NAME}/admin/scripts/error_check.log"

ERRORS_FOUND=false


> "$OUTPUT_FILE"  # Clear previous output


for file in $LOG_FILES

do

  if grep -iq "ORA-" "$file" ; then

    ERRORS_FOUND=true

    ERR_FILE="${file}_err"


    # Extract relevant lines and save to .log_err file

    grep -iE "ORA-" "$file" > "$ERR_FILE"


    echo "Issues found in: $(basename "$file") $(basename "$ERR_FILE")" >> "$OUTPUT_FILE"

  fi

done


if [ "$ERRORS_FOUND" = false ]; then

  echo "Everything is good with Db creation." > "$OUTPUT_FILE"


fi


#Backup /etc/oratab with timestamp

timestamp=$(date +%Y%m%d_%H%M%S)

cp /etc/oratab /oracle/$DB_NAME/admin/scripts/oratab_bak_$timestamp


# Append entry to /etc/oratab

echo "${DB_NAME}:${ORACLE_HOME}:Y" >> /etc/oratab


echo "Entry added to /etc/oratab and backup created as /oracle/$DB_NAME/admin/scripts/oratab_bak_$timestamp"


# Set environment variables arch mode conversion

export ORACLE_HOME=$ORACLE_HOME

export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib

export ORACLE_SID=$DB_NAME


# Check if DB is already in ARCHIVELOG mode

archive_mode=$(sqlplus -s / as sysdba <<'EOF'

SET HEADING OFF

SET FEEDBACK OFF

SET PAGESIZE 0

SELECT log_mode FROM v$database;

EXIT

EOF

)


archive_mode=$(echo "$archive_mode" | xargs)  # Trim whitespace


if [ "$archive_mode" == "ARCHIVELOG" ]; then

  echo "Database is already in ARCHIVELOG mode. Skipping conversion."

else

  echo "Converting database to ARCHIVELOG mode..."


  sqlplus / as sysdba <<EOF

  SPOOL convert_db_archive_mode_bct.log


  SHOW PARAMETER spfile;

  CREATE PFILE='$ORACLE_HOME/pfile_before_arch.ora' FROM SPFILE;

  SHUTDOWN IMMEDIATE;

  STARTUP MOUNT;

  ALTER DATABASE ARCHIVELOG;

  ALTER DATABASE OPEN;

  ARCHIVE LOG LIST;

  alter database enable block change tracking using file '/oracle/${DB_NAME}/SystemTBS/${DB_NAME}_block_change.dbf';



  SPOOL OFF

  EXIT

EOF


fi



echo "exporting Db variables final check"


export ORACLE_HOME=$ORACLE_HOME

export PATH=$ORACLE_HOME/bin:$PATH

export LD_LIBRARY_PATH=$ORACLE_HOME/lib

export ORACLE_SID=$DB_NAME


EMAIL="BALAmani@abc.com"


# Run SQL to get DB name and open mode

DB_STATUS=$(sqlplus -s / as sysdba <<'EOF'

SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF

SELECT open_mode FROM v$database;

EXIT;

EOF

)


# Check if SQL*Plus ran successfully

if [[ $? -ne 0 ]]; then

    echo "SQL*Plus execution failed."

    exit 1

fi


# Trim whitespace

DB_STATUS=$(echo "$DB_STATUS" | xargs)


# Log the status

echo "Database status returned: $DB_STATUS"


# Check if status is "READ WRITE"

if [[ "$DB_STATUS" == "READ WRITE" ]]; then

    echo "DB creation completed successfully." | mailx -s "DB $DB_NAME build completed, proceed with next steps" "$EMAIL"

else

    echo "Database is not in READ WRITE mode. Current status: $DB_STATUS"

    exit 1

fi


exit 0


Monday, May 20, 2024

ORA-29702: error occurred in Cluster Group Service operation in oracle database

 Issue:

when I started my oracle database got the below error.

ORA-29702: error occurred in Cluster Group Service operation

SQL> startup mount;

ORA-29702: error occurred in Cluster Group Service operation

Solution:

cd $ORACLE_HOME/rdbms/lib

make -f ins_rdbms.mk rac_off ioracle

make -f ins_rdbms.mk ioracle



[oracle@<server_name> ~]$ cd $ORACLE_HOME/rdbms/lib

[oracle@<server_name> lib]$ make -f ins_rdbms.mk rac_off ioracle

rm -f /u01/app/oracle/product/12.1.0/dbhome_1/lib/libskgxp12.so

cp /u01/app/oracle/product/12.1.0/dbhome_1/lib//libskgxpg.so /u01/app/oracle/product/12.1.0/dbhome_1/lib/libskgxp12.so

rm -f /u01/app/oracle/product/12.1.0/dbhome_1/lib/libskgxn2.so

cp /u01/app/oracle/product/12.1.0/dbhome_1/lib//libskgxns.so \

              /u01/app/oracle/product/12.1.0/dbhome_1/lib/libskgxn2.so

/usr/bin/ar d /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/libknlopt.a kcsm.o

/usr/bin/ar cr /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/libknlopt.a /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/ksnkcs.o

chmod 755 /u01/app/oracle/product/12.1.0/dbhome_1/bin


 - Linking Oracle

rm -f /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/oracle

/u01/app/oracle/product/12.1.0/dbhome_1/bin/orald  -o /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/oracle -m64 -z noexecstack -Wl,--disable-new-dtags -L/u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/ -L/u01/app/oracle/product/12.1.0/dbhome_1/lib/ -L/u01/app/oracle/product/12.1.0/dbhome_1/lib/stubs/   -Wl,-E /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/opimai.o /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/ssoraed.o /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/ttcsoi.o -Wl,--whole-archive -lperfsrv12 -Wl,--no-whole-archive /u01/app/oracle/product/12.1.0/dbhome_1/lib/nautab.o /u01/app/oracle/product/12.1.0/dbhome_1/lib/naeet.o /u01/app/oracle/product/12.1.0/dbhome_1/lib/naect.o /u01/app/oracle/product/12.1.0/dbhome_1/lib/naedhs.o /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/config.o  -lserver12 -lodm12 -lcell12 -lnnet12 -lskgxp12 -lsnls12 -lnls12  -lcore12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lxml12 -lcore12 -lunls12 -lsnls12 -lnls12 -lcore12 -lnls12 -lclient12  -lvsn12 -lcommon12 -lgeneric12 -lknlopt `if /usr/bin/ar tv /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/libknlopt.a | grep xsyeolap.o > /dev/null 2>&1 ; then echo "-loraolap12" ; fi` -lskjcx12 -lslax12 -lpls12  -lrt -lplp12 -lserver12 -lclient12  -lvsn12 -lcommon12 -lgeneric12 `if [ -f /u01/app/oracle/product/12.1.0/dbhome_1/lib/libavserver12.a ] ; then echo "-lavserver12" ; else echo "-lavstub12"; fi` `if [ -f /u01/app/oracle/product/12.1.0/dbhome_1/lib/libavclient12.a ] ; then echo "-lavclient12" ; fi` -lknlopt -lslax12 -lpls12  -lrt -lplp12 -ljavavm12 -lserver12  -lwwg  `cat /u01/app/oracle/product/12.1.0/dbhome_1/lib/ldflags`    -lncrypt12 -lnsgr12 -lnzjs12 -ln12 -lnl12 -lnro12 `cat /u01/app/oracle/product/12.1.0/dbhome_1/lib/ldflags`    -lncrypt12 -lnsgr12 -lnzjs12 -ln12 -lnl12 -lnnzst12 -lzt12 -lztkg12 -lmm -lsnls12 -lnls12  -lcore12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lxml12 -lcore12 -lunls12 -lsnls12 -lnls12 -lcore12 -lnls12 -lztkg12 `cat /u01/app/oracle/product/12.1.0/dbhome_1/lib/ldflags`    -lncrypt12 -lnsgr12 -lnzjs12 -ln12 -lnl12 -lnro12 `cat /u01/app/oracle/product/12.1.0/dbhome_1/lib/ldflags`    -lncrypt12 -lnsgr12 -lnzjs12 -ln12 -lnl12 -lnnzst12 -lzt12 -lztkg12   -lsnls12 -lnls12  -lcore12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lxml12 -lcore12 -lunls12 -lsnls12 -lnls12 -lcore12 -lnls12 `if /usr/bin/ar tv /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/libknlopt.a | grep "kxmnsd.o" > /dev/null 2>&1 ; then echo " " ; else echo "-lordsdo12"; fi` -L/u01/app/oracle/product/12.1.0/dbhome_1/ctx/lib/ -lctxc12 -lctx12 -lzx12 -lgx12 -lctx12 -lzx12 -lgx12 -lordimt12 -lclsra12 -ldbcfg12 -lhasgen12 -lskgxn2 -lnnzst12 -lzt12 -lxml12 -locr12 -locrb12 -locrutl12 -lhasgen12 -lskgxn2 -lnnzst12 -lzt12 -lxml12  -lgeneric12 -loraz -llzopro -lorabz2 -lipp_z -lipp_bz2 -lippdcemerged -lippsemerged -lippdcmerged  -lippsmerged -lippcore  -lippcpemerged -lippcpmerged  -lsnls12 -lnls12  -lcore12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lxml12 -lcore12 -lunls12 -lsnls12 -lnls12 -lcore12 -lnls12 -lsnls12 -lunls12  -lsnls12 -lnls12  -lcore12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lxml12 -lcore12 -lunls12 -lsnls12 -lnls12 -lcore12 -lnls12 -lasmclnt12 -lcommon12 -lcore12  -laio -lons    `cat /u01/app/oracle/product/12.1.0/dbhome_1/lib/sysliblist` -Wl,-rpath,/u01/app/oracle/product/12.1.0/dbhome_1/lib -lm    `cat /u01/app/oracle/product/12.1.0/dbhome_1/lib/sysliblist` -ldl -lm   -L/u01/app/oracle/product/12.1.0/dbhome_1/lib

test ! -f /u01/app/oracle/product/12.1.0/dbhome_1/bin/oracle ||\

           mv -f /u01/app/oracle/product/12.1.0/dbhome_1/bin/oracle /u01/app/oracle/product/12.1.0/dbhome_1/bin/oracleO

mv /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/oracle /u01/app/oracle/product/12.1.0/dbhome_1/bin/oracle

chmod 6751 /u01/app/oracle/product/12.1.0/dbhome_1/bin/oracle

[oracle@<server_name> lib]$ make -f ins_rdbms.mk ioracle

chmod 755 /u01/app/oracle/product/12.1.0/dbhome_1/bin


 - Linking Oracle

rm -f /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/oracle

/u01/app/oracle/product/12.1.0/dbhome_1/bin/orald  -o /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/oracle -m64 -z noexecstack -Wl,--disable-new-dtags -L/u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/ -L/u01/app/oracle/product/12.1.0/dbhome_1/lib/ -L/u01/app/oracle/product/12.1.0/dbhome_1/lib/stubs/   -Wl,-E /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/opimai.o /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/ssoraed.o /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/ttcsoi.o -Wl,--whole-archive -lperfsrv12 -Wl,--no-whole-archive /u01/app/oracle/product/12.1.0/dbhome_1/lib/nautab.o /u01/app/oracle/product/12.1.0/dbhome_1/lib/naeet.o /u01/app/oracle/product/12.1.0/dbhome_1/lib/naect.o /u01/app/oracle/product/12.1.0/dbhome_1/lib/naedhs.o /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/config.o  -lserver12 -lodm12 -lcell12 -lnnet12 -lskgxp12 -lsnls12 -lnls12  -lcore12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lxml12 -lcore12 -lunls12 -lsnls12 -lnls12 -lcore12 -lnls12 -lclient12  -lvsn12 -lcommon12 -lgeneric12 -lknlopt `if /usr/bin/ar tv /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/libknlopt.a | grep xsyeolap.o > /dev/null 2>&1 ; then echo "-loraolap12" ; fi` -lskjcx12 -lslax12 -lpls12  -lrt -lplp12 -lserver12 -lclient12  -lvsn12 -lcommon12 -lgeneric12 `if [ -f /u01/app/oracle/product/12.1.0/dbhome_1/lib/libavserver12.a ] ; then echo "-lavserver12" ; else echo "-lavstub12"; fi` `if [ -f /u01/app/oracle/product/12.1.0/dbhome_1/lib/libavclient12.a ] ; then echo "-lavclient12" ; fi` -lknlopt -lslax12 -lpls12  -lrt -lplp12 -ljavavm12 -lserver12  -lwwg  `cat /u01/app/oracle/product/12.1.0/dbhome_1/lib/ldflags`    -lncrypt12 -lnsgr12 -lnzjs12 -ln12 -lnl12 -lnro12 `cat /u01/app/oracle/product/12.1.0/dbhome_1/lib/ldflags`    -lncrypt12 -lnsgr12 -lnzjs12 -ln12 -lnl12 -lnnzst12 -lzt12 -lztkg12 -lmm -lsnls12 -lnls12  -lcore12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lxml12 -lcore12 -lunls12 -lsnls12 -lnls12 -lcore12 -lnls12 -lztkg12 `cat /u01/app/oracle/product/12.1.0/dbhome_1/lib/ldflags`    -lncrypt12 -lnsgr12 -lnzjs12 -ln12 -lnl12 -lnro12 `cat /u01/app/oracle/product/12.1.0/dbhome_1/lib/ldflags`    -lncrypt12 -lnsgr12 -lnzjs12 -ln12 -lnl12 -lnnzst12 -lzt12 -lztkg12   -lsnls12 -lnls12  -lcore12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lxml12 -lcore12 -lunls12 -lsnls12 -lnls12 -lcore12 -lnls12 `if /usr/bin/ar tv /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/libknlopt.a | grep "kxmnsd.o" > /dev/null 2>&1 ; then echo " " ; else echo "-lordsdo12"; fi` -L/u01/app/oracle/product/12.1.0/dbhome_1/ctx/lib/ -lctxc12 -lctx12 -lzx12 -lgx12 -lctx12 -lzx12 -lgx12 -lordimt12 -lclsra12 -ldbcfg12 -lhasgen12 -lskgxn2 -lnnzst12 -lzt12 -lxml12 -locr12 -locrb12 -locrutl12 -lhasgen12 -lskgxn2 -lnnzst12 -lzt12 -lxml12  -lgeneric12 -loraz -llzopro -lorabz2 -lipp_z -lipp_bz2 -lippdcemerged -lippsemerged -lippdcmerged  -lippsmerged -lippcore  -lippcpemerged -lippcpmerged  -lsnls12 -lnls12  -lcore12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lxml12 -lcore12 -lunls12 -lsnls12 -lnls12 -lcore12 -lnls12 -lsnls12 -lunls12  -lsnls12 -lnls12  -lcore12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lxml12 -lcore12 -lunls12 -lsnls12 -lnls12 -lcore12 -lnls12 -lasmclnt12 -lcommon12 -lcore12  -laio -lons    `cat /u01/app/oracle/product/12.1.0/dbhome_1/lib/sysliblist` -Wl,-rpath,/u01/app/oracle/product/12.1.0/dbhome_1/lib -lm    `cat /u01/app/oracle/product/12.1.0/dbhome_1/lib/sysliblist` -ldl -lm   -L/u01/app/oracle/product/12.1.0/dbhome_1/lib

test ! -f /u01/app/oracle/product/12.1.0/dbhome_1/bin/oracle ||\

           mv -f /u01/app/oracle/product/12.1.0/dbhome_1/bin/oracle /u01/app/oracle/product/12.1.0/dbhome_1/bin/oracleO

mv /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/oracle /u01/app/oracle/product/12.1.0/dbhome_1/bin/oracle

chmod 6751 /u01/app/oracle/product/12.1.0/dbhome_1/bin/oracle

[oracle@<server_name> lib]$




[oracle@<server_name> lib]$ sqlplus / as sysdba


SQL*Plus: Release 12.1.0.1.0 Production on Mon May 20 22:24:34 2024


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


Connected to an idle instance.


SQL> startup mount;

ORACLE instance started.


Total System Global Area 1369579520 bytes

Fixed Size                  2288200 bytes

Variable Size             436209080 bytes

Database Buffers          922746880 bytes

Redo Buffers                8335360 bytes

Database mounted.

SQL> alter database open;


Database altered.


SQL> select name,open_mode from v$database;


NAME      OPEN_MODE

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

SOURCE    READ WRITE




Monday, November 28, 2016

scrip to check the query execution time in oracle database

You can use below query to find out the execution time of the query. Just replace the SQL_ID with your SQL_ID.

SELECT
SQL_ID,
EXECUTIONS,
ELAPSED_TIME/1000000 TOTAL_ELAPSED_TIME_SEC,
ELAPSED_TIME/1000000/EXECUTIONS ELAPSED_TIME_SEC_PER_EXEC,
CPU_TIME/1000000 TOTAL_CPU_TIME_SEC,
CPU_TIME/1000000/EXECUTIONS CPU_TIME_SEC
FROM
V$SQL WHERE SQL_ID='dx647nxstqu260';

To calculate the execution time from the AWR tables, you can use below query.

SELECT
SNAP_ID,
SQL_ID,
EXECUTIONS_DELTA EXECUTIONS,
ELAPSED_TIME_DELTA/1000000 TOTAL_ELAPSED_TIME_SEC,
ELAPSED_TIME_DELTA/1000000/EXECUTIONS_DELTA ELAPSED_TIME_SEC_PER_EXEC,
CPU_TIME_DELTA/1000000 TOTAL_CPU_TIME_SEC,
CPU_TIME_DELTA/1000000/EXECUTIONS_DELTA CPU_TIME_SEC
FROM
DBA_HIST_SQLSTAT WHERE SQL_ID='dx647nxstqu260';

Thursday, November 10, 2016

How to create manual profile in oracle 10g database?

issue:
oracle 10g database sql execution plan got changed and sql performing badly.
root cause:
oracle picked up the new plan which is a bad plan and same time we have good plan in AWR.
we have to force oracle to pick the good plan. but in 10g we dont have baseline features,so we cant forcefully oracle to pick the new plan.
solution:
In oracle 10g database version we don't have SPM and we have some  other  method to pick  the old plan.

we have SQLT feature is there and using it we can create manual profile by passing the SQL_ID and plan_hash_value.

coe_xfr_sql_profile.sql

SQL> START coe_xfr_sql_profile.sql [SQL_ID] [PLAN_HASH_VALUE];
it will create new SQL file to create a profile on the database and we can create the profile on the database.
check the profile status using dba_sql_profiles

Monday, October 3, 2016

what are the various methods for tracing a session in oracle database?

1)ALTER SESSION SET EVENTS ’10046 TRACE NAME CONTEXT FOREVER,LEVEL 12′;

2)DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION(SID, SERIAL#, TRUE);

DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION(SID, SERIAL#, FALSE);

3)DBMS_SUPPORT.START_TRACE_IN_SESSION(SID, SERIAL#, WAITS, BINDS);

SQL> @?/rdbms/admin/dbmssupp.sql


4)DBMS_MONITOR.SESSION_TRACE_ENABLE(SESSION_ID, SERIAL_NUM,BINDS,WAITS);

5)how to find the trace file location using sql query?


select
   u_dump.value || '/' ||
   db_name.value || '_ora_' ||
   v$process.spid ||
   nvl2(v$process.traceid, '_' || v$process.traceid, null )||'.trc' "Trace File"
from
   v$parameter u_dump
cross join
   v$parameter db_name
cross join
   v$process
join
   v$session
on
   v$process.addr = v$session.paddr
where
   u_dump.name = 'user_dump_dest'
and
   db_name.name = 'db_name'
and
v$session.audsid=sys_context('userenv','sessionid');

6) convert the trace files to human readble format using tkprof
trprof source_file target_file




Tuesday, September 27, 2016

How to calculate optimal SYSAUX tablespace size ON ORACLE DATABASE?

we have oracle provided script to check optimal  sysaux tablespace size.
script located under rdbms/admin

$ORACLE_HOME/rdbms/admin/utlsyxsz.sql;


SQL> @utlsyxsz.sql;


This script estimates the space required for the SYSAUX tablespace.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Specify the Report File Name
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The default report file name is utlsyxsz.txt.  To use this name,
press <return> to continue, otherwise enter an alternative.

Enter value for report_name: awr.log


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SYSAUX Size Estimation Report
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Estimated at
12:01:02 on Sep 27, 2016 ( Tuesday ) in Timezone -05:00


DB_NAME     HOST_PLATFORM                             INST STARTUP_TIME      PAR
----------- ---------------------------------------- ----- ----------------- ---
* TEST      servername                1 11:22:14 (07/17)  NO

~~~~~~~~~~~~~~~~~~~~
Current SYSAUX usage
~~~~~~~~~~~~~~~~~~~~
| Total SYSAUX size:                         180.9 MB
|
| Total size of SM/AWR                        76.0 MB (  42.0% of SYSAUX )
| Total size of SM/OPTSTAT                    71.8 MB (  39.7% of SYSAUX )
| Total size of SM/ADVISOR                    10.3 MB (   5.7% of SYSAUX )
| Total size of LOGMNR                         5.9 MB (   3.3% of SYSAUX )
| Total size of SM/OTHER                       4.8 MB (   2.6% of SYSAUX )
| Total size of EM_MONITORING_USER             1.6 MB (   0.9% of SYSAUX )
| Total size of LOGSTDBY                       0.9 MB (   0.5% of SYSAUX )
| Total size of XSOQHIST                       0.8 MB (   0.4% of SYSAUX )
| Total size of AO                             0.8 MB (   0.4% of SYSAUX )
| Total size of STREAMS                        0.5 MB (   0.3% of SYSAUX )
| Total size of JOB_SCHEDULER                  0.4 MB (   0.2% of SYSAUX )
| Total size of TSM                            0.3 MB (   0.1% of SYSAUX )
| Total size of Others                         7.1 MB (   3.9% of SYSAUX )
|

~~~~~~~~~~~~~~~~~~~~
AWR Space Estimation
~~~~~~~~~~~~~~~~~~~~

| To estimate the size of the Automatic Workload Repository (AWR)
| in SYSAUX, we need the following values:
|
|     - Interval Setting (minutes)
|     - Retention Setting (days)
|     - Number of Instances
|     - Average Number of Active Sessions
|     - Number of Datafiles

|
| For 'Interval Setting',
|   Press <return> to use the current value:     60.0 minutes
|   otherwise enter an alternative
|
Enter value for interval: 30

**   Value for 'Interval Setting': 30

|
| For 'Retention Setting',
|   Press <return> to use the current value:   7.00 days
|   otherwise enter an alternative
|
Enter value for retention: 7

**   Value for 'Retention Setting': 7

|
| For 'Number of Instances',
|   Press <return> to use the current value:   1.00
|   otherwise enter an alternative
|
Enter value for num_instances: 1

**   Value for 'Number of Instances': 1

|
| For 'Average Number of Active Sessions',
|   Press <return> to use the current value:   0.00
|   otherwise enter an alternative
|
Enter value for active_sessions: 10

**   Value for 'Average Number of Active Sessions': 10

| ***************************************************
| Estimated size of AWR:                     310.5 MB
|
|   The AWR estimate was computed using
|   the following values:
|
|            Interval -        30 minutes
|           Retention -      7.00 days
|       Num Instances -         1
|     Active Sessions -     10.00
|           Datafiles -         7
| ***************************************************

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Optimizer Stat History Space Estimation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

| To estimate the size of the Optimizer Statistics History
| we need the following values:
|
|     - Number of Tables in the Database
|     - Number of Partitions in the Database
|     - Statistics Retention Period (days)
|     - DML Activity in the Database (level)

|
| For 'Number of Tables',
|   Press <return> to use the current value:    663.0
|   otherwise enter an alternative <a positive integer>
|
Enter value for number_of_tables:

**   Value for 'Number of Tables': 663

|
| For 'Number of Partitions',
|   Press <return> to use the current value:   0.00
|   otherwise enter an alternative <a positive integer>
|
Enter value for number_of_partitions:

**   Value for 'Number of Partitions': 0

|
| For 'Statistics Retention',
|   Press <return> to use the current value:     31.0 days
|   otherwise enter an alternative <a positive integer>
|
Enter value for stats_retention:

**   Value for 'Statistics Retention': 31

|
| For 'DML Activity',
|   Press <return> to use the current value:        2 <medium>
|   otherwise enter an alternative <1=low, 2=medium, 3=high>
|
Enter value for dml_activity:

**   Value for 'DML Activity': 2

| ***************************************************
| Estimated size of Stats history             23.8 MB
|
|   The space for Optimizer Statistics history was
|   estimated using the following values:
|
|                         Tables -     663
|                        Indexes -   1,313
|                        Columns -   4,282
|                     Partitions -       0
|          Indexes on Partitions -       0
|          Columns in Partitions -       0
|        Stats Retention in Days -      31
|          Level of DML Activity -  Medium
| ***************************************************

~~~~~~~~~~~~~~~~~~~~~~
Estimated SYSAUX usage
~~~~~~~~~~~~~~~~~~~~~~

| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Estimated size of AWR:                     310.5 MB
|
|   The AWR estimate was computed using
|   the following values:
|
|            Interval -        30 minutes
|           Retention -      7.00 days
|       Num Instances -         1
|     Active Sessions -     10.00
|           Datafiles -         7
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Estimated size of Stats history             23.8 MB
|
|   The space for Optimizer Statistics history was
|   estimated using the following values:
|
|                         Tables -     663
|                        Indexes -   1,313
|                        Columns -   4,282
|                     Partitions -       0
|          Indexes on Partitions -       0
|          Columns in Partitions -       0
|        Stats Retention in Days -      31
|          Level of DML Activity -  Medium
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|   For all the other components, the estimate
|   is equal to the current space usage of
|   the component.
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
| ***************************************************
| Summary of SYSAUX Space Estimation
| ***************************************************

| Est size of SM/ADVISOR                      10.3 MB
| Est size of LOGMNR                           5.9 MB
| Est size of SM/OTHER                         4.8 MB
| Est size of EM_MONITORING_USER               1.6 MB
| Est size of LOGSTDBY                         0.9 MB
| Est size of XSOQHIST                         0.8 MB
| Est size of AO                               0.8 MB
| Est size of STREAMS                          0.5 MB
| Est size of JOB_SCHEDULER                    0.4 MB
| Est size of TSM                              0.3 MB
| Est size of Others                           7.1 MB

| Est size of SM/AWR                         310.5 MB
| Est size of SM/OPTSTAT                      23.8 MB
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Total Estimated SYSAUX size:               367.4 MB
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| ***************************************************

End of Report

Tuesday, September 20, 2016

ORA-19588: archived log RECID 2986343 STAMP 4532923 is no longer valid

ORA-19588: archived log RECID 2986343 STAMP 4532923 is no longer valid

check if the SEQ log backed up

LIST BACKUP OF ARCHIVELOG FROM SEQUENCE <SEQ Number>,if its backed up you can ignore it

cause:
Root cause could be due to 2 simultaneous backup sessions where one refers to and the other had already backed up and not needed to be backed up.


Wednesday, September 7, 2016

when the execution plan change for oracle database for single SQL?


How Execution Plans Can Change occur by the below reasons:


  1. Schema changes (usually changes in indexes & table ) between the two operations.
  2. Different Costs
  3. Even if the schema are the same, the optimizer can choose different execution plans when the costs are different. Some factors that affect the costs include the following:
  • Data volume and statistics
  • Bind variable types and literal values

what are the various modes to run ADDM in oracle database?

running modes for ADDM

DB
instance
partial

How to disable/remove AWR snapshot genration and ADDM job from oracle database

Disabling Oracle Performance Pack

   Disabling Performance Tuning & Diagnostic pack:

Method 1:  Revoking Management Pack Access through OEM
Home Page>setup>Management Pack Access <Remove Access> <Apply>




Method 2:
  Step 1

Disable Automatic/manual AWR snapshots                    

SQL> @dbmsnoawr.plb  <This Package is downloaded from My Support Article ID 436386.1>

SQL> begin dbms_awr.disable_awr(); end;

Impact:

·         Stops Automatic AWR snapshots
·         Does not allow taking manual snapshot.
·         All  <report>.sql files will work for old snaps

Step 2
To Disable Automatic ADDM
ALTER SYSTEM set "_addm_auto_enable"=false;
(Dynamic parameter)

Impact:
·         Disables automatic ADDM which gets run automatically after every Automatic AWR snapshots
CONTROL_MANAGEMENT_PACK_ACCESS to NONE disables ADDM.

Wednesday, August 31, 2016

How to calculate UNDO table space optimal size in oracle database?

Here is the list of steps to follow to get optimal UNDO table space.

Undo Space = UNDO_RETENTION in seconds * undo blocks for each second * block_size of the database/TBS

lets say if undo retention 1 hr 60*60 seconds
undo block usage per second 300
undo block size 8k 8192

so optimal undo size=60*60 *300*8192/1024/124=843 MB



To check the block_size on database


SELECT TO_NUMBER(value) as DB_BLOCK_SIZE   FROM v$parameter WHERE name = 'db_block_size';

find the number of undo block per second;

SELECT MAX(undoblks/((end_time-begin_time)*3600*24)) as UNDO_BLOCK_PER_SECOND   FROM v$undostat;

To check the undo retention of tablespaces.

select name,value FROM v$parameter WHERE name='undo_retention';

Monday, August 15, 2016

scrip to check the Progress of the SQL Tuning Advisor job in oracle database?

You can check the execution progress of the SQL Tuning Advisor in the V$ADVISOR_PROGRESS view.


SELECT sofar, totalwork FROM V$ADVISOR_PROGRESS
WHERE user_name = <USER_NAME>' AND task_name = '<sql_tuning_task_NAME>';

what are the input source for SQL tunning advisor in oracle database?

SQL tuning advisor inputs:


1.addm
2.awr
3.cursor cache
4.STS(SQL tuning Sets)

what are the statements we can apply SQL profiles in oracle database?

SQL Profiles apply to the following statement types:


SELECT statements
UPDATE statements
INSERT statements (only with a SELECT clause)
DELETE statements
CREATE TABLE statements (only with the AS SELECT clause)
MERGE statements (the update or insert operations)

Thursday, August 4, 2016

what is the pre-request for converting standby database to max protection & max availability?

Here is the pre-request for converting standby database to Max.availability & Max Protection

1)need to create Standby Redo log
2)DB  Flashback would be turned ON
3)Log Transport mode should be SYNC

Wednesday, August 3, 2016

script to find out wait event objects in oracle database.

Steps to get the wait event object name

select event,p1,p2,p3 from V$session_wait where
sid in (select sid from v$session where username='BALA');

where P1--file# P2 block number


define __FILE = &1
define __BLOCK = &2

select segment_name from dba_extents where file_id = &__FILE
and &__BLOCK between block_id and block_id + blocks - 1 and rownum = 1 ;

set echo on

Friday, July 29, 2016

Steps to restore oracle database using RMAN & resetting the incarnation.

Steps to restore oracle database using RMAN & resetting the incarnation.

Step#1
Connect to the rman & identify the backup piece
<server_name>:<OSuser_name> 49> rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Sun Jul 17 22:21:14 2016

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

connected to target database: <DB_name> (not mounted)

RMAN> connect catalog rman/****@RCAT;

connected to recovery catalog database

Database needs to be in nomunt state.

Step#2
Restore the ctl file
RMAN> restore controlfile from '/tmp/DD_Backup/<server_name>/<DB_name>/database/<DB_name>_ctl_spfile_c-238613855-20160717-05';

Starting restore at 17-JUL-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=317 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=380 device type=DISK

channel ORA_DISK_2: skipped, AUTOBACKUP already found
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
output file name=/oracle/<DB_name>/control1/cntrl<DB_name>.dbf
output file name=/oracle/<DB_name>/control2/cntrl<DB_name>.dbf
output file name=/oracle/<DB_name>/control3/cntrl<DB_name>.dbf
Finished restore at 17-JUL-16

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1
released channel: ORA_DISK_2
step #3 check the incarnation & reset the incarnation to use old backups
RMAN> list incarnation of database <DB_name>;


List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
3038857 3038858 <DB_name>      238613855        PARENT  1          10-JAN-11
3038857 25197016 <DB_name>      238613855        CURRENT 220087209  17-JUL-16

RMAN> reset database to incarnation 3038858;

database reset to incarnation 3038858

RMAN>
Step#3 restore the DB where the app team wants to rollforward
RMAN> run
{
allocate channel dev1 type disk;
allocate channel dev2 type disk;
set until time "to_date('2016-07-17:09:00:00', 'yyyy-mm-dd:hh24:mi:ss')";
restore database;
recover database;
release channel dev1;
release channel dev2;
}
2> 3> 4> 5> 6> 7> 8> 9> 10>
allocated channel: dev1
channel dev1: SID=317 device type=DISK

allocated channel: dev2
channel dev2: SID=380 device type=DISK

executing command: SET until clause

Starting restore at 17-JUL-16

channel dev1: starting datafile backup set restore
channel dev1: specifying datafile(s) to restore from backup set
channel dev1: restoring datafile 00002 to /oracle/<DB_name>/sapdata888/undo_1/undo.data1
channel dev1: reading from backup piece /tmp/DD_Backup/<server_name>/<DB_name>/database/DF_<DB_name>_2016_07_17_08_00_6307_1_917424023_53rathsn_1_1
channel dev2: starting datafile backup set restore
channel dev2: specifying datafile(s) to restore from backup set
channel dev2: restoring datafile 00005 to /oracle/<DB_name>/sapdata1/user_1/user.data1
channel dev2: reading from backup piece /tmp/DD_Backup/<server_name>/<DB_name>/database/DF_<DB_name>_2016_07_17_08_00_6309_1_917424078_55rathue_1_1
channel dev2: piece handle=/tmp/DD_Backup/<server_name>/<DB_name>/database/DF_<DB_name>_2016_07_17_08_00_6309_1_917424078_55rathue_1_1 tag=TAG20160717T080023
channel dev2: restored backup piece 1
channel dev2: restore complete, elapsed time: 00:00:26
channel dev2: starting datafile backup set restore
channel dev2: specifying datafile(s) to restore from backup set
channel dev2: restoring datafile 00001 to /oracle/<DB_name>/sapdata777/system_1/system.data1
channel dev2: reading from backup piece /tmp/DD_Backup/<server_name>/<DB_name>/database/DF_<DB_name>_2016_07_17_08_00_6310_1_917424086_56rathum_1_1
channel dev2: piece handle=/tmp/DD_Backup/<server_name>/<DB_name>/database/DF_<DB_name>_2016_07_17_08_00_6310_1_917424086_56rathum_1_1 tag=TAG20160717T080023
channel dev2: restored backup piece 1
channel dev2: restore complete, elapsed time: 00:00:35
channel dev2: starting datafile backup set restore
channel dev2: specifying datafile(s) to restore from backup set
channel dev2: restoring datafile 00003 to /oracle/<DB_name>/sapdata777/sysaux_1/sysaux.data1
channel dev2: reading from backup piece /tmp/DD_Backup/<server_name>/<DB_name>/database/DF_<DB_name>_2016_07_17_08_00_6311_1_917424181_57rati1l_1_1
channel dev1: piece handle=/tmp/DD_Backup/<server_name>/<DB_name>/database/DF_<DB_name>_2016_07_17_08_00_6307_1_917424023_53rathsn_1_1 tag=TAG20160717T080023
channel dev1: restored backup piece 1
channel dev1: restore complete, elapsed time: 00:01:04
channel dev1: starting datafile backup set restore
channel dev1: specifying datafile(s) to restore from backup set
channel dev1: restoring datafile 00004 to /oracle/<DB_name>/sapdata1/sr3db_1/sr3db.data1
channel dev1: reading from backup piece /tmp/DD_Backup/<server_name>/<DB_name>/database/DF_<DB_name>_2016_07_17_08_00_6308_1_917424023_54rathsn_1_1
channel dev2: piece handle=/tmp/DD_Backup/<server_name>/<DB_name>/database/DF_<DB_name>_2016_07_17_08_00_6311_1_917424181_57rati1l_1_1 tag=TAG20160717T080023
channel dev2: restored backup piece 1
channel dev2: restore complete, elapsed time: 00:00:27
channel dev1: piece handle=/tmp/DD_Backup/<server_name>/<DB_name>/database/DF_<DB_name>_2016_07_17_08_00_6308_1_917424023_54rathsn_1_1 tag=TAG20160717T080023
channel dev1: restored backup piece 1
channel dev1: restore complete, elapsed time: 00:02:15
Finished restore at 17-JUL-16

Starting recover at 17-JUL-16

starting media recovery

archived log for thread 1 with sequence 16600 is already on disk as file /oracle/<DB_name>/oraarch/<DB_name>arch1_16600_740086239.dbf
channel dev1: starting archived log restore to default destination
channel dev1: restoring archived log
archived log thread=1 sequence=16598
channel dev1: reading from backup piece /tmp/DD_Backup/<server_name>/<DB_name>/archivelog/AL_<DB_name>_2016_07_17_08_00_6313_1_917424329_59rati69_1_1
channel dev2: starting archived log restore to default destination
channel dev2: restoring archived log
archived log thread=1 sequence=16599
channel dev2: reading from backup piece /tmp/DD_Backup/<server_name>/<DB_name>/archivelog/AL_<DB_name>_2016_07_17_08_00_6314_1_917424329_5arati69_1_1
channel dev2: piece handle=/tmp/DD_Backup/<server_name>/<DB_name>/archivelog/AL_<DB_name>_2016_07_17_08_00_6314_1_917424329_5arati69_1_1 tag=TAG20160717T080528
channel dev2: restored backup piece 1
channel dev2: restore complete, elapsed time: 00:00:02
channel dev1: piece handle=/tmp/DD_Backup/<server_name>/<DB_name>/archivelog/AL_<DB_name>_2016_07_17_08_00_6313_1_917424329_59rati69_1_1 tag=TAG20160717T080528
channel dev1: restored backup piece 1
channel dev1: restore complete, elapsed time: 00:00:08
archived log file name=/oracle/<DB_name>/oraarch/<DB_name>arch1_16598_740086239.dbf thread=1 sequence=16598
archived log file name=/oracle/<DB_name>/oraarch/<DB_name>arch1_16599_740086239.dbf thread=1 sequence=16599
archived log file name=/oracle/<DB_name>/oraarch/<DB_name>arch1_16600_740086239.dbf thread=1 sequence=16600
media recovery complete, elapsed time: 00:00:05
Finished recover at 17-JUL-16

released channel: dev1

released channel: dev2

RMAN> alter database open RESETLOGS;

database opened
new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

step#4
Take a full backup of database once database is open.

Wednesday, April 20, 2016

query eating more Temp space and throwing ORA-01652: unable to extend temp segment by even for one row


Hi All,
I had situation  when tried to fetch some amount of records from v$rman_backup_job_details,its keep eating lot of temp space and finally throws error on 10204.


ORA-01652: unable to extend temp segment by 256 in tablespace TEMP 

finally identified there was a bug and below is the work around.

you are likely to be running in to Bug 5466436

The workaround for this issue is to delete statistics from the X$KCCRSR ie:
exec dbms_stats.DELETE_TABLE_STATS('SYS','X$KCCRSR');
- this deletes the statistics on the fixed object  and
exec dbms_stats.LOCK_TABLE_STATS('SYS','X$KCCRSR');
- this locks that object so that statistics will not be collected in future.

Monday, April 18, 2016

Difference between SQL profile Vs SQL plan management baselines

BASIC INFO
SQL PROFILES
SPM BASELINES
What they are
Stored collections of Hints (plus some technical information for the optimizer)
Stored collections of Hints (plus some technical information for the optimizer)
Available from
10g
11g
They affect
Individual SQL
Individual SQL
What they do
Adjust Optimizer cardinality estimations
Direct SQL to follow specific execution plan
Motto (as far asSQL Plans are concerned)
Be the Best you can be !
Only the Worthy may Pass !
Managed by PL/SQL package
dbms_sqltune
dbms_spm
How are they created ?
Run SQL Tuning task (dbms_sqltune.execute_tuning_task) to analyze existing SQL and IF cardinality is skewed, store it as SQLProfile
Take existing execution plan from SQL that already ran and store it as SPM baseline
Can their creation be forced ?
YES, but this is not fully supported. I.e.


YES, ifoptimizer_capture_sql_plan_baselines=TRUE
Can they be created manually for individual SQL?
YES, bydbms_sqltune.execute_tuning_task()
YES, but SQL needs to already have run:dbms_spm.load_plans_from_cursor_cache(sql_id => …)
Can they be captured for the ongoing workload ?
YES, through SQL Tuning Sets
YES, if optimizer_capture_sql_plan_baselines=TRUE
Can they be “group loaded” from SQLs in the shared pool ?
YES, through SQL Tuning Sets
YES, directly
Can they be “group loaded” from SQLs in AWRrepository ?
YES, through SQL Tuning Sets
YES, through SQL Tuning Sets
Are they “activated” upon creation ?
NO, SQL Profiles need to be explicitly accepted
MAYBE, Baseline is activated if it is the first baseline captured (for the SQL) OR if loaded from cursor cache, AWR etc
Can they be activated automatically ?
YES, if accept_sql_profiles is set forSQL Tuning AutoTask
MAYBE, SPM baseline is activated if it is the first baseline captured (for the SQL)
Can they be deactivated globally ?
NO
YES, Setoptimizer_use_sql_plan_baselines=FALSE
Can they be deactivated locally ?
YES, set sqltune_category
NO
Can they be transferred to another database ?
YES
YES
Can they “fire” for the object in different schema ?
YES
YES
Can they “fire” when object has a different structure ?
YES
YES
Can they “fire” when table is replaced withMVIEW ?
YES
NO
Can they “fire” when some objects (i.e. indexes) used in the original plan are missing for the new object ?
YES
NO
Available in Standard Edition ?
NO
NO
Available in genericENTERPRISEEdition ?
NO, you need to also licenseDIAGNOSTICS and TUNING packs
YES