Monday, 31 October 2011

Install Rar or Unrar on linux

However, I am a linux supporter and I don't want to make you upset while bumping into this blog and didn't really get what you need. So, here is how to install rar and unrar on other linux distributions...

Under Debian Linux, you can use the same apt-get method as follows to install unrar program:
$ apt-get install unrar

If you are using Fedora core Linux then use yum command as follows:
$ yum install unrar

If you are using FreeBSD, you can use:
$ pkg_add -v -r unrar

If any of above, methods is not working, you can download binary package from official rarlab site and choose the right package for your machine... for example, i chose the latest (by the time i write this post):
$ cd /tmp
$ wget

then untar the file:
$ tar -zxvf rarlinux-3.7.1.tar.gz

Both rar and unrar commands are located in rar sub-directory. Just go to rar directory:
$ cd rar
$ ./unrar

Now copy rar and unrar to /bin directory:
$ cp rar unrar /bin

Then you can use the same method on creating and extracting rar files in linux in my previous post.

Another thing to add, you can also test the integrity of archive, with this command:
$ unrar t filename.rar

To Extract from the rar file
$ unrar e brenttt.rar

or to list the files inside the rar file using this command:
$ unrar l filename.rar

that's it... hope it helps...J

Tuesday, 25 October 2011

Automatic Database Restart

To automate database startup and shutdown by using the dbstart and dbshut scripts:
  1. Log in as the root user.
  2. Edit the oratab file for the platform.
    To open the file, use one of the following commands:
    • On Solaris:
      # vi /var/opt/oracle/oratab
    • On AIX, HP-UX, and Linux:
      # vi /etc/oratab
    Database entries in the oratab file are displayed in the following format:
    In this example, the values Y and N specify whether you want the scripts to start or shut down the database, respectively. For each database for which you want to automate shutdown and startup, first determine the instance identifier (SID) for that database, which is identified by the SID in the first field. Then, change the last field for each to Y.
    You can set dbstart to autostart a single-instance database that uses an Automatic Storage Management installation that is auto-started by Oracle Clusterware. This is the default behavior for an Automatic Storage Management cluster. If you want to do this, then you must change the oratab entry of the database and the Automatic Storage Management installation to use a third field with the value W and N, respectively. These values specify thatdbstart auto-starts the database only after the Automatic Storage Management instance is started.
    If you add new database instances to the system and automate startup for them, then you must edit the entries for those instances in the oratab file.
  3. Change directory to one of the following depending on the operating system:
    PlatformInitialization File Directory
    Linux and Solaris/etc/init.d
  4. Create a file called dbora, and copy the following lines into this file:
    Change the value of the ORACLE_HOME environment variable to an Oracle home directory for the installation. Change the value of the ORACLE environment variable to the user name of the owner of the database installed in the Oracle home directory (typically, oracle).
    #! /bin/sh  -x
    # Change the value of ORACLE_HOME to specify the correct Oracle home
    # directory for your installation.
    # Change the value of ORACLE to the login name of the
    # oracle owner at your site.
    if [ ! "$2" = "ORA_DB" ] ; then
       if [ "$PLATFORM" = "HP-UX" ] ; then
          remsh $HOST -l $ORACLE -n "$0 $1 ORA_DB"
          rsh $HOST -l $ORACLE  $0 $1 ORA_DB
          if [ "$PLATFORM" = "Linux" ] ; then
              touch /var/lock/subsys/dbora
    case $1 in
            $ORACLE_HOME/bin/dbstart $ORACLE_HOME &
            $ORACLE_HOME/bin/dbshut $ORACLE_HOME &
            echo "usage: $0 {start|stop}"
    ####################### Or Use Below Script ##########################
    # chkconfig: 345 99 10
    # description: Oracle auto start-stop script.
    # Set ORA_HOME to be equivalent to the $ORACLE_HOME
    # from which you wish to execute dbstart and dbshut;
    # Set ORA_OWNER to the user id of the owner of the 
    # Oracle database in ORA_HOME.
    if [ ! -f $ORA_HOME/bin/dbstart ]
        echo "Oracle startup: cannot start"
    case "$1" in
            # Start the Oracle databases:
            # The following command assumes that the oracle login 
            # will not prompt the user for any values
            su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart $ORA_HOME"
            touch /var/lock/subsys/dbora
            # Stop the Oracle databases:
            # The following command assumes that the oracle login 
            # will not prompt the user for any values
            su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut $ORA_HOME"
            rm -f /var/lock/subsys/dbora
    This script can only stop Oracle Net listener for which a password has not been set. In addition, if the listener name is not the default name, LISTENER, then you must specify the listener name in the stop and start commands:
    $ORACLE_HOME/bin/lsnrctl {start|stop} listener_name
  5. Change the group of the dbora file to the OSDBA group (typically dba), and set the permissions to 750:
    # chgrp dba dbora
    # chmod 750 dbora
  6. Create symbolic links to the dbora script in the appropriate run-level script directories as follows.
    PlatformSymbolic Links Commands
    # ln -s /etc/dbora /etc/rc.d/rc2.d/S99dbora
    # ln -s /etc/dbora /etc/rc.d/rc0.d/K01dbora
    # ln -s /sbin/init.d/dbora /sbin/rc3.d/S990dbora
    # ln -s /sbin/init.d/dbora /sbin/rc0.d/K001dbora
    # ln -s /etc/init.d/dbora /etc/rc.d/rc0.d/K01dbora
    # ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S99dbora
    # ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S99dbora
    # ln -s /etc/init.d/dbora /etc/rc0.d/K01dbora
    # ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora

Wednesday, 12 October 2011

Configure Xclock in OEL 6

Configure Xclock in OEL 6
yum install xorg-x11-xauth
yum install xorg-x11-apps
[oracle@Oel6Wls11g ~]$ echo $DISPLAY
Install Xming on your windows
Set following in your Putty :
SSH à X11 à Check “Enable X11 forwarding” & X display location = localhost:0
Go to session back and save settings.
Make sure xming running before you run Xclock.

Tuesday, 11 October 2011

Changing Runlevels at Boot Time -- Oracle Linux / Red Hat Linux

Changing Runlevels at Boot Time
Under Red Hat Linux, it is possible to change the default runlevel at boot time.

If using LILO, access the boot: prompt by typing [Ctrl]-[X]. Then type:

linux <runlevel-number>

In this command, replace <runlevel-number> with either the number of the runlevel to boot into (1 through 5), or the words single or emergency.

If using GRUB, follow these steps:

In the graphical GRUB boot loader screen, select the Red Hat Linux boot label and press [e] to edit it.

Arrow down to the kernel line and press [e] to edit it.

At the prompt, type the number of the runlevel you wish to boot into (1 through 5), or the words single or emergency and press [Enter].

You will be returned to the GRUB screen with the kernel information. Press the [b] key to boot the system

BOOTING IN RUNLEVEL 3 ( With Grub ) == OEL Linux

There are occasions you want to boot in non-graphical mode ( in runlevel 3 ) for troubleshooting because the system fails to boot the usual way, X fails to start or some module it fails to load.

Here is how you do it when Grub is your boot loader:

At the grub boot menu press the E key. Next select the distro you want to boot and press the E key again. Now select the line with "kernel /boot/vmlinuz" and hit the E key one more time. Now type a space and the number 3 at the end of that line, so for example from:

kernel /boot/vmlinuz-2.6.17 ro root=/dev/hda6


kernel /boot/vmlinuz-2.6.17 ro root=/dev/hda6 3

Finally press the B key and your distro will boot in runlevel 3

NOTE: Runlevel 3 does not work in Ubuntu . . . . use the "rescue mode" you see in the Ubuntu boot menu.

NOTE 2: In recent Mandriva versions Grub has a graphical menu where you can press F2 to edit boot options . . . simply add the number 3 and press the Enter key to boot in runlevel 3.

Create Linux Partition -- Add New HDD to Linux

[root@Grid-DB ~]# fdisk -l

Disk /dev/xvda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start    End   Blocks   Id System
/dev/xvda1   *       1     16   128488+  83 Linux
/dev/xvda2          17     408  3148740  82 Linux swap / Solaris
/dev/xvda3         409    1044  5108670  83 Linux

Disk /dev/xvdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/xvdb doesn't contain a valid partition table
7. Create a primary partition on the device identified above.

[root@Grid-DB ~]# fdisk /dev/xvdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
Partition number (1-4): 1
First cylinder (1-1044, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044):
Using default value 1044

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
8. Add a filesystem to the new partition.

[root@Grid-DB ~]# mkfs -t ext3 /dev/xvdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1048576 inodes, 2096474 blocks
104823 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2147483648
64 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

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

This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@Grid-DB ~]#
Then add the necessary commands to the /etc/fstab file before issuing the mount command to mount the new device as shown below. 
[root@Grid-DB ~]# vi /etc/fstab

LABEL=/                 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-xvda2        swap                    swap    defaults        0 0
/dev/xvdb1              /u01                    ext3    defaults        1 1

[root@Grid-DB ~]# mkdir /u01
[root@Grid-DB ~]# mount /u01
[root@Grid-DB ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda3            4.8G  2.5G  2.1G  55% /
/dev/xvda1            122M   13M  104M  11% /boot
tmpfs                 1.1G     0  1.1G   0% /dev/shm
/dev/xvdb1            7.9G  147M  7.4G   2% /u01

Tuesday, 4 October 2011

How to detect what is the Oracle memory hunger process

How to detect what is the Oracle memory hunger process? Previously I did share a script on how to check the top 10 memory consumption process in Unix.
It is recommended to check the growth memory usage of your Oracle Application Server from time to time.
Top Memory Usage Checking
$ UNIX95= ps -eo vsz,ruser,pid,args | sort -rn | head -10
  85796 applprod 21020 f60webmx webfile=5,1425,apps_oracle
  80228 applprod  5803 f60webmx webfile=5,2443,apps_oracle
  68388 applprod 27304 f60webmx webfile=5,1619,apps_oracle
  65828 applprod 15211 f60webmx webfile=5,1741,apps_oracle
  65444 applprod 11075 f60webmx webfile=5,264,apps_oracle
  64676 applprod 20696 f60webmx webfile=5,2163,apps_oracle
  62948 applprod   885 f60webmx webfile=5,2303,apps_oracle
  56996 applprod 24789 f60webmx webfile=5,2458,apps_oracle
  54884 applprod 18172 f60webmx webfile=5,2405,apps_oracle
  54756 applprod 18077 f60webmx webfile=5,61,apps_oracle
From the output above, it seems that the Oracle form process f60webmx utilize a high amount of server memory.
Quite abnormal because the f60webmx form process should be terminated after certain time of inactivity.
Use the script as below to check on the status of f60webmx session by using the Unix PID.
Oracle Forms Session Checking
s.TYPE "Type",
s.username "DB_User",
s.osuser "Client_User",
s.server "Server",
s.machine "Machine",
s.module "Module",
s.logon_time "Connect Time",
s.process "Process",
SYSDATE - (s.last_call_et / 86400) "Last_Call"
FROM v$session s,
v$process p
WHERE s.paddr = p.addr(+)
AND s.process = <replace WITH Unix PID>;

How To Check Top Memory Usage In Unix

How To Check Top Memory Usage In Unix
Top or glance command can be use to monitor the overall CPU and memory usage per process. But is hard to monitor because some top command did not support sorting based on the CPU or memory consumption.
Thus, you need to use one single line of Unix command as below to detect the top 20 memory consumption process.
Memory Leak Check With Unix Command
$ UNIX95= ps -eo vsz,ruser,pid,args | sort -rn | head -20
272444 oracle  8930 /opt/java1.4/bin/PA_RISC2.0/java -mx1024m
267156 oracle  8936 INVLIBR FND Concurrent_Processor MANAGE
217468 oracle 10767 FNDLIBR FND Concurrent_Processor MANAGE
216316 oracle 10774 FNDLIBR FND Concurrent_Processor MANAGE
216188 oracle 10775 FNDLIBR FND Concurrent_Processor MANAGE
215932 oracle 10776 FNDLIBR FND Concurrent_Processor MANAGE
215932 oracle 10758 FNDLIBR FND Concurrent_Processor MANAGE
215548 oracle 10763 FNDLIBR FND Concurrent_Processor MANAGE
214524 oracle 10764 FNDLIBR FND Concurrent_Processor MANAGE
214140 oracle 10777 FNDLIBR FND Concurrent_Processor MANAGE
212732 oracle 10755 FNDLIBR FND Concurrent_Processor MANAGE
212604 oracle 10778 FNDLIBR FND Concurrent_Processor MANAGE
212348 oracle 10766 FNDLIBR FND Concurrent_Processor MANAGE
212092 oracle 10765 FNDLIBR FND Concurrent_Processor MANAGE
211964 oracle 10756 FNDLIBR FND Concurrent_Processor MANAGE
211708 oracle 10773 FNDLIBR FND Concurrent_Processor MANAGE
211068 oracle 10762 FNDLIBR FND Concurrent_Processor MANAGE
210684 oracle 10754 FNDLIBR FND Concurrent_Processor MANAGE
210044 oracle 10760 FNDLIBR FND Concurrent_Processor MANAGE
209532 oracle 10779 FNDLIBR FND Concurrent_Processor MANAGE
The 3rd column is the Unix process ID which you can use as a reference before killing it.
The 1st column shows the amount of memory used by each process for data/text and stack.
This value is in pages and you need to multiply by 4096 to determine the size in byte.
After you convert the size into byte, divide it by 1024 to get value in Kb and 1024 again to get value in Mb.
It’s recommended to monitor the memory from time to time. If memory per process grow tremendously then there might be possibility of memory leak.

Yum update or Install packages from DVD

When You installed Linux (sample: Oracle Linux) from DVD and You need to use "yum" command-line to install(update) some packages from DVD. How?
- Check "createrepo" pacakge. 
[root@linuxtest ~]# rpm -qa |grep createrepo
- Mount DVD, Create repomd (xml-rpm-metadata) repository and Clean repo 
[root@linuxtest ~]# mount /dev/cdrom /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only

[root@linuxtest ~]# 
cd /mnt
[root@linuxtest mnt]# createrepo .

[root@linuxtest mnt]# 
yum clean all
Cleaning repos: local
Cleaning up Everything
- Create config file 
[root@linuxtest mnt]# vi /etc/yum.repos.d/iso.repo
name=Local CD Repo 

- Test 
[root@linuxtest mnt]# yum install gcc
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc.i686 0:4.4.5-6.el6 will be installed
--> Processing Dependency: cpp = 4.4.5-6.el6 for package: gcc-4.4.5-6.el6.i686
--> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.5-6.el6.i686
--> Running transaction check
---> Package cloog-ppl.i686 0:0.15.7-1.2.el6 will be installed
--> Processing Dependency: for package: cloog-ppl-0.15.7-1.2.el6.i686
--> Processing Dependency: for package: cloog-ppl-0.15.7-1.2.el6.i686
---> Package cpp.i686 0:4.4.5-6.el6 will be installed
--> Processing Dependency: for package: cpp-4.4.5-6.el6.i686
--> Running transaction check
---> Package mpfr.i686 0:2.4.1-6.el6 will be installed
---> Package ppl.i686 0:0.10.2-11.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

Package Arch Version Repository Size
gcc i686 4.4.5-6.el6 local 8.1 M
Installing for dependencies:
cloog-ppl i686 0.15.7-1.2.el6 local 93 k
cpp i686 4.4.5-6.el6 local 3.3 M
mpfr i686 2.4.1-6.el6 local 153 k
ppl i686 0.10.2-11.el6 local 1.3 M
Transaction Summary
Install 5 Package(s)

Total download size: 13 M
Installed size: 29 M
Is this ok [y/N]: y
Downloading Packages:
Total 26 MB/s | 13 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : ppl-0.10.2-11.el6.i686 1/5
Installing : cloog-ppl-0.15.7-1.2.el6.i686 2/5
Installing : mpfr-2.4.1-6.el6.i686 3/5
Installing : cpp-4.4.5-6.el6.i686 4/5
Installing : gcc-4.4.5-6.el6.i686 5/5

gcc.i686 0:4.4.5-6.el6

Dependency Installed:
cloog-ppl.i686 0:0.15.7-1.2.el6 cpp.i686 0:4.4.5-6.el6 mpfr.i686 0:2.4.1-6.el6 ppl.i686 0:0.10.2-11.el6