Oracle Database Experts

By Charles Kim

August 27th, 2010

View your alert.log file in Oracle Database 11g

function ALERT {
export DB1=$ORACLE_SID
export DB=$(echo $ORACLE_SID|tr '[A-Z]' '[a-z]' |sed -e '$s/.$//')
export ASMDB=rdbms
if [ "$DB" = "+asm" ]; then export ASMDB=asm ; fi
if [ "$DB" = "+as" ]; then export ASMDB=asm ; export DB="+asm"; fi
[ -d "$ORACLE_BASE/diag/$ASMDB/$DB/$ORACLE_SID/trace" ] && view $ORACLE_BASE/diag/$ASMDB/$DB/$ORACLE_SID/trace/alert_$ORACLE_SID.log ||view $ORACLE_BASE/diag/$ASMDB/$DB1/$ORACLE_SID/trace/alert_$ORACLE_SID.log
}

Notes:
* Works in both RAC and non-RAC.
* Works for ASM and non-ASM instances.
* The ALERT function will open the alert log associated with your current ORACLE_SID

** Requirements:
1. ORACLE_BASE must already be set
2. Add this script to your .profile or .bash_profile depending on the shell you are using

Posted by Charles Kim, Oracle ACE Director

August 27th, 2010

Change directory to the trace directory in Oracle Database 11g

function trace {
# DB = The sed command strips off the last character of ORACLE_SID off
export DB1=$ORACLE_SID
export DB=$(echo $ORACLE_SID|tr '[A-Z]' '[a-z]' |sed -e '$s/.$//')
export ASMDB=rdbms
if [ "$DB" = "+asm" ]; then export ASMDB=asm ; fi
if [ "$DB" = "+as" ]; then export ASMDB=asm ; fi
[ -d "$ORACLE_BASE/diag/$ASMDB/$DB/$ORACLE_SID/trace" ] && cd $ORACLE_BASE/diag/$ASMDB/$DB/$ORACLE_SID/trace || cd $ORACLE_BASE/diag/$ASMDB/$DB1/$ORACLE_SID/trace
}

Notes:
* Works in both RAC and non-RAC.
* Works for ASM and non-ASM instances.
* The trace function will take you to the directory where all the trace files are located including the alert log

** Requirements:
1. ORACLE_BASE must already be set
2. Add this script to your .profile or .bash_profile depending on the shell you are using

Posted by Charles Kim, Oracle ACE Director

December 19th, 2009

One Liner to View the Inventory XML file

Solaris:

cat /var/opt/oracle/oraInst.loc |grep inventory_loc |cut -d= -f2 |xargs -I {} -t cat {}/ContentsXML/inventory.xml

Linux and other Unix OS:

cat /etc/oraInst.loc |grep inventory_loc |cut -d= -f2 |xargs -I {} -t cat {}/ContentsXML/inventory.xml

Notes:
1. The -t option tells it to display out the syntax before execution
2. The -I is for Insert mode. utility is executed for each
line from standard input, taking the entire
line as a single argument, inserting it in
argument s for each occurrence of replstr.

Posted by Charles Kim, Oracle ACE Director

April 23rd, 2008

Oracle Database 11g Release 2 RPM requirements

Linux 64-bit Requirements for Red Hat 5 for Oracle Database 11g Release 2
(Also includes Asianux Server 3, Oracle Enterprise Linux 5,)

binutils-2.17.50.0.6
compat-libstdc++-33-3.2.3
compat-libstdc++-33-3.2.3 (32 bit)
elfutils-libelf-0.125
elfutils-libelf-devel-0.125
gcc-4.1.2
gcc-c++-4.1.2
glibc-2.5-24
glibc-2.5-24 (32 bit)
glibc-common-2.5
glibc-devel-2.5
glibc-devel-2.5 (32 bit)
glibc-headers-2.5
ksh-20060214
libaio-0.3.106
libaio-0.3.106 (32 bit)
libaio-devel-0.3.106
libaio-devel-0.3.106 (32 bit)
libgcc-4.1.2
libgcc-4.1.2 (32 bit)
libstdc++-4.1.2
libstdc++-4.1.2
libstdc++-devel
make-3.81
sysstat-7.0.2
unixODBC-2.2.11
unixODBC-2.2.11
unixODBC-devel-2.2.11
unixODBC-devel-2.2.11 (32 bit)

The following list of RPMs are required to successfully install Oracle Database 11g Release 1 on Red Hat:

binutils-2.15.92.0.2-18
compat-libstdc++-33.2.3-47.3
elfutils-libelf-0.97-5
elfutils-libelf-devel-0.97-5
glibc-2.3.9.4-2.19
glibc-common-2.3.9.4-2.19
glibc-devel-2.3.9.4-2.19
gcc-3.4.5-2
gcc-c++-3.4.5-2
libaio-devel-0.3.105-2
libaio-0.3.105-2
libgcc-3.4.5
libstdc++-3.4.5-2
libstdc++-devel-3.4.5-2
make-3.80-5
sysstat-5.0.5
unixODBC-2.2.11
unixODBC-devel-2.2.11
March 19th, 2008

Setup VNCServer to autostart after a server reboot

Modify /etc/sysconfig/vncservers

# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# as my ‘myusername’ (adjust this to your own). You will also
# need to set a VNC password; run ‘man vncpasswd’ to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted! For a secure way of using VNC, see
# <URL:http://www.uk.research.att.com/archive/vnc/sshvnc.html>.

# Use “-nolisten tcp” to prevent X connections to your VNC server via TCP.

# Use “-nohttpd” to prevent web-based VNC clients connecting.

# Use “-localhost” to prevent remote VNC clients connecting except when
# doing so through a secure tunnel. See the “-via” option in the
# `man vncviewer’ manual page.

VNCSERVERS=”1:oracle 2:root”
VNCSERVERARGS[1]=”-geometry 1024×768″

Once the changes are saved, Run “chkconfig vncserver on 345″ to enable autostartup. When the server reboots, two vncserver processes will start, one for root and the other for oracle.

March 10th, 2008

Create a new file system

[root@gc ~]# fdisk -l

Disk /dev/hda: 100.0 GB, 100030242816 bytes
255 heads, 63 sectors/track, 12161 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 2040 16386268+ 83 Linux
/dev/hda2 2041 6119 32764567+ 83 Linux
/dev/hda3 6120 6641 4192965 82 Linux swap
/dev/hda4 6642 12161 44339400 5 Extended
/dev/hda5 6642 7163 4192933+ 83 Linux
/dev/hda6 7164 7662 4008186 83 Linux
/dev/hda7 7663 8161 4008186 83 Linux
/dev/hda8 8162 8660 4008186 83 Linux
/dev/hda9 8661 9159 4008186 83 Linux
/dev/hda10 9160 9658 4008186 83 Linux
/dev/hda11 9659 10281 5004216 83 Linux

[root@gc ~]# mke2fs -j /dev/hda11
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
626496 inodes, 1251054 blocks
62552 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1283457024
39 block groups
32768 blocks per group, 32768 fragments per group
16064 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@gc ~]# mkdir /nfs1
[root@gc ~]# vi /etc/fstab

# This file is edited by fstab-sync – see ‘man fstab-sync’ for details
LABEL=/ / ext3 defaults 1 1
LABEL=/apps /apps ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
LABEL=/tmp /tmp ext3 defaults 1 2
LABEL=SWAP-hda3 swap swap defaults 0 0
rac1.dbaexpert.com:/backups/oracle /backups/oracle nfs rw,rsize=32768,wsize=32768,tcp,hard,nointr,nfsvers=3,bg,actimeo=0,timeo=600,suid,async
/dev/hdc /media/cdrecorder auto pamconsole,fscontext=system_u:object_r:removable_t,exec,noauto,managed 0 0
/dev/hda11 /nfs1 ext3 defaults 1 1

[root@gc ~]# mount /nfs1
[root@gc ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda1 16G 3.7G 11G 26% /
/dev/hda2 31G 26G 3.7G 88% /apps
none 1014M 566M 449M 56% /dev/shm
/dev/hda5 4.0G 41M 3.7G 2% /tmp
/dev/hda11 4.7G 42M 4.5G 1% /nfs1

[root@gc ~]# cd /nfs1
[root@gc nfs1]# mkdir oracle
[root@gc nfs1]# chown oracle:oinstall oracle
[root@gc nfs1]# ls -tlr
total 24
drwx—— 2 root root 16384 Mar 10 22:32 lost+found
drwxr-xr-x 2 oracle oinstall 4096 Mar 10 22:33 oracle




January 9th, 2008

Oracle Validated RPMs

If you are licensed to use Oracle Enterprise Linux and have setup up2date with OLN, you can use up2date with the “–install oracle-validated” option to automatically install all required packages by the Oracle database installer. The oracle-validated installation also creates the oracle OS user and an oinstall and dba groups.

up2date --install oracle-validated

Fetching Obsoletes list for channel: el4_i386_addons...

Fetching Obsoletes list for channel: el4_i386_oracle...

Fetching Obsoletes list for channel: el4_i386_latest...

Fetching rpm headers...
########################################

Name                                    Version        Rel
----------------------------------------------------------
oracle-validated                        1.0.0          3.el4             i386  

Testing package set / solving RPM inter-dependencies...
########################################
oracle-validated-1.0.0-3.el ########################## Done.
elfutils-libelf-devel-0.97. ########################## Done.
gcc-3.4.6-3.1.0.1.i386.rpm: ########################## Done.
gcc-c++-3.4.6-3.1.0.1.i386. ########################## Done.
glibc-devel-2.3.4-2.25.i386 ########################## Done.
glibc-headers-2.3.4-2.25.i3 ########################## Done.
glibc-kernheaders-2.4-9.1.9 ########################## Done.
libstdc++-devel-3.4.6-3.1.0 ########################## Done.
sysstat-5.0.5-11.rhel4.i386 ########################## Done.
Preparing              ########################################### [100%]

Installing...
   1:libstdc++-devel        ########################################### [100%]
   2:glibc-kernheaders      ########################################### [100%]
   3:glibc-headers          ########################################### [100%]
   4:glibc-devel            ########################################### [100%]
   5:gcc                    ########################################### [100%]
   6:gcc-c++                ########################################### [100%]
   7:sysstat                ########################################### [100%]
   8:elfutils-libelf-devel  ########################################### [100%]
   9:oracle-validated       ########################################### [100%]
.....
Posted by Charles Kim @ DBAExpert.com
December 1st, 2007

Required Kernel Parameters and RPM Requirements for Grid Control on Redhat 4

Kernel Parameters in /etc/sysctl.conf< /STRONG >

kernel.shmall = 3279547
kernel.shmmax = 2147483648
kernel.shmmni = 4096
#semaphores: semmsl, semmns, semopm, semmni
kernel.sem = 256 32000 100 142
fs.file-max = 327679
net.ipv4.ip_local_port_range = 1024 65000
kernel.msgmni = 2878
kernel.msgmax = 8192
kernel.msgmnb = 65535
net.core.rmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144

To reload the kernel:
sysctl -p

RPM Requirements

glibc-2.3.4-2.9
make-3.79
binutils-2.15.92.0.2-13
gcc-3.4.3-22.1
libaio-0.3.96
glibgc-common-2.3.4-2.9
setarch-1.6-1
pdksh-5.2.14-30
openmotif21-2.1.30-11
sysstat-5.0.5-1
gnome-libs-1.4.1.2.90-44.1
libstdc++-3.4.3-22.1
libstdc++devel-3.4.3-22.1
compat-libstdc++-296-2.96-
compat-db-4.1.25-9
control-center-2.8.0-12
xscreensaver-4.18-5.rhel4.2

Posted by Charles Kim @ DBAExpert.com

November 9th, 2007

Use uuencode from unix to attach files to mail recipients

The rpm that is required to install uucp in Redhat is sharutils:

root# rpm -ihv sharutils-4.2.1-22.2.x86_64.rpm
Preparing… ########################################### [100%]
1:sharutils ########################################### [100%]

Once you have uuencode installed and configured, you can attach file using the example code below:

uuencode rman_backup.ksh rman_backup.ksh |mailx -s “Attached rman backup shell script” oradba@dbaexpert.com

Posted by: Charles Kim @ DBAExpert.com

November 7th, 2007

Change hostnames in Linux

Check /etc/sysconfig/network
If you have a static IP address, then /etc/sysconfig/network is configured as follows:

NETWORKING=yes
HOSTNAME=”mybox.mydomain.com”

Posted by Charles Kim @ DBAExpert.com

October 24th, 2007

Remove files with find

In this example, we will remove all files that have not been modified in 30 days.
find . -mtime +30 -exec rm -f {} \;

If you have a ton of files in the directory, the find command used above will spit out errors. In this case, you may want to try the find command piped to xargs:

find . -mtime +30 |xargs rm -f

rhct-logo

Posted by: Charles Kim @ DBAExpert.com

October 22nd, 2007

Introduction to CVS

Relevant Aliases
cvsadd=’echo “Enter File to Add to CVS Repository”; read FILE; cvs add $FILE; cvs ci -m “Initial load of file into the
vs repository” $FILE’
cvsci=’echo “Enter File to Check-In to CVS Repository”; read FILE; cvs ci $FILE’
cvsprod=’. $SH/CVS.profile prod’

From the $SH directory – To Check Out a file from the CVS repository:
DBATOOLS > cvs co sh/vmstat.ksh
U sh/vmstat.ksh
ictcdb25:/u01/app/oracle/general/sh
DBATOOLS > cd sh
ictcdb25:/u01/app/oracle/general/sh/sh
DBATOOLS > l -tlr
total 4
4 -rwxr-xr-x 1 oracle oinstall 2748 Dec 22 08:26 vmstat.ksh
0 drwxr-sr-x 2 oracle oinstall 256 Dec 22 08:30 CVS

Check out certain versions:
cvs co -r 1.3 sh/rman_backup.ksh

Check In a file into the CVS repository
DBATOOLS > cvs add dgman.ksh
cvs add: scheduling file `dgman.ksh’ for addition
cvs add: use ‘cvs commit’ to add this file permanently
ictcdb25:/u01/app/oracle/general/sh
DBATOOLS > cvs ci -m “Initial load of dgman.ksh” dgman.ksh
RCS file: /u01/app/oracle/general/cvs/sh/dgman.ksh,v
done
Checking in dgman.ksh;
/u01/app/oracle/general/cvs/sh/dgman.ksh,v <– dgman.ksh
initial revision: 1.1
done

Help
cvs –help
cvs -H co

DBATOOLS > cvs -H add
Usage: cvs add [-k rcs-kflag] [-m message] files…
-k Use “rcs-kflag” to add the file with the specified kflag.
-m Use “message” for the creation log.
(Specify the –help global option for a list of other help options)

Current Status of a file
cvs status rman_backup.ksh

Revision history of a file
cvs rlog sh/rman_backup.ksh

Check Differences Between Versions
cvs diff -r 1.1 -r 1.2 srvping.ksh
Index: srvping.ksh
===================================================================
RCS file: /u01/app/oracle/general/cvs/sh/srvping.ksh,v
retrieving revision 1.1
retrieving revision 1.2
diff -r1.1 -r1.2
1a2
> # Created By: Basir Kabir

rhct-logo