OracleLand

April 5, 2009

Some Oracle 10g Best Practices

Filed under: Administration — nomadetech @ 4:15 pm

  • Learn to decipher Awr reports.
  • Create index only where needed, drop unneeded indexes.
  • Use outlines if code is not modifiable.
  • Use RAID-5 for OLTP systems, 85-95% of io’s are reads anyway.
  • Create tablespace with extent management local and segment space management auto
  • If you cannot use the datapump:
    • TIP #1: Export with buffer=several hundred MB, recordlength=65535, direct=y
    • TIP #2: Import with commit=n, buffer=several hundred MB, recordlength=65535; and a large UNDO.
  • Use SGA_TARGET, don’t bother setting up the sga yourself.
  • In the Grid Control, set tablespace alert threshold to 92%, the default at 97% is too risky. Better, create a monitoring template.
  • Rebuild indexes online regularly; forget about validating the need to since some application indexes might be locked all the time. And as it is time consuming to find which indexes really need a rebuild.
    • TIP: If you can afford, recreate the index instead, it’s better than a rebuild
  • On a normal OLTP database, let Oracle gather the stats. Don’t bother.
  • Reorganize the tables by using alter table move tablespace ….
  • Cache all small static table into a buffer keep pool.
  • Scan the db regularly for costly full table scans.
  • Forget about the myth of restarting the database weekly to supposedly clean the instance, it flushes your cache and some views might suffer from this. In one instance, the view took 1h30 to re-cache itself.
  • If you see queries with lots of outer joins, validate each and every outer joins, some developers don’t take any chances!!! At one client, I saved them 2 cpu by removing 7 outer joins in a table trigger.

January 14, 2009

Compare timestamps in a text file

Filed under: Shell scripting — nomadetech @ 8:39 pm
Tags: , , ,

I needed to compare 2 timestamps in a log file and come up with the newest.

Here’s the little script I wrote:

  1. I needed to remove the blanks and non-numerical characters
  2. Then compare the numerical strings

Before proceeding make sure to convert your string in this order: year, month, day, hh24, mi, ss

#!/bin/sh

DATE1=”2008 September 12 11:30:45″

DATE2=”2008 September 12 12:45:32″

dateval1=`print ${DATE1} | sed ’s/[^0-9]//g’`

echo $dateval1

20080912113045

echo $dateval2

20080912124532

if [ $dateval1 -gt $dateval2 ]; then
echo $dateval1
else
echo $dateval2
fi

October 28, 2008

Rman Backup script on Windows

Filed under: Administration — nomadetech @ 3:52 pm
Tags: , ,

Hello,

Here’s a script I created recently to backup a database under Windows with RMAN.

Hope you enjoy it.

Pierre

The script takes 4 parameters:

  • Target Database Sid
  • Rman Database Sid
  • Rman Database Password
  • Level of Rman backup

SET ORACLE_HOME=E:\ORACLE\ORA10G
SET ORACLE_SID=%1%
SET RMAN_DB=%2%
SET CATALOG_PASS=%3%
SET LEVELBCK=%4%
SET CATALOG_PASS=rman/%CATALOG_PASS%@%RMAN_DB%
SET RMAN_DEST=K:\SAUVEGARDES\RMAN\%ORACLE_SID%
SET LOG_DEST=K:\SAUVEGARDES\LOGS
SET NLS_LANG=AMERICAN_AMERICA.UTF8
SET TMPDIR=E:\ORACLE\TEMPSCRIPTS

@echo on

cd %TMPDIR%

REM This bit generates the RMAN script to backup database,
REM archivelogs and control file and then crosscheck output.
echo run { > rman_%ORACLE_SID%.rcv
echo allocate channel d1 type disk; >> rman_%ORACLE_SID%.rcv
echo allocate channel d2 type disk; >> rman_%ORACLE_SID%.rcv
echo allocate channel d3 type disk; >> rman_%ORACLE_SID%.rcv
echo backup incremental level %LEVELBCK% format
‘%RMAN_DEST%\DBF_%ORACLE_SID%_t%%t_s%%s_p%%p.db’
database;>>rman_%ORACLE_SID%.rcv
echo sql ‘alter system archive log current’; >>rman_%ORACLE_SID%.rcv
echo backup archivelog all format
‘%RMAN_DEST%\ARC_%ORACLE_SID%_t%%t_s%%s_p%%p.arc’;>>rman_%ORACLE_SID%.rcv
echo backup current controlfile format
‘%RMAN_DEST%\CTL_%ORACLE_SID%_t%%t_s%%s_p%%p.ctl’;>>rman_%ORACLE_SID%.rcv
echo release channel d1; >> rman_%ORACLE_SID%.rcv
echo release channel d2; >> rman_%ORACLE_SID%.rcv
echo release channel d3; >> rman_%ORACLE_SID%.rcv
echo } >> rman_%ORACLE_SID%.rcv
echo allocate channel for maintenance type disk; >> rman_%ORACLE_SID%.rcv
echo sql ‘alter system archive log current’; >> rman_%ORACLE_SID%.rcv
echo crosscheck backup; >> rman_%ORACLE_SID%.rcv
echo crosscheck backup of archivelog all; >> rman_%ORACLE_SID%.rcv
echo crosscheck backup of controlfile; >> rman_%ORACLE_SID%.rcv
echo release channel; >> rman_%ORACLE_SID%.rcv
echo exit >> rman_%ORACLE_SID%.rcv

REM This starts RMAN, executes the script created earlier, then exits and
tidies up.
cd %RMAN_DEST%
if %LEVELBCK%==1 goto INCR
if %LEVELBCK%==0 goto FULL

:FULL
del %RMAN_DEST%\*.* /q
rman target / catalog=%CATALOG_PASS% cmdfile=%TMPDIR%\rman_%ORACLE_SID%.rcv
msglog=%LOG_DEST%\rman_%ORACLE_SID%.log
del %TMPDIR%\rman_%ORACLE_SID%.rcv
goto END
:INCR
rman target / catalog=%CATALOG_PASS% cmdfile=%TMPDIR%\rman_%ORACLE_SID%.rcv
msglog=%LOG_DEST%\rman_%ORACLE_SID%.log
del %TMPDIR%\rman_%ORACLE_SID%.rcv
:END

Next Page »

Blog at WordPress.com.