Saturday, June 14, 2008

Linux BASICS

Linux How-To

Although i have been working with Oracle Application all various Unix flavors my favorite one has been Linux. In today's post i will shift focus from Oracle Applications and discuss some tips for doing some frequently used tasks on the Operating System.

This post is my first in a series of posts which i intend to put up here on the operating system. Although most of you would be using these quite frequently I just though of putting them in one place.

Finding Your Linux Release
The first set you would require to do most of the times as an Applications DBA before you start installing or troubleshooting is to find out the version of Linux you are running.
This you can get from a static file redhat-release located in the /etc directory

view /etc/redhat-release
Red Hat Enterprise Linux AS release 4 (Nahant Update 2)

NFS mounting on Linux

Most often it is required to do a NFS mount of your disks across different servers. This particularly useful for doing Applications Installations and Patching. There are two aspects of configuration involved here. One is the sever that is the which is sharing the file system and the other is client which the host that is mounting the shared file system.

Supposing you want to mount a u01/sam on Node_A to Node_B

Configurations on Node_A
edit the /etc/exports file
vi /etc/exports
add the filesystem to mount
/u01/sam ro Node_B

you can either use the option ro which means read only or in case you wish to allow node_b to write into the filesystem use the rw option which is read writeable.

The change in exports file takes effect only after the restart of your NFS service daemon. use the service command to do that.

# service nfs restart
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]

Configuration for Node_B
On Node_B simply create the mount point to hold the shared file system and mount it using the mount command.

#mkdir sam
#mount -t nfs Node_A:/u01/sam /sam

Setting Kernel Parameters

Most oracle products require certain kernel parameters to be set as a pre requisite for installation. Common kernel parameters include parameters for shared memory .

The /etc/sysctl.conf file takes care of your kernel parameters.
#vi /etc/sysctl.conf
kernel.shmmax = 2147483648
kernel.shmmni = 128
kernel.shmall = 2097152
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000

However changes made to this file take effect only after the next reboot.

The sysctl command can be used to set the kernel parameter at runtime in linux.

sysctl -w kernel.shmmax=2147483648

You must however make the change in the /etc/sysctl.conf so that it is permanent.

Increasing the Swap space at runtime
Imagine this, you start the OUI and your pre installation check fails due to insufficient swap space. Now I agree that you got to check all this before starting the installation but just in case you missed it. You could always increase it on the fly.

Check the memory on your server
# free -m
total used free shared buffers cached
Mem: 8117 3204 4913 0 77 2648
-/+ buffers/cache: 478 7639
Swap: 101 0 101

Now say you need to increase it by 500 MB for your server, first locate a place you can spare this 500 MB in my case i found it in /u01

Use the dd command to create a swapfile
#cd /u01
# dd if=/dev/zero of=swapfile bs=1024 count=512000
512000+0 records in
512000+0 records out
# ls -ltr
drwx------ 2 root root 16384 May 1 2006 lost+found
-rw-r--r-- 1 root root 524288000 Nov 28 13:58 swapfile

Next issue the following two commands
# mkswap swapfile
Setting up swapspace version 1, size = 524283 kB
# swapon swapfile

Now check you memory again
# free -m
total used free shared buffers cached
Mem: 8117 2176 5941 0 45 1975
-/+ buffers/cache: 155 7962
Swap: 601 0 601

Bingo! here is your increased SWAP.

To make this change permanent add the line in your etc/fstab
/u01/swapfile swap swap defaults 0 0

No comments: