Thursday, 10 July 2014

How To Clear Memory Cache In Linux

Clearning the Linux Memory cache can be a quick way to regain system resources. Writing to the drop_cache process will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free.


 To free pagecache:                                      # echo 1 > /proc/sys/vm/drop_caches

    To free dentries and inodes:                      # echo 2 > /proc/sys/vm/drop_caches

    To free pagecache, dentries and inodes :  # echo 3 > /proc/sys/vm/drop_caches

As this is a non-destructive operation, and dirty objects are not freeable, the user should run "sync" first in order to make sure all cached objects are freed.

Example - Memory before:


[root@server ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          3259       2288        970          0        120        828
-/+ buffers/cache:       1340       1919
Swap:         6206          0       6206
[root@server ~]# sync
[root@server ~]# echo 3 > /proc/sys/vm/drop_caches

Example - Memory before:
[root@server ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          3259       1563       1696          0          2        281
-/+ buffers/cache:       1279       1980
Swap:         6206          0       6206



Enjoy the tricksss............. Have fun !!!!!!!!!!!!!!!!!!!!







Boot Process in Linux

1. BIOS

BIOS stands for Basic Input/Output System

Performs some system integrity checks

Searches, loads, and executes the boot loader program.

It looks for boot loader in floppy, cd-rom, or hard drive. You can press a key (typically F12 of F2, but it depends on your system) during the BIOS startup to change the boot sequence.

Once the boot loader program is detected and loaded into the memory, BIOS gives the control to it.
So, in simple terms BIOS loads and executes the MBR boot loader.

2. MBR

MBR stands for Master Boot Record.

It is located in the 1st sector of the bootable disk. Typically /dev/hda, or /dev/sda

MBR is less than 512 bytes in size. This has three components

1) primary boot loader info in 1st 446 bytes
2) partition table info in next 64 bytes
3) mbr validation check in last 2 bytes.

It contains information about GRUB (or LILO in old systems).

So, in simple terms MBR loads and executes the GRUB boot loader.

3. GRUB

GRUB stands for Grand Unified Bootloader.

If you have multiple kernel images installed on your system, you can choose which one to be executed.

GRUB displays a splash screen, waits for few seconds, if you don’t enter anything, it loads the default kernel image as specified in the grub configuration file.

GRUB has the knowledge of the filesystem (the older Linux loader LILO didn’t understand filesystem).
Grub configuration file is /boot/grub/grub.conf (/etc/grub.conf is a link to this). The following is sample grub.conf of MostlyLinux or Redhat or Cent OS

[root@server ~]# cat /etc/grub.conf
# grub.conf generated by anaconda 
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd0,5)
#          kernel /boot/vmlinuz-version ro root=/dev/sda6
#          initrd /boot/initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,5)/boot/grub/splash.xpm.gz
hiddenmenu
title MostlyLinux (2.6.32-431.3.1.el6.x86_64)
root (hd0,5)
kernel /boot/vmlinuz-2.6.32-431.3.1.el6.x86_64 ro root=UUID=09cc97c6-5791-4224-8737-fe24f60affc8 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /boot/initramfs-2.6.32-431.3.1.el6.x86_64.img
[root@server ~]# 


As you notice from the above info, it contains kernel and initrd image.
So, in simple terms GRUB just loads and executes Kernel and initrd images.

4. Kernel

Mounts the root file system as specified in the “root=” in grub.conf

Kernel executes the /sbin/init program

Since init was the 1st program to be executed by Linux Kernel, it has the process id (PID) of 
1. Do a ‘ps -ef | grep init’ and check the pid.

initrd stands for Initial RAM Disk.

initrd is used by kernel as temporary root file system until kernel is booted and the real root file system is mounted. It also contains necessary drivers compiled inside, which helps it to access the hard drive partitions, and other hardware.

5. Init

Looks at the /etc/inittab file to decide the Linux run level.

Following are the available run levels
0 – halt
1 – Single user mode
2 – Multiuser, without NFS
3 – Full multiuser mode
4 – unused
5 – X11
6 – reboot
Init identifies the default initlevel from /etc/inittab and uses that to load all appropriate program.

Execute ‘grep initdefault /etc/inittab’ on your system to identify the default run level

If you want to get into trouble, you can set the default run level to 0 or 6. Since you know what 0 and 6 means, probably you might not do that.

Typically you would set the default run level to either 3 or 5.

6. Runlevel programs

When the Linux system is booting up, you might see various services getting started. For example, it might say “starting sendmail …. OK”. Those are the runlevel programs, executed from the run level directory as defined by your run level.

Depending on your default init level setting, the system will execute the programs from one of the following directories.
Run level 0 – /etc/rc.d/rc0.d/
Run level 1 – /etc/rc.d/rc1.d/
Run level 2 – /etc/rc.d/rc2.d/
Run level 3 – /etc/rc.d/rc3.d/
Run level 4 – /etc/rc.d/rc4.d/
Run level 5 – /etc/rc.d/rc5.d/
Run level 6 – /etc/rc.d/rc6.d/
Please note that there are also symbolic links available for these directory under /etc directly. So, /etc/rc0.d is linked to /etc/rc.d/rc0.d.

Under the /etc/rc.d/rc*.d/ directories, you would see programs that start with S and K.

Programs starts with S are used during startup. S for startup.

Programs starts with K are used during shutdown. K for kill.

There are numbers right next to S and K in the program names. Those are the sequence number in which the programs should be started or killed.

For example, S12syslog is to start the syslog deamon, which has the sequence number of 12. S80sendmail is to start the sendmail daemon, which has the sequence number of 80. So, syslog program will be started before sendmail.

Sunday, 20 April 2014

How To  Drives in Windows

How To  Drives in Windows:

1.Go to run .
2.Type "diskpart".
3.Type "list volume".
4.Now select the volume you want to hide by typing "select volume n"(n is the volume number against the drive you want to hide).
eg: select volume 2.
5.Type "revome letter x"(x is the drive name).eg: remove letter D.
Done, now check my computer .
If you want to show the drive again then repeat step 1 to 4 then type "assign letter x".
Note :
**Dont try with drive C **
** If you have locked something with Folderlock or other software then after assigning the drive everything will be unlocked ;)**

Monday, 7 April 2014

Oracle Database 10g Installation on RHEL5.5 64-bit


Oracle Database 10g Installation on RHEL5.5 64-bit

Make sure when partitioning...
 / 15 GB
 swap 4 GB
 /u01 15 GB

Unpack Files
Login as super user.
32-bits Oracle Unzip database the files.
# unzip 10201_database_linux32.zip

64-bits Oracle Unzip database the files.

 #  cd /home/oracle/Desktop/
 #  gunzip 10201_database_linux_x86_64.tar.gz
 #  cpio -idm < 10201_database_linux_x86_64.tar.gz

You should now have a single directory containing installation files. Depending on the age of the download this may either be named  "database".

Make network configuration Static, basically System provide DHCP IP Address.
# system-config-network-tui
Here edit the Device---> eth0-----> Uncheck Use DHCP-----> give Static IP---> Netmask-----Default gateway IP..

Hosts File
The "/etc/hosts" file must contain a fully qualified name for the server.

    <IP-address>  <fully-qualified-machine-name>  <machine-name>
   e.g- 192.168.0.14       desktop20.example.com       localhost


Set Kernel Parameters
# vim /etc/sysctl.conf

    #kernel.shmall = 2097152
    #kernel.shmmax = 536870912
    kernel.shmmni = 4096
    # semaphores: semmsl, semmns, semopm, semmni
    kernel.sem = 250 32000 100 128
    fs.file-max = 65536
    net.ipv4.ip_local_port_range = 1024 65000
    net.core.rmem_default=262144
    net.core.rmem_max=262144
    net.core.wmem_default=262144
    net.core.wmem_max=262144

Run the following command to change the current kernel parameters.

   # /sbin/sysctl -p


Add the following lines to the "/etc/security/limits.conf" file.
As it is given below...

 *       soft    nproc   2047
 *       hard    nproc   16384
 *       soft    nofile  1024
 *       hard    nofile  65536

Add the following line to the "/etc/pam.d/login" file, if it does not already exist.

    session    required     pam_limits.so

Disable secure linux by editing the "/etc/selinux/config" file, making sure the SELINUX flag is set as follows.

    SELINUX=disabled

Alternatively, this alteration can be done using the GUI tool (System > Administration > Security Level and Firewall). Click on the SELinux tab and disable the feature.
Setup

Edit the "/etc/redhat-release" file replacing the current release information (Red Hat Enterprise Linux Server release 5 (Tikanga)) with the following:

    redhat-4

Configure your /etc/yum.repos.d/rhel.repo
    [redhat]
    name=rhel6.5
    baseurl=http://192.168.0.254/rhel-6-64
    enabled=1
    gpgcheck=0

Save the file.

#  yum clean all
#  yum list all 

Install the following packages.
rhel5.5 64-bits
    # yum install setarch make glibc compat-libstdc++-33 compat-gcc-34 compat-gcc-34-c++ gcc libXp openmotif compat-db java* -y

Create the new groups and users.

   # groupadd oinstall
   # groupadd dba
   # groupadd oper

   # useradd -g oinstall -G dba,oper -d /home/oracle oracle
   # passwd oracle

Create the directories in which the Oracle software will be installed.

   # mkdir -p /u01/app/oracle/product/10.2.0/db_1
   # chown -R oracle:oinstall /u01
   # chmod -R 775 /u01

Restart the system and switch to the user oracle.

-- Let's see which shell is being used by the user Oracle.
$ echo $SHELL
/bin/bash

Add the following lines at the end of the ".bash_profile" file.
$ vim ~/.bash_profile
   
#ORACLE SETTING
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_HOSTNAME=desktop2.example.com; export ORACLE_HOSTNAME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
LD_LIBRARY_PATH=$ORACLE_HOME/jdk/jre/i386:$ORACLE_HOME/jdk/jre/lib/i386/server:$ORACLE_HOME/rdbms/lib:$ORACLE_HOME/lib:$LD_LIBRARY_PATH;
export LD_LIBRARY_PATH
PATH=$PATH:$HOME/bin; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
export username

if [ $USER = "oracle" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
     ulimit -p 16384
     ulimit -n 65536
  else
     ulimit -u 16384 -n 65536
  fi
fi

umask 022


Save the file.
Now run the following command to make these changes effective in the current session of user oracle.

-- for bash shell
$ source ~/.bash_profile



Login as root and issue the following command.
Allow the user oracle to use X server, which it will need to run Oracle Universal Installer.
e.g.~ xhost +<machine-name>
# xhost +SI:localuser:oracle
or, # xhost +

Flush the firewall
#  iptables -F


Installation
Start the Oracle Universal Installer (OUI) by issuing the following command in the database directory.

  $ cd Desktop/linux/database/
  $ ./runInstaller

During the installation enter the appropriate ORACLE_HOME and name then continue installation.

If any problem occured during installation, contact me.
Prepared By: Tapas Kumar Sen
email:  tapas.93028@gmail.com

Oracle Database 11g Release 2 (11.2) Installation On RedhatLinux 6


Oracle Database 11g Release 2 (11.2) Installation On RedhatLinux 6

--------------------------------------------------------------
While Installation RHEL6 make sure Swap memory will be 4GB minimum, along with /u01 partition 15GB minimum space.

Unzip the files.

    # 11.2.0.1
    unzip linux.x64_11gR2_database_1of2.zip
    unzip linux.x64_11gR2_database_2of2.zip

 You should now have a single directory called "database" containing installation files.

Hosts File

The "/etc/hosts" file must contain a fully qualified name for the server.

    <IP-address>  <fully-qualified-machine-name>  <machine-name>

For example.

    127.0.0.1       localhost.localdomain  localhost
    192.168.0.181   desktop2.example.com   desktop2

Add or amend the following lines in the "/etc/sysctl.conf" file.

    fs.suid_dumpable = 1
    fs.aio-max-nr = 1048576
    fs.file-max = 6815744
    kernel.shmall = 2097152
    kernel.shmmax = 536870912
    kernel.shmmni = 4096
    # semaphores: semmsl, semmns, semopm, semmni
    kernel.sem = 250 32000 100 128
    net.ipv4.ip_local_port_range = 9000 65500
    net.core.rmem_default=4194304
    net.core.rmem_max=4194304
    net.core.wmem_default=262144
    net.core.wmem_max=1048586

Run the following command to change the current kernel parameters.

    /sbin/sysctl -p


Configure your /etc/yum.repos.d/rhel.repo
    [redhat]
    name=rhel6.5
    baseurl=http://192.168.0.254/rhel-6-64
    enabled=1
    gpgcheck=0

Save the file.

#  yum clean all
#  yum list all 
Install these Packages:

# yum install binutils* compat-libcap* compat-libstdc++-33* compat-libstdc++-33* gcc* gcc-c++* glibc* glibc* glibc-devel* libaio* libaio-devel* libgcc* libstdc++* libstdc++-devel* libXext* libXtst* openmotif* openmotif22* sysstat* ksh* java* numactl-devel-2*x86_64* make-3.81*x86_64* elfutils-libelf-0*x86_64* elfutils-libelf-devel-0*x86_64* -y


Add the following lines to the "/etc/security/limits.conf" file.

    oracle              soft    nproc   2047
    oracle              hard    nproc   16384
    oracle              soft    nofile  4096
    oracle              hard    nofile  65536
    oracle              soft    stack   10240

Add the following line to the "/etc/pam.d/login" file, if it does not already exist.

    session    required     pam_limits.so


Amend the "/etc/security/limits.d/90-nproc.conf" file as described below.

    # Change this
    *          soft    nproc    1024

    # To this
    * - nproc 16384

Set secure Linux to permissive by editing the "/etc/selinux/config" file, making sure the SELINUX flag is set as follows.

    SELINUX=permissive

Once the change is complete, restart the system.

Create the new groups and users.

    groupadd -g 501 oinstall
    groupadd -g 502 dba
    groupadd -g 503 oper


    useradd -u 502 -g oinstall -G dba,oper oracle
    passwd oracle

Create the directories in which the Oracle software will be installed.

    mkdir -p /u01/app/oracle/product/11.2.0/db_1
    chown -R oracle:oinstall /u01
    chmod -R 775 /u01

Login as the oracle user and add the following lines at the end of the ".bash_profile" file.

-- Let's see which shell is being used by the user Oracle.
$ echo $SHELL
/bin/bash

Add the following lines at the end of the ".bash_profile" file.
# vim ~/.bash_profile
   
#ORACLE SETTING
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_HOSTNAME=desktop2.example.com; export ORACLE_HOSTNAME
ORACLE_UNQNAME=orcl; export ORACLE_UNQNAME 
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
LD_LIBRARY_PATH=$ORACLE_HOME/jdk/jre/i386:$ORACLE_HOME/jdk/jre/lib/i386/server:$ORACLE_HOME/rdbms/lib:$ORACLE_HOME/lib:$LD_LIBRARY_PATH;
export LD_LIBRARY_PATH
PATH=$PATH:$HOME/bin; export PATH
PATH=$ORACLE_HOME/bin:$PATH; export PATH
export username

if [ $USER = "oracle" ]; then
  if [ $SHELL = "/bin/ksh" ]; then
     ulimit -p 16384
     ulimit -n 65536
  else
     ulimit -u 16384 -n 65536
  fi
fi

umask 022


Save the file.
Now run the following command to make these changes effective in the current session of user oracle.

-- for bash shell
$ source ~/.bash_profile

Login as root and issue the following command.

  #  xhost +<machine-name>

Flush the Iptables

#   iptables -F

Start the Oracle Universal Installer (OUI) by issuing the following command in the database directory.

  $ cd Desktop/database/
  $ ./runInstaller

A Shell Script To Take RMAN Cold/Hot and Export Backup


A Shell Script To Take RMAN Cold/Hot and Export Backup


#!/bin/bash
# A Shell Script To Take RMAN Cold/Hot and Export Backup
ORACLE_SID=orcl;export ORACLE_SID
echo $ORACLE_SID

echo “Which kind of backup you want to take?”
echo “1) RMAN COLD BACKUP”
echo “2) RMAN HOT BACKUP”
echo “3) LOGICAL OR EXPORT BACKUP”
echo “Enter your option”

read option

while [ $option -gt 3 ]||[ $option -le 0 ]
do
echo “Please Enter the correct option”
read option
done

case $option in
1|2) echo “You are taking RMAN backup of orcl Database”
   rman target sys/oracle@orcl @/ORACLE/RMAN_BACKUP/rman_backup_$option.txt;exit;;
3) echo “You are taking export backup of orcl Database”
   exp system/oracle file=/ORACLE/EXPORT_BACKUP/exp_dat.dmp log=/oracle/export_backup/exp_dat.log full=y;
   exit;;
esac

exit

# Now Create two simple text file for Rman Cold and Hot backup.
# The above script can call anyone of the following RMAN script depending on the option 1-cold or 2-hot backup.

rman_backup_1.txt:

run
{
shutdown immediate;
startup mount;
allocate channel d1 type disk FORMAT "H:\Cold_Backup\COLD_BACKUP_%T_%d-%s_%p.db";
allocate channel d2 type disk FORMAT "H:\Cold_Backup\COLD_BACKUP_%T_%d-%s_%p.db";
backup full format "H:\Cold_Backup\COLD_BACKUP_%T_%d-%s_%p.db" (database);
copy current controlfile to 'H:\Cold_Backup\COLD_BACKUP_Control.db';
release channel d1;
release channel d1;
alter database open;
}

rman_backup_2.txt:

run {
allocate channel d1 type disk FORMAT "H:\Hot_Backup\Hot_BACKUP_%T_%d-%s_%p.db";
allocate channel d2 type disk FORMAT "H:\Hot_Backup\Hot_BACKUP_%T_%d-%s_%p.db";
sql 'alter system archive log current';
 backup
 
  tag Catalog_Full_Rman
  filesperset 10
  format "H:\Hot_Backup\Hot_Backup_%T_FULL_%d-%s_%p.db"
  database archivelog all;
release channel d1;
release channel d1;
}