• CozWeAreFriends Banner. Nice isn't it?
  • CozWeAreFriends Banner. Nice isn't it?
  • Oracle SQL to generate maximum/high CPU on OVM Guest

    Posted on July 18th, 2015 by fath

    Hi All,

    There was a time during my project migrating our Oracle database servers to Oracle Virtual Machine (OVM) Guest (VM) that I had an issue regarding how the CPU works. Consider this scenario, you already provisioned 4 VCPUs to your guest running on Windows Server 2008 and then suddenly there is a need to increase the CPU since your Oracle database (oracle.exe) is starving for more processing power. What you did is simply increase the Guest’s VCPU on the fly through your OVM Manager console. The CPU somehow is reflected to your Windows OS (CPU in your task manager changed from 4 to 8 cores) but your oracle.exe process remained utilizing maximum 4 cores and not growing into the new 4 cores.

    I had searched through MOS and Google but cannot find much information related to the scenario except for some documentations regarding Guest sort-of bug but it however was affecting earlier version of OVM.

    Based on our testing in the environment, we found out that there’s no way to let our Oracle database process to switch to 8 VCPUs dynamically except after OS reboot. To test this, we had to ensure that our oracle.exe will initially consume maximum 4 CPUs and we tried to increase the VCPU afterwards.

    It was too bad that the database size was not that big hence I could not figure out how to simulate very high load in an easy way. So what I did was to use the following SQL so that the CPU retained at maximum all the time. I hope it will help anyone of you who is looking for the same answer.

    *Note: you may not want to run this in your production environment.

    SQL:
    select /*+ PARALLEL(100) */ distinct a.obj#, a.obj#
    from SOURCE$ a, WRH$_SYSMETRIC_HISTORY b



    UNIX – Shell script to capture SQL query using Oracle sqlplus

    Posted on April 22nd, 2012 by fath

    Hi All,
    In my project, as part of Performance Testing team, I’ve wrote a number of scripts to help us perform our duty in system tunings. Here. I’d like to share one of my shell script that can help to capture SQL query running in the background.Feel free to modify this script to fit your own requirement.

     

    ###############################
    # CAPTURE SQL – by Fath #
    ###############################
    ################# PARAMETERS #################

    ##############################################
    #SH_LOG=”$location/CAPTURE_SQL.log”

    clear
    echo “*****************************************************************”
    echo “PV SQL CAPTURE SCRIPT”
    echo “*****************************************************************”

    echo “LOADING CAPTURING SQL..”

    echo “”
    pros=`ps -ef | grep ora_pmon | awk ‘{print $9}’ | grep ora_pmon_ | awk ‘{print substr($1,10)}’`

    echo “Database running on Oracle Process = $pros”
    echo “Oracle SID = $ORACLE_SID”
    echo “Proceed? [y/n]”
    read option
    echo “”

    if [ “$option” = “y” ]
    then
    echo “Enter sid and serial#”
    echo “SID:”
    read sid
    echo “Serial #:”
    read serial

    result=`sqlplus -s ‘/as sysdba’ << ENDOFSQL
    begin
    dbms_system.set_ev(‘$sid’,’$serial’,10046,12,”);
    end;
    /

    begin
    DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION (sid=>’$sid’, serial#=>’$serial’,sql_trace=>TRUE);
    end;
    /
    show parameter user_dump_dest
    exit;
    ENDOFSQL`

    #path=”$result”

    echo “”
    echo “——————————-”
    echo “Remarks:”
    echo “Spooled queries will be generated in:”
    #echo “$path” | grep /app | awk ‘{print $3}’

    path=”/app/oracle/admin/NSBLPVT/udump”
    echo “$path”
    echo “——————————-”
    echo “”

    while true
    do
    echo “Stop capturing? [y/n]”
    read option2
    echo “”

    if [ “$option2” = “y” ]
    then
    result2=`sqlplus -s ‘/as sysdba’ << ENDOFSQL
    begin
    DBMS_SYSTEM.SET_SQL_TRACE_IN_SESSION (sid=>’$sid’, serial#=>’$serial’,sql_trace=>FALSE);
    end;
    /
    exit;
    ENDOFSQL`

    echo “——————————-”
    echo “Results: ”
    echo “SQL captured in: ”
    result3=`ls -lrt $path | tail -n 1 | awk ‘{print $9}’`
    echo “$result3”
    echo “Converting trace file to log…”
    result4=`tkprof $path/$result3 SQL_CAPTURED[$result3].log sys=no waits=yes sort=exeela`
    echo “Converted to SQL_CAPTURED[$result3].log…”
    echo “Completed.”
    echo “——————————-”

    break
    fi
    done
    fi

    echo “”
    echo “SEE YOU AGAIN!!”
    echo “”