Wednesday, December 26, 2012

every 5 minutes how to copy files after certain date time (linux)


here the script  to copy  archive logs ,created after certain date time, into different location every 5 minutes for our production database; simply , writing the last time of archive log created by oracle on os into a log file and then read the time from this log file to find out which archive logs should be copied next time.create a sh file and copy paste this script into file and then add it into crontab ,if u have any question feel free to ask...


REF=.tmp.$$
export date_name=`cat last_time`
touch -t $(date +%m%d)$date_name $REF
ls -lra | tail -1 | awk '{print $8}' | sed 's/\://g' > last_time
find . -newer $REF -exec cp {} /opt/oracle / \;
rm -f $REF



before run this script create a file called last_time in archive logs destination folder and write the time after files u wanna copy.for example write 1900  in last_time file to copy files after 19:00..


adding crontab to execute sh every 5 mins;

crontab -e then add this line ;

*/5 * * * * /opt/name_of_file.sh

Monday, December 24, 2012

PRVF-5637 and PRVF-9802 installing oracle database on oracle linux or redhat 6.x

Solution for PRVF-5637
if u have more than one  node then perform these steps for each nodes;

# mv /usr/bin/nslookup /usr/bin/nslookup.orig
# echo '#!/bin/bash
/usr/bin/nslookup.orig $*
exit 0' > /usr/bin/nslookup
# chmod a+x nslookup

its well-known bug for OEL6 or RHEL6 while installing oracle 11.2.0.3.

 grid installer returning exit code of 1 which means as a problem;



* Mon May 07 2012 Adam Tkac <atkac redhat com> 32:9.8.2-0.9.rc1
- fix race condition in the resolver module
- nslookup: return non-zero exit code when fail to get answer (#816164)

simply returning nlslookup behaviors like OEL 5.8 will solve your problem.

  Good luck.

Solution for PRVF-9802

u need to download oracleasmlib from the below link and install it

oracleasmlib.rpm

after installing rpm u can see the disks with "/usr/sbin/oracleasm-discover"


[root@rac1 opt]# rpm -ivh oracleasmlib-2.0.4-1.el5.x86_64.rpm
warning: oracleasmlib-2.0.4-1.el5.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 1e5e0159: NOKEY
Preparing...                ########################################### [100%]
   1:oracleasmlib           ########################################### [100%]
[root@rac1 opt]#  /usr/sbin/oracleasm-discover
Using ASMLib from /opt/oracle/extapi/64/asm/orcl/1/libasm.so
[ASM Library - Generic Linux, version 2.0.4 (KABI_V2)]
Discovered disk: ORCL:DISK1 [3078144 blocks (1576009728 bytes), maxio 512]

Also check permissions for disks, they must belong to grid user..


[root@rac1 opt]# cd /dev/oracleasm/disks/
[root@rac1 disks]# ll
total 0
brw-rw---- 1 grid oinstall 8, 1 May 15 14:57 DISK1


- Erol









Sunday, December 16, 2012

ORA-07445: exception encountered: core dump [ptmak()+191] [SIGSEGV]

Usually this problem is related with debug scructures.Today one of our developers was complaining with ora-031114: Not Connected to Oracle and when i checked the alert log i saw ORA-07445: exception encountered: core dump [ptmak()+191] [SIGSEGV] in alert log and this problem can occur if last time debug mode was on and compiled package before upgrading to database and retry to compile the same package after upgrading.What you should do is to check if package has debug flag or not.if it has debug flag then just disable it.Good luck.

Thursday, December 6, 2012

Installation Oracle OS Watcher and User's Guide



if your java version below 1.4.2 then you need to download latest java version and install it.

download latest java from the below link;

latest java

installation java on redhat

Step 1: installing rpm;

[oracle@isupdbsh opt]$  rpm -ivh jdk-7u9-linux-x64.rpm


Step 2: installation and configuration java

[oracle@isupdbsh /]$ alternatives  --install     /usr/bin/java   java /usr/java/jdk1.7.0_09/jre/bin/java 1


[oracle@isupdbsh /]$ alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*  1           /usr/lib/jvm/jre-1.4.2-gcj/bin/java
 + 2           /usr/java/jdk1.7.0_09/jre/bin/java

Enter to keep the current selection[+], or type selection number: 2

select the new location installed java and check java version;

Step 3: Checking java version;

[oracle@isupdbsh /]$ java -version
java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)


Tuesday, December 4, 2012

how to get column names,DATA_TYPE,DATA_LENGTH of any table....


select a.table_name,U.OWNER, column_name,DATA_TYPE,DATA_LENGTH from user_tab_columns a,ALL_CATALOG u
where a.TABLE_NAME=u.TABLE_NAME
AND u.table_name='table_name'
and column_name like upper('%column_name%')
and u.owner='owner'
order by DATA_LENGTH desc;

Friday, November 23, 2012

ORA-15018, ORA-15072 on node 2 when running root.sh

U have to give the path of asm disks manually when installing 11g grid Infrastructure

click Disk discovery path and then write

/dev/oracleasm/disks

automatically asm disks will be showned on list.And dont forget to check owner of disks they should belong to oracle:oinstall..

then edit /etc/sysconfig/oracleasm and add dm,sd parameters otherwise u can have a trouble with disks after restarting server.(if  you are using multipath.)

ORACLEASM_SCANORDER="dm"
ORACLEASM_SCANEXCLUDE="sd"

last thing, dont forget to restart  oracleasm

/etc/init.d/oracleasm restart.

after these steps are done simply run rootcrs.pl -verbose -deconfig -force on first node , if u have more than two nodes then u have to add -verbose. good luck.

applying patch 9413827 before upgrading crs to 11.2.0.3.0


patch id 9413827
with root
/u01/app/11.2.0/grid/crs/install/rootcrs.pl -unlock
su - oracle
9413827/custom/scripts/prepatch.sh -dbhome $ORACLE_HOME
First applying patch for grid;
/u01/app/11.2.0/grid/OPatch/opatch napply -local -oh $CRS_HOME -id 9413827
then for database;
/u01/app/oracle/product/11.2.0/db_1/OPatch/opatch napply custom/server/ -local -oh $ORACLE_HOME -id 9413827

again with root
chmod +w /u01/app/11.2.0/grid/log/rac1/agent/
chmod +w /u01/app/11.2.0/grid/log/rac1/agent/crsd/

su - oracle

custom/server/9413827/custom/scripts/postpatch.sh -dbhome $ORACLE_HOME


su - root

/u01/app/11.2.0/grid/crs/install/rootcrs.pl -patch

same steps for node 2 too..

Tuesday, October 2, 2012

problem with du and df commands disagree (OCFS2 1.4.1 BUG)


Today our production database stopped working because of ocfs2 1.4.1 bug..du -sch and df -h was showing different size on location where archive logs are..so after searching on google, i realize we hit a bug with ocfs2 1.4.1. Here is the solution of fixing this problem;

 first of all u need to umount ocfs2 partition using below command line;


 
umount /oradata1 (location where partition as ocfs2 is mounted)

then u need to run ;

/sbin/fsck.ocfs2 -fy /dev/sda1
it could take a while to finish; u can break the operation while fixing..wont effect any datafiles or system files on this partition...in case of losing any datafiles, better taking a fresh backup before running fsck.ocfs2.

Friday, September 21, 2012

ASMCMD-08102: no connection to ASM

[oracle@localhost ~]$ export ORACLE_HOME=/u01/app/oracle/grid
[oracle@localhost ~]$ export PATH=/u01/app/oracle/grid/bin
[oracle@localhost ~]$ export ORACLE_SID=+ASM
[oracle@localhost ~]$ asmcmd

Thursday, September 13, 2012

ORA-04021: timeout occurred while waiting to lock object

U have to kill all sessions using object which u wanna compile, u can use this below script to find out which sessions are using any object..

select 'kill -9 '||b.spid||' # username '||c.username||'' from gv$access a, gv$process b, gv$session c where a.object=upper('object_name') and a.sid=c.sid and b.addr=c.paddr


run the output on linux to kill all sessions then compile object