Skip to main content

Posts

Showing posts from September, 2016

HOW TO RECOVER A FILE DELETED WITHOUT A BACKUP

Recover deleted files with lsof Every process on the system has a directory here with its name on it, inside of which lies many things -- including an fd ("file descriptor") subdirectory containing links to all files that the process has open. Even if a file has been removed from the filesystem, a copy of the data will be right here: /proc/ process id /fd/ file descriptor $ ls -l myfile -rw-r--r-- 1 jimbo jimbo 114383 Oct 31 16:14 myfile $ stat myfile File: `myfile' Size: 114383 Blocks: 232 IO Block: 4096 regular file Device: 341h/833d Inode: 1276722 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1010/ jimbo) Gid: ( 1010/ jimbo) Access: 2006-10-31 16:15:08.423715488 -0400 Modify: 2006-10-31 16:14:52.684417746 -0400 Change: 2006-10-31 16:14:52.684417746 -0400  REMOVE NOW $ rm myfile $ ls -l myfile ls: myfile: No such file or directory $ stat myfile stat: cannot stat `myfile': No such file or directory $ AN

How to see IO service time histogram order by Read Time in ms.

col read_time format a9 heading "Read Time|(ms)" col reads format 999999,99999999,9999999 heading "Reads" col histogram format a51 heading "" set pagesize 10000 set lines 100  set echo on  SELECT LAG(singleblkrdtim_milli, 1)           OVER (ORDER BY singleblkrdtim_milli)            || '<' || singleblkrdtim_milli read_time,         SUM(singleblkrds) reads,        RPAD(' ', ROUND(SUM(singleblkrds) * 50 /           MAX(SUM(singleblkrds)) OVER ()), '*')  histogram FROM v$file_histogram GROUP BY singleblkrdtim_milli ORDER BY singleblkrdtim_milli;  Read Time (ms)                         Reads --------- ------------------------ --------------------------------------------------- <1                     660,1811398  ************************************************* 1<2                     25,2251982  * 2<4                      4,5348096 4<8                        5699221 8<16                    

How to see top 10 user that consumes PGA memory.

set pagesize 1000 set lines 1000 col sid format 9999 col username format a12 col module format a30 column pga_memory_mb format 9,99999.99 heading "PGA MB" column max_pga_memory_mb format 9,999999.99 heading "PGA MAX|MB" col service name format a20  col sql_text format a70 heading "Currently executing SQL" set echo on  WITH pga AS      (SELECT sid,             ROUND(SUM(CASE name WHEN 'session pga memory'                         THEN VALUE / 1048576 END),2) pga_memory_mb,             ROUND(SUM(CASE name WHEN 'session pga memory max'                        THEN VALUE / 1048576  END),2) max_pga_memory_mb       FROM v$sesstat         JOIN v$statname  USING (statistic#)      WHERE name IN ('session pga memory','session pga memory max' )      GROUP BY sid) SELECT sid, username,s.module,         pga_memory_mb,         max_pga_memory_mb, substr(sql_text,1,70) sql_text   FROM v$session s   JOIN (SELECT sid

How to see top 20 sql that is not using bind variables.

set pages 1000 set lines 10000 set echo on  column schema format a20 column sql_text format a80  WITH force_matches AS        (SELECT force_matching_signature,                COUNT( * )  matches,                MAX(sql_id || child_number) max_sql_child,                DENSE_RANK() OVER (ORDER BY COUNT( * ) DESC)                   ranking         FROM v$sql         WHERE force_matching_signature <> 0           AND parsing_schema_name <> 'SYS'         GROUP BY force_matching_signature         HAVING COUNT( * ) > 5) SELECT sql_id,  matches, parsing_schema_name schema, sql_text   FROM    v$sql JOIN force_matches     ON (sql_id || child_number = max_sql_child) WHERE ranking <= 21 ORDER BY matches DESC; SQL_ID           MATCHES SCHEMA               SQL_TEXT ------------- ---------- -------------------- -------------------------------------------------------------- gzxsf4mv720t0       2392 SAPSR3               SELECT /*+ FIRST_ROWS (12) *

How to obtain latch statistics (get, misses and sleeps).

column name format a30 column pct_of_gets format 99.00 heading "Pct of|Gets" column pct_of_misses format 99.00 heading "Pct of|Misses" column pct_of_sleeps format 99.00 heading "Pct of|Sleeps" column pct_of_wait_time format 99.00 heading "Pct of|Wait Time" set pagesize 100 WITH latch AS (     SELECT name,            ROUND(gets * 100 / SUM(gets) OVER (), 2) pct_of_gets,            ROUND(misses * 100 / SUM(misses) OVER (), 2) pct_of_misses,            ROUND(sleeps * 100 / SUM(sleeps) OVER (), 2) pct_of_sleeps,            ROUND(wait_time * 100 / SUM(wait_time) OVER (), 2)                  pct_of_wait_time       FROM v$latch) SELECT * FROM latch WHERE pct_of_wait_time > .1 OR pct_of_sleeps > .1 ORDER BY pct_of_wait_time DESC;                                Pct of Pct of Pct of    Pct of NAME                             Gets Misses Sleeps Wait Time ------------------------------ ------ ------ ------ --------- cache b

Solaris 11.3 Bug# 21207532 System or DB hang in zil_commit() at shutdown

The issue is generated due to ZFS bug present in version lower than 11.3.2.4.0, those symptoms produce that some errors related with IO wait are generated in the trace log file of the Oracle Data Base, shutting down the mmon process as you see below Trace log example: Thu Sep 01 08:51:11 2016 WARNING: aiowait timed out 2 times Thu Sep 01 08:57:38 2016 minact-scn: got error during useg scan e:12751 usn:4 minact-scn: useg scan erroring out with error e:12751 Suspending MMON action 'Block Cleanout Optim, Undo Segment Scan' for 82800 seconds Thu Sep 01 09:01:11 2016 WARNING: aiowait timed out 3 times Thu Sep 01 09:07:20 2016 Suspending MMON action 'undo usage' for 82800 seconds Thu Sep 01 09:11:11 2016 WARNING: aiowait timed out 4 times Thu Sep 01 09:12:03 2016 Shutting down instance (immediate) Stopping background process SMCO Thu Sep 01 09:12:34 2016 Background process SMCO not dead after 30 seconds Killing background process SMCO Shutting

How to check database i/o waits and compare them with CPU

How to check database i/o waits and compare them with CPU column wait_type format a35 heading "Wait Type" column lock_name format a12 column waits_1000 format  99,999,999 heading "Waits|\1000" column time_waited_hours format 99,999.99 heading "Time|Hours" column pct format 99.99 Heading "Pct" column avg_wait_ms format 9,999.99 heading "Avg Wait|Ms" set pagesize 10000 set lines 100 set echo on WITH system_event AS     (SELECT CASE               WHEN wait_class IN ('User I/O', 'System I/O')               THEN event ELSE wait_class              END  wait_type, e.*         FROM v$system_event e) SELECT wait_type, SUM(total_waits) / 1000 waits_1000,        ROUND(SUM(time_waited_micro) / 1000000 / 3600, 2)              time_waited_hours,        ROUND(SUM(time_waited_micro) / SUM(total_waits) / 1000, 2)              avg_wait_ms,        ROUND(  SUM(time_waited_micro)              * 100              / SU

How to check memory size por each user

SET LINESIZE 200 SET PAGESIZE 9999 COLUMN sid                     FORMAT 999            HEADING 'SID' COLUMN oracle_username         FORMAT a12            HEADING 'Oracle User'     JUSTIFY right COLUMN os_username             FORMAT a9             HEADING 'O/S User'        JUSTIFY right COLUMN session_program         FORMAT a11          HEADING 'Session Program' TRUNC COLUMN session_machine         FORMAT a8             HEADING 'Machine'         JUSTIFY right TRUNC COLUMN session_pga_memory      FORMAT 9,999,999,999  HEADING 'PGA Memory' COLUMN logon_time              FORMAT 9,999,999,999  HEADING 'logon_time' COLUMN session_pga_memory_max  FORMAT 9,999,999,999  HEADING 'PGA Memory Max' COLUMN session_uga_memory      FORMAT 9,999,999,999  HEADING 'UGA Memory' COLUMN session_uga_memory_max  FORMAT 9,999,999,999  HEADING 'UGA Memory MAX' SELECT      lpad(s.username,12)  oracle_username   ,

How to Force The Database Open With `_ALLOW_RESETLOGS_CORRUPTION

This is an internal note from Oracle. Forcing The Database Open With `_ALLOW_RESETLOGS_CORRUPTION` with Automatic Undo Management ( Doc ID 283945.1 ) Warning The following instructions should only be used under the explicit direction of Oracle Support. These steps should only be used when all other conventional means of recovering the database have failed. Please note that there is no guarantee that this method will succeed. IF THE STEPS BELOW DO ALLOW YOU TO OPEN YOUR DATABASE THEN IT IS ESSENTIAL THAT THE DATABASE BE REBUILT AS IT IS NO LONGER SUPPORTED. FAILURE TO DO SO MAY LEAD TO DATA DICTIONARY INCONSISTENCIES, INTERNAL ERRORS AND CORRUPTIONS. ** Note: The steps here apply to Oracle 9i or higher and only and when Automatic Undo Management is being used. ** Steps to attempt to force the database open: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1) Backup the database while the database is closed. THE INSTRUCTIONS HERE ARE DESTRUCTIVE. YOU ARE STRONGLY A

How to check lob segments size

set linesize 300 col table_name format a20; col column_name format a15; col segment_name format a40; col bytes format 999; col TABLESPACE_NAME format a20; select table_name, column_name,a.bytes/1024/1024/1024 as gigas, segment_name,a.TABLESPACE_NAME from dba_segments a join dba_lobs b using (owner, segment_name) where b.table_name = 'table_name';

HOW TO INCREASE A VOLUME IN VxVM CLUSTERED

1.-Check server master what is the master server #vxdctl -c mode mode: enabled: cluster active - SLAVE master: linuxtest1 2.-Master Server ------------------ ------------------ linuxtest1 2.1.-Slave Server ------------------ ------------------ linuxtest2 3.-Connect to master server --------------------------- --------------------------- ssh linuxtest1 4.-Check DG and FS before the change in our case we will increase data03  #vxassist -g POE-dg  maxgrow data03 #vxassist -g POE-dg  maxsize data03 5.-Check Disks availables for adding in the Disk Group we discover the new disk sdat/sdau/sdav, that are in online status, however they are not part from any DG #vxdisk -o alldgs list DEVICE       TYPE            DISK         GROUP        STATUS cciss/c0d0   auto:none       -            -            online invalid sda          auto:cdsdisk    POE-54  POE-dg  online shared sdaa         auto:cdsdisk    -            -            online sdab         au

HACMP Moving Resources to Another node and Back Again to the main node

We have two servers AIX Hostname: aixtest1 Hostname: aixtest2 Moving Resource to other node --------------------------------   as root user   #smitty hacmp   Initialization and Standard Configuration   Extended Configuration   System Management (C-SPOC)   Problem Determination Tools    "SELECT C-SPOC"   Manage HACMP Services   HACMP Communication Interface Management   HACMP Resource Group and Application Management   HACMP Log Viewing and Management   HACMP File Collection Management   HACMP Security and Users Management   HACMP Logical Volume Management   HACMP Concurrent Logical Volume Management   HACMP Physical Volume Management    "SELECT HACMP Resource Group and Application Management"   Show the Current State of Applications and Resource Groups   Bring a Resource Group Online   Bring a Resource Group Offline   Move a Resource Group to Another Node / Site    "SELECT Move a Resource Group to Another Node / Site

HOW TO INSTALL UCB OR BERKLEY IF YOU HAVE .PROFILES USING THEM

#pkg install compatibility/ucb            Packages to install:  1        Create boot environment: No Create backup boot environment: No DOWNLOAD                                PKGS         FILES    XFER (MB)   SPEED Completed                                1/1         95/95      0.5/0.5 91.7k/s PHASE                                          ITEMS Installing new actions                       181/181 Updating package state database                 Done Updating package cache                           0/0 Updating image state                            Done Creating fast lookup database                   Done Updating package cache                           1/1 # ls -ltr /usr/ucb | more total 1086 -r-xr-xr-x   4 root     bin        56800 Aug 14 23:01 ps -r-xr-xr-x   1 root     bin          521 Sep 15 06:56 fastboot -r-xr-xr-x   1 root     bin          518 Sep 15 06:56 fasthalt -r-xr-xr-x   1 root     bin          613 Sep 15 06:56 file -rwxr-xr-x   1 root     bin