Friday, November 28, 2014

Oracle Performance Tuning

SQL_ID and CPU Usage
SQL> select * from (
             select sql_id, inst_id,
                sum(decode(vash.session_state, 'ON CPU', 1,0)) as "Number on CPU",
                sum(decode(vash.session_state, 'WAITING', 1, 0)) as "Number Waiting on CPU"
             from gv$active_session_history cash
             where sample_time > sys date -5/(60*24)
             group by sql_id, instead
             order by 3 desc
             ) where rownum <11;

Query top 10 SQL_ID's in the last 10 minutes

select * from
(select NVL(SQL_ID,'NULL') AS SQL_ID,
SUM(1) AS "DBTime IN SECONDES" FROM V$ACTIVE_SESSION_HISTORY
WHERE sample_time > sys date - 10/(24*60)
GROUP BY SQL_ID
ORDER BY 2 DESC)
WHERE ROWNUM < 11;

Wait Events Across Nodes
select * from (
select sql_id, inst_id,
                sum(decode(vash.session_state, 'ON CPU', 1,0)) as "Number on CPU",
                sum(decode(vash.session_state, 'WAITING', 1, 0)) as "Number Waiting on CPU",
                event , count(distinct(session_id||session_serial#)) as "SESSION COUNT"
             from gv$active_session_history cash
             where sample_time > sys date -5/(60*24)
             group by event,sql_id, instead
             order by 3 desc
             ) where rownum <11;

IO Waits by object from ASH

SELECT TW.*, DO.object_name from (
select current_obj#,
ROUND(SUM(CASE WHEN TIME_WAITED >= 1000000 THEN 1
ELSE 1000000 / TIME_WAITED END)) AS "Estimated IO Waits",
SUM(1) AS "ESTIMATED DBTIME"
FROM V$ACTIVE_SESSION_HISTORY
WHERE sample_time > sysdate - 5/(24*60) and TIME_WAITED > 0
and WAIT_CLASS = 'User I/O'
GROUP BY CURRENT_OBJ#
ORDER BY 2 DESC) TW, DBA_OBJECTS DO
WHERE DO.object_id=TW.current_obj#
and ROWNUM < 11;

Thursday, November 27, 2014

Oracle: Preliminary Connection

Login as oracle
$ sqlplus -prelim "/as sysdba"

 SQL> shutdown abort
 ORACLE instance shut down.
 SQL> exit


$ sqlplus / as sysdba
SQL> startup

Tuesday, November 25, 2014

Oracle VM Manager/VM Server: Migrate virtual machine between in-compatible/in different pool


  1. Shutdown target virutla machine
  2. Create same size virtual disk on target server
  3. Copy the existing virtual disk to replace the file generated in last step
  4. Create network for the target virtual machine
  5. Create new virtual machine with same configuration as original virutal machine
  6. Start up target virtual machine
To Create another Oracle VM Manager to replace existing one:

      Copy the UUID of your original Oracle VM Manager from the file /u01/app/oracle/ovm-manager-3/.config.

    After mounting the Oracle VM Manager install dvd on the file system of your virtual machine, run the installer as follows: ./runinstaller.sh --uuid <original_manager_uuid>. Select your preferred installation type, as you would with a regular install.

Stop your original Oracle VM Manager.
From the new Oracle VM Manager virtual machine, rediscover your Oracle VM Server and storage, and refresh your storage repository to make sure that that all your VM resources reappear.
After rediscovering the minimal setup, proceed with the installation and configuration of your full Oracle VM environment.