Monday, November 21, 2011

Recovering if Control file gets corrupted / missing

If any of control file is missing or get corrupted oracle database won't startup. There are two ways to recover from this error.


  1. select name from v$controlfile
    This will show all control files with the paths. shutdown database (shutdown immediate) and copy the available control file to the path from where it is lost or corrupted with the same name as above query is showing. After replacing control file, start your database.
  2. If RMAN is configured and at least once backup of control file is taken from RMAN. If yes then connect to RMAN as following
    # rman connect target /
    Now once connected with RMAN issue any of below mentioned command.
    RMAN>restore controlfile from 'PATH and NAME of available Controlfile';

    RMAN>restore controlfile from autobackup;
    That's it. Just restart your database and monitor alert log file.

    Cheers!

Sunday, October 16, 2011

How to resize/recreate /tmp parition in linux

Today I am going to explain about how to resize/recreate /temp partition in Linux. Why you need it? Many software like MySQL writes temporary files in /tmp partition and if /tmp is of less space then sometimes software are unable to function properly. Following are the steps I use to fix this problem:

  1. umount -l /tmp
  2. dd if=/dev/zero of=/usr/tmpDSK bs=1024 count=512000
  3. mkfs.ext3 /usr/tmpDSK
Then mount this to /tmp
  1.     mount -o loop,rw,noexec,nosuid /usr/tmpDSK /tmp
Now new /tmp partition is created by you may have to give proper permission to your applications to this new /tmp directory. In my case I had to give permission to MySQL and achieved using following commands;
  1. usermod -G mysql /tmp
  2. chmod 0770 -R /tmp
 That's it and you are done with it.

Thursday, May 12, 2011

Shell script that FTP multiple files whose creation time is last 60 minutes

Sometimes you need to write a shell script which can FTP files(specific types) whose creation time is for example in last one hour. I've written following shell script which does the same. I hope it will help you.


#!/bin/bash
cd /opt/archive/
movedFile=`find . '*.csv' -cmin -60 `
HOST=192.168.0.15
USER='user'
PASSWD='xxxx'
for i in $movedFile; do
        echo "Uploading file $i ...."
        /usr/bin/ftp -n $HOST <         quote USER $USER
        quote PASS $PASSWD
        binary
        cd Records
       put $i
       quit
END_SCRIPT
mv $i /root/backup/
done