Tuesday, November 16, 2010

Process states in linux systems

There are many states for processes in linux environment. You can see the process states using the following commands.

#ps
#ps -ax       -From all users and terminals.
#ps -aux     -Shows Process owner also.

For the dynamic details:

#top
#top -c      -Sorts according to CPU usage.
#top   and pressing M(shift+m)  - sorts according to memory usage.

Main process states are as follows:


             D       Marks a process in disk (or other short term, uninterruptible) wait.
             I       Marks a process that is idle (sleeping for longer than about 20 seconds).
             R       Marks a runnable process.
             S       Marks a process that is sleeping for less than about 20 seconds.

             T       Marks a stopped process.
             Z       Marks a dead process (a ``zombie'').

Additional characters after these, indicates additional state information:

             +       The process is in the foreground process group of its control terminal.
             <       The process has raised CPU scheduling priority.
             >       The process has specified a soft limit on memory requirements and is currently exceeding that limit; such a process is (necessarily) not swapped.
             E       The process is trying to exit.
             L       The process has pages locked in core (for example, for raw I/O).
             N       The process has reduced CPU scheduling priority (see setpriority(2)).
             s       The process is a session leader.
             V       The process is suspended during a vfork(2).
             W       The process is swapped out.
             X       The process is being traced or debugged.

How to install and configure oracle 10g standalone database server in redhat rhel5 linux

Oracle 10g installation on RHEL5 ( Standalone Server)

This document explains how to install and configure the Oracle 10g database server on a redhat rhel5 linux machine. This steps will work in other redhat distros like Centos, Fedora etc.

System:
VMware VM
OS Redhat enterprise Linux 5.4
32 bit
IP: 192.168.0.56
RAM = 1700Mb
Host machine Dell inspiron 1545

Oracle software:
Oracle 10g
Version 10.2.0.1.0

Other Requirements:
Yum server

Pre - Installation steps:

Setting the hostname:
[root@oracle ~]# hostname
oracle.lap.work

Resolving the hostname:
[root@oracle ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1oracle.lap.work oracle localhost.localdomain localhost
::1localhost6.localdomain6 localhost6
192.168.0.35 oracle.lap.work oracle

Making the hostname permenant:
[root@oracle ~]# cat s/etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=oracle.lap.work

Changing the OS Name:
Oracle 10g does not support the rhel 5.4. So we've tochange it to rhel4

[root@oracle ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 4 (Tikanga)

Installation:
Installing dependancies:

[root@oracle ~]# yum install compat-db compat-gcc* compat-libstdc++* openmotif* sysstat telnet-server libaio* gcc*

Now creating groups and users for oracle installation:
[root@oracle ~]# [root@oracle ~]# groupadd -g 200 oinstall
[root@oracle ~]# groupadd -g 200 oinstall1 dba
[root@oracle ~]# useradd -g oinstall -G dba oracle-u 200
[root@oracle ~]# passwd oracle
Changing password for user oracle.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.

Creating home directories for oracle:
Crs home:
[root@oracle ~]# mkdir -p /u01/app/oracle/product/10.2.0/crs
Oracle home:
[root@oracle ~]# mkdir -p /u01/app/oracle/product/10.2.0/db_1

Setting Kernel & other parameters for Oracle installation in /etc/sysctl.conf file
[root@oracle ~]# cat >> /etc/sysctl.conf
#Oracle installation parameters
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 4294967295
kernel.shmall = 268435456
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_fin_timeout = 5
net.ipv4.tcp_keepalive_intvl = 5
net.ipv4.tcp_keepalive_time = 3
net.ipv4.tcp_keepalive_probes = 9
net.ipv4.tcp_orphan_retries = 2
kernel.sem = 250 32000 100 128
net.core.rmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 262144^[[A 4
kernel.domainname = lap.work #change the domain name as you wish
[root@oracle ~]#

Reloading the sysctl.conf to make effect the above parameters:
[root@oracle ~]# sysctl -p

You can check the errors using
[root@oracle ~]# sysctl -p > /dev/null

Settings for limiting the resource usage of oracle user:
[root@oracle ~]# cat >> /etc/security/limits.conf << EOF
> oracle soft nproc 4096
> oracle hard nproc 16384
> oracle soft nofile 2048
> oracle hard nofile 65536
> EOF

[root@oracle ~]# cat >> /etc/pam.d/login << EOF
> session required /lib/security/pam_limits.so
> EOF

[root@oracle ~]# [root@oracle ~]# cat >> /etc/pam.d/su << EOF
> session required /lib/security/pam_limits.so
> EOF

[root@oracle ~]# cat >> /etc/pam.d/sshd << EOF
> session required /lib/security/pam_limits.so
> EOF

Adding the variables and functions needed for oracle installation into /etc/profile file:

[root@oracle ~]# cat >> /etc/profile
#oracle installation variavl bles and functions
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
CRS_HOME=$ORACLE_BASE/product/10.2.0/crs
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
if [ $USER = .oracle. ]; then
ulimit .u 16384 .n 65536
fi

Sourcing it to make effect:
[root@oracle ~]# source /etc/profile

Adding the variables and functions needed for oracle installation into user oracle's profile file:

cat >> ~oracle/.bash_profile
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
CRS_HOME=$ORACLE_BASE/product/10.2.0/crs
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
PATH=/usr/sbin:$PATH; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH


Sourcing it to make effect. Or you can logout and log in.

[oracle@oracle ~]$ sourse .bash_profile

Hang Checker Timer:

[root@oracle ~]# cat >> /etc/modprobe.conf
options hangcheck-timer hangcheck_tick=30 hangcheck_margin=180

Starting the hangcheck driver using the following command

[root@oracle ~]# modprobe hangcheck-timer

Now mount the cd to /media and copy the oracle database directory to /u01/app/oracle:

Now we have :
[root@oracle ~]# cd /u01/app/oracle/
[root@oracle oracle]# ls
database product

Changing the ownership and permissions of oracle files and directories:

[root@oracle oracle]# chown -R oracle:dba /u01/app/oracle/
[root@oracle oracle]# chmod -R 775 /u01/app/oracle/

Now we can start the installation:

You have to do this in runlevel 5, ie graphical mode:
You have to run the command xhost + as root user. As shown below.



Then only you will get access to oracle's graphical installation tool.

Starting the installation:

First we have to switch as user oracle and goto the directory /u01/app/oracle/database.
There you can see a script runInstaller. Execute it. See the pic below.


And you will get the following window.


Set the database password in that. And click next.
Note: It will be the password for the users SYS,SYSTEM,SYSMAN and DBSNMP

Now you will get the next window as follows:


Check the oracle group name is oinstall and click next.

Here you will get the prerequisite check results. There may be some errors. We are lacking enough swap memory here. And network script is not executed. [Its because we have static ip not dhcp]


Creating swap memory:

Sometimes there wont be enough swap memory in your system. So you have to create swap area either by partition or file.

Here we create swap using file.

[root@oracle oracle]# touch /swapfile

Using dd command and dumping zeros to the file:

[root@oracle oracle]# dd if=/dev/zero of=/swapfile bs=1024 count=500000
500000+0 records in
500000+0 records out
512000000 bytes (512 MB) copied, 71.4932 seconds, 7.2 MB/s

Making swap filesystem:

[root@oracle oracle]# mswkswap -v1 /swapfile
Setting up swapspace version 1, size = 511995 kB

Creating entry in fstab:

[root@oracle oracle]# cat /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-sda3 swap swap defaults 0 0
/swapfile swap swap defaults 0 0

Mounting and enabling it:

[root@oracle oracle]# mount -a
[root@oracle oracle]# swapon -a

Checking the swap status:

[root@oracle oracle]# swapon -s
FilenameTypeSizeUsedPriority
/dev/sda3 partition23535120-1
/swapfile file4999920-2

Now rechecking and continuing installation:



Now Pre-checks are over:


If there was errors, it'll be listed in red color so check for errors.

Now Click on install.


It may take some time.

Some configuration scripts will run during installation:




At the end of installation we have to run two scripts manually as root user:


1st script:

[root@oracle db_1]# ./root.sh

Running Oracle10 root.sh script...

The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/10.2.0/db_1

Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...

Creating /etc/oratab file...

Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
[root@oracle db_1]# cd ../../../oraior

2nd script:

[root@oracle oraInventory]# ./orainstRoot.sh
Changing permissions of /u01/app/oracle/oraInventory to 770.
Changing groupname of /u01/app/oracle/oraInventory to oinstall.
The execution of the script is complete
[root@oracle oraInventory]#


For using the EM you have to run this command as user oracle:
Switching user as oracle:
[root@oracle oraInventory]# su - oracle

Running the command:
[oracle@oracle ~]$ emctl start dbconsole
TZ set to Asia/Calcutta
Oracle Enterprise Manager 10g Database Control Release 10.2.0.1.0
Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved.
http://oracle.lap.work:1158/em/console/aboutApplication
  • An instance of Oracle Enterprise Manager 10g Database Control is already running.
Now installation is over:

Now login using web access:
http://192.168.0.35/em



user :sys
password: same you've given during oracle installation

Accepting the license:


Thats it



Using the command prompt:

Login as user oracle:
[oracle@oracle ~]$ sqlplus / as stysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Nov 16 12:48:40 2010

Copyright (c) 1982, 2005, Oracle. All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> select * from all_users;

USERNAME USER_ID CREATED
------------------------------ ---------- ---------
BI 60 16-NOV-10
PM 59 16-NOV-10
SH 58 16-NOV-10
IX 57 16-NOV-10
OE 56 16-NOV-10
HR 55 16-NOV-10
SCOTT 54 30-JUN-05
****** Output truncated *********


SQL> shutdown
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Thats it. Leave a comment if you like. Enjoy.