Archive for August, 2010

SVN plugin inside Eclipse and Microsoft visual Studio

August 27th, 2010

SVN plugin inside a IDE ( Eclipse or Visual Studio ) is a great help for the developer.

Installation of SVN plugin inside Eclipse , I will use subversive plugin here .

1. Go to Help->Software Updates.
2. Click on the “Available Software” tab.
3. Unfold the Ganymede->Collaboration Tools node, and , you will see the “SVN Team Provider (Incubation)” item , “0.7.1.I20080612-1500″. What you really need is the version from 2008-08-01.
4. Click on “Manage Sites…”.
5. Uncheck the “Ganymede” checkbox (http://download.eclipse.org/releases/ganymede)
6. Scroll down to find “http://download.eclipse.org/technology/subversive/0.7/update-site/”, select it and click “OK”.
7. You should be back on the “Available Software” tab, with only the subversive items present. Note that the version identifier is “0.7.3.I20080814-1500″.
8. Check the box, and click”install”. The install will be change to an update. Restart Eclipse at the end of the install.
9. Go to “Help->Software Updates”.
10. Choose the “Available Software” tab.
11. Click the “Add Site” button, and add “http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/”.
12. Check the SVNKit Connectors and click “Install”. Restart Eclipse at the end of the install.
13. Subversive should be working !

Installation of SVN plugin inside Visual Studio IDE

This is very simple just install AnkhSvn exe from the site

http://ankhsvn.open.collab.net/downloads

Install this exe and restart Visual Studio .
This will work on Visual Studio 2005/05/10.

Tomcat 6 installation on CentOS 5/RHEL

August 25th, 2010

We can add repository under /etc/yum.repos.d/
wget ‘http://www.jpackage.org/jpackage50.repo’

#rpm -Uvh ‘http://plone.lucidsolutions.co.nz/linux/centos/images/jpackage-utils-compat-el5-0.0.1-1.noarch.rpm

#yum update
# yum install tomcat6 tomcat6-webapps tomcat6-admin-webapps
# service tomcat6 start

Oracle 10g R2 installtion on CentOS 5.5/RHEL

August 25th, 2010

The main required packages for installing oracle are (installing on 32 bit architecture)

binutils.i386
compat-gcc-7.3-2.96.128.i386
compat-gcc-c++-7.3-2.96.128.i386
compat-libstdc++-7.3-2.96.128.i386
compat-libstdc++-devel-7.3-2.96.128.i386
cpp.i386
gcc.i386
gcc-c++.i386
glibc.i386
glibc-common.i386
glibc-devel.i386
glibc-headers.i386
glibc-kernheaders.i386
libstdc++.i386
libstdc++-devel.i386
libaio
libai-devel.i386
pdksh.i386
setarch.i386
sysstat.i386

Download the Oracle 10gR2 from ,

http://www.oracle.com/technology/software/products/database/oracle10g/index.html

Preinstallation Steps:
1. Edit /etc/hosts file

2. Edit /etc/sysctl.conf
#kernel.shmall = 2097152
#kernel.shmmax = 2147483648
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

3. Run the following command to change the kernel parameters

/sbin/sysctl -p

4. Add the following security parameter
in /etc/security/limits.conf

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

5. Edit /etc/pam.d/login and add following line

session required pam_limits.so

6. SElinux and firewall should be turned off

check /etc/selinux/config

SELINUX=disabled

7. Creating following users and Groups

groupadd oinstall
groupadd dba
groupadd oper

useradd -g oinstall -G dba oracle
passwd oracle

8. Oracle will be installed in the following Directories

#mkdir -p /u01/app/oracle/product/10.2.0/db_1
#chown -R oracle.oinstall /u01

9. Login as Root user on the machine in GUI console and execute
#xhost +
This will enable other users to use X console

10. Take backup of the file /etc/redhat-release to /etc/redhat-release.original

and edit /etc/redhat-release
#echo “redhat-4″> /etc/redhat-release

11. Edit the /home/oracle/.bash_profile
add the following lines

# Oracle Settings
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR

ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1; export ORACLE_HOME
ORACLE_SID=TSH1; 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

12. Log into the oracle user. If you are using X emulation then set the DISPLAY environmental variable:

DISPLAY=:0.0; export DISPLAY

13. Copy the file 10201_database_linux32.zip into oracle user home directory ,i.e, /home/oracle

and unzip the file.

14. Now the time to start installation

when u extact the file it will create a database directory.
$cd database
$./runInstaller
This will start Oracle Universal Installer

15 . In Oracle Universal Installer

a. Select Advanced Installation
b. Here Specify Inventory Directory and Credentials

Values are : /u01/app/oracle/oraInventory
and OS group name will be onistall

c. Select Installation Type
Enterprise Edition
d. Specify Home Details
Name; db_1
Path ; /u01/app/oracle/product/10.2.0/db_1

e. Product Specific Prerequisite checks

This should come passed ,otherwise select user varified

f. Select Configuration Options

Create Database

g. Select Database configuration

General Purpose

h. Specify Database configuration options
Global Database Name: TSH1
SID : TSH1

i. Select Database management options

use database control for database management

j. Specify Database Storage Option
File System
location /u01/app/oracle/oradata

k. Specify Backup and Recovery Options

Do not enable

l. Specify Database Schema Passwords

give a password which you must remember .

m. Summery and install
when the installation finishes it will show
Database Configuration Assistant
click ok
Now it will give you 2 scripts which must be run as root
#/u01/app/oracle/oraInventory/orainstRoot.sh
#/u01/app/oracle/product/10.2.0/db_1/root.sh

This is the end of installation part.

16. Post installation Steps

Just copy back
#cp /etc/redhat-release.original /etc/redhat-release

Edit the file /etc/oratab , In last change to Y

TSH1:/u01/app/oracle/product/10.2.0/db_1:Y

17. Autostart and Stop Script , login as root and create a script

This script is required to automatically start/stop  Oracle database

#vim /etc/init.d/dbora

ORA_HOME=/u01/app/oracle/product/10.2.0/db_1
ORA_OWNER=oracle

if [ ! -f $ORA_HOME/bin/dbstart ]
then
    echo "Oracle startup: cannot start"
    exit
fi

case "$1" in
    'start')
        # 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"
        ;;
    'stop')
        # 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"
        ;;
esac

---------------------------------
#chmod 750 /etc/init.d/dbora
#chkconfig --level 345 dbora on

Now we have created the script which will start/stop with Operating system 

#/etc/init.d/dbora stop

#/etc/init.d/dbora start

Note : you may get the listener waring message while starting oracle db

Failed to auto-start Oracle Net Listener using /ade/vikrkuma_new/oracle/bin/tnslsnr

To Resolve the issue ,login as oracle user and  change the file $ORACLE_HOME/bin/dbstart

Nearly 78 line

ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle

Change to

ORACLE_HOME_LISTNER=$ORACLE_HOME

18. As oracle user Login in shell

$sqlplus
usename : SYSTEM
password : givenbyyou

Some of the Reference taken from
1. http://dearlinux.wordpress.com/2010/07/01/installing-oracle-database-10g-release-2-on-linux-rhel-5-part-2/
2. http://www.oracle-base.com/articles/10g/OracleDB10gR2InstallationOnRHEL5.php
3. http://ivan.kartik.sk/oracle/install_ora10gR2_redhat.html

Can’t read /sys/hypervisor/uuid which leads to high load average.

August 14th, 2010

Description of problem:

When the daemon of xend stops ,the cron task who is
/etc/cron.hourly/mcelog.cron can’t read /sys/hypervisor/uuid.It leads to D
status of “cat /sys/hypervisor/uuid ” which results in high load average

Version-Release number of selected component (if applicable):
In RHEL5.4 for 64 bits x86_64 xen kernel.

How reproducible:
In xen kernel,make the daemon of xend stop.

Steps to Reproduce:
1.#service xend stop
2.#top  (see the load average by hours)
3.#ps aux |grep “^D” (there are lots of “D” status process)

Actual results:
See the result of ‘ps’ ,we will find there are a lot of “D” state
process.Theses process are waiting for cat /sys/hypervisor/uuid.And the load
average become more and more high.
Expected results:

When the daemon of xend stops, the process can read /syst/hypervisor/uuid.The
load average is not high by hours.

[root@server ~]# ps aux | grep /sys/hypervisor/uuid
root       708  0.0  0.0   3796   400 ?        D    05:00   0:00 cat /sys/hypervisor/uuid
root      2313  0.0  0.0   3796   396 ?        D    Aug13   0:00 cat /sys/hypervisor/uuid
root      4477  0.0  0.0   3796   400 ?        D    Aug13   0:00 cat /sys/hypervisor/uuid
root      5813  0.0  0.0   3796   396 ?        D    06:00   0:00 cat /sys/hypervisor/uuid
root      6140  0.0  0.0   3796   396 ?        D    Aug13   0:00 cat /sys/hypervisor/uuid
root      6502  0.0  0.0   3796   400 ?        D    Aug13   0:00 cat /sys/hypervisor/uuid
root      7403  0.0  0.0   3796   396 ?        D    00:00   0:00 cat /sys/hypervisor/uuid
root      9434  0.0  0.0   3796   396 ?        D    Aug13   0:00 cat /sys/hypervisor/uuid
root     10902  0.0  0.0   3796   396 ?        D    07:01   0:00 cat /sys/hypervisor/uuid
root     11499  0.0  0.0   3796   400 ?        D    Aug13   0:00 cat /sys/hypervisor/uuid
root     12471  0.0  0.0   3796   400 ?        D    01:00   0:00 cat /sys/hypervisor/uuid
root     14525  0.0  0.0   3796   396 ?        D    Aug13   0:00 cat /sys/hypervisor/uuid
root     16579  0.0  0.0   3796   400 ?        D    Aug13   0:00 cat /sys/hypervisor/uuid
root     16630  0.0  0.0   3796   400 ?        D    08:01   0:00 cat /sys/hypervisor/uuid
root     17055  0.0  0.0  58904   464 ?        D    08:07   0:00 cat /sys/hypervisor/uuid
root     17562  0.0  0.0   3796   396 ?        D    02:00   0:00 cat /sys/hypervisor/uuid
root     18017  0.0  0.0  61160   748 pts/2    S+   08:17   0:00 grep /sys/hypervisor/uuid
root     19598  0.0  0.0   3796   396 ?        D    Aug13   0:00 cat /sys/hypervisor/uuid
root     21655  0.0  0.0   3796   400 ?        D    Aug13   0:00 cat /sys/hypervisor/uuid

Due to this load average is very -2 high ( load average: 22.09, 22.07, 22.01). After stopping xend #service xend stop and i have started again and all cat /sys/hypervisor/uuid process stopped and i have stopped this process again.

After restarting xend services, all /sys/hypervisor/uuid processes killed and also load average was coming donw
[root@server ~]# ps aux | grep /sys/hypervisor/uuid
root     21666  0.0  0.0  61160   736 pts/0    S+   08:30   0:00 grep /sys/hypervisor/uuid
[root@server ~]#

[root@server ~]# uptime
08:30:26 up 22:03,  1 user,  load average: 2.35, 14.47, 19.67
[root@server ~]#

Thanks
Manoj

Upgrading MySQL from 4 to 5

August 14th, 2010

MySQL upgradation is a simple process of removing old binaries and installing the new one.
Following is a process of how to upgrade MySQL 4.1 to MySQL 5 on RHAS 4

Note: Before going to upgrade your database take a backup of your database and /etc/my.cnf file.

Now find out the current packages Installed on your system by

[root@localhost~]# rpm –qa | grep mysql
mysqlclient10-3.23.58-4.RHEL4.1
mysql-devel-4.1.7-4.RHEL4.1
mysql-server-4.1.7-4.RHEL4.1
mysql-4.1.7-4.RHEL4.1
mod_auth_mysql-2.6.1-2.1
mysql-bench-4.1.7-4.RHEL4.1
libdbi-dbd-mysql-0.6.5-10.RHEL4.1
php-mysql-4.3.9-3.1

Once you find out the packages now its time to remove the unwanted packages mainly server and client, but the communication packages and authentication packages can be remain as it is; if require you can remove those also.

I have selected the following packages to remove, remove it by following command

rpm -e –nodeps mysql-devel-4.1.7-4.RHEL4.1
rpm -e –nodeps mysql-server-4.1.7-4.RHEL4.1
rpm -e –nodeps mysql-4.1.7-4.RHEL4.1
rpm -e –nodeps mysql-bench-4.1.7-4.RHEL4.1
rpm -e –nodeps mysql-bench-4.1.7-4.RHEL4.1

Once you have removed the mysql packages, restart the server (Not necessary but better to do)
Before restarting the server check the folder name mysql on location /var/lib; this folder is actual repository of your mysql databases.

After restarting deploy the mysql 5 packages by issuing following command

rpm -ivh MySQL-server-community-5.0.51a-0.rhel4.i386.rpm
rpm -ivh MySQL-client-community-5.0.51a-0.rhel4.i386.rpm
rpm -ivh MySQL-shared-compat-5.0.51a-0.rhel4.i386.rpm
rpm -ivh MySQL-devel-community-5.0.51a-0.rhel4.i386.rpm

Here you have upgrade the mysql 4 to mysql 5. Now try to log in to the database by using your previously defined database user and password.

How to Delete a Big Number of Files in a Folder

August 13th, 2010

If you’re using temporary files you should notice that after some time it is hard to delete them as their number is growing. If you have many files and try to delete them with a usual command rm -f you should receive something like this:

[root@server html]# rm -f *
-bash: /bin/rm: Argument list too long

OR

In our case (Number of files in the folder is around 1 million ) if we run ls or other command, linux shell prompt hung and we need to start new terminal.

What to do when this occurs? You have to combine several Linux commands in order to empty this folder. Here is the command you should use; I will explain what does it do below.

[root@server html]# ls | grep .| xargs rm

This will do the following: the first command ls outputs the list of files. The output is being sent to grep command so you won’t see it in your console. Grep searches for files with “.” symbol (in the example given I think that all your files have so named extension – filenames contain a dot. So grep will extract all the file names that contain a dot and will throw them to the next function – xargs. xargs accepts these filenames and deletes them one by one. This allows to reduce server load and gives us the possibility to delete multiple files in one folder that are no longer necessary.

Thanks
Manoj

SVN installation with Apache

August 13th, 2010

1. First of all, install apache/httpd
* yum install httpd
2. Make sure you apache is running. You can also type ‘http://localhost’ at your browser and apache test page should appear if your apache is running
* /etc/init.d/httpd status
3. Make it start by default on startup
* chkconfig httpd on
4. Edit the apache configuration to suit your need. If not sure, leave the default setting as it is
* vi /etc/httpd/conf/httpd.conf
5. Install subversion and mod_dav_svn for apache
* yum install mod_dav_svn subversion
6. Go to subversion.conf in /etc/httpd/conf.d/. Edit as below
* cd /etc/httpd/conf.d/
* vi subversion.conf

1. This is the most basic configuration where anyone will have unrestricted access to the repos. Location is the name that will be used in the browser address bar. In this example it will be ‘http://localhost/svn/repos’

2. This is a configuration with username and password for the client

DAV svn

SVNListParentPath on

SVNParentPath /usr/local/svn/

AuthType Basic

AuthName “Subversion repositories”

AuthUserFile “/etc/httpd/conf.d/svnuserconf”

Require valid-user

1.
* htpasswd -cm /etc/httpd/conf.d/svnuserconf admin — This command is not needed for the first configuration. To create the first user with password
* htpasswd -m /etc/httpd/conf.d/svnuserconf pawan — use this command to add another user
2. Configure your repository
* mkdir /usr/local/svn — create folder svn
* cd /usr/local/svn — change diectory to the newly created svn directory
* svnadmin create repos — create svn repository named repos
* chown apache.apache -R repos — change ownership of ‘repos’ to apache
* /etc/init.d/httpd restart — restart apache
* If you are running different apache change port no from conf file.
3. Open you browser and type ‘http://localhost/svn/repos’. You can see that a page with ‘Revision 0:/’ will appear. Congratulation, you just completed the setup for svn server

SSH login expect shell script to supply username and password

August 12th, 2010

#!/usr/bin/expect -f
# Expect script to supply root/admin password for remote ssh server
# and execute command.
# This script needs three argument to(s) connect to remote server:
# password = Password of remote UNIX server, for root user.
# ipaddr = IP Addreess of remote UNIX server, no hostname
# scriptname = Path to remote script which will execute on remote server
# For example:
#  ./sshlogin.exp password 192.168.1.11 who
# ————————————————————————
# Copyright (c) 2010 Onaxer project <http://onaxer.com/>
# This script is licensed under GNU GPL version 2.0 or above
# ————————————————————————-
# This script is part of Onaxer shell script collection (NSSC)
# Visit http://onaxer.com/ for more information.
# ———————————————————————-
# set Variables
set password [lrange $argv 0 0]
set ipaddr [lrange $argv 1 1]
set scriptname [lrange $argv 2 2]
set arg1 [lrange $argv 3 3]
set timeout -1
# now connect to remote UNIX box (ipaddr) with given script to execute
spawn ssh root@$ipaddr $scriptname $arg1
match_max 100000
# Look for passwod prompt
expect “*?assword:*”
# Send password aka $password
send — “$password\r”
# send blank line (\r) to make sure we get back to gui
send — “\r”
expect eof

Thanks
Manoj Chauhan

Backup an entire hard disk using dd command

August 10th, 2010

The ‘ dd ‘ command is one of the original Unix utilities and should be in everyone’s tool box. It can strip headers, extract parts of binary files and write into the middle of floppy disks; it is used by the Linux kernel Makefiles to make boot images. It can be used to copy and convert magnetic tape formats, convert between ASCII and EBCDIC, swap bytes, and force to upper and lowercase.

For blocked I/O, the dd command has no competition in the standard tool set. One could write a custom utility to do specific I/O or formatting but, as dd is already available almost everywhere, it makes sense to use it.

Like most well-behaved commands, dd reads from its standard input and writes to its standard output, unless a command line specification has been given. This allows dd to be used in pipes, and remotely with the rsh remote shell command.

Unlike most commands, dd uses a keyword=value format for its parameters. This was reputedly modeled after IBM System/360 JCL, which had an elaborate DD ‘Dataset Definition’ specification for I/O devices. A complete listing of all keywords is available from GNU dd with

# dd –help

For more options check dd man page

Using dd you can create backups of an entire harddisk or just a parts of it. This is also usefull to quickly copy installations to similar machines. It will only work on disks that are exactly the same in disk geometry, meaning they have to the same model from the same brand.

full hard disk copy

dd if=/dev/hdx of=/dev/hdy
dd if=/dev/hdx of=/path/to/image
dd if=/dev/hdx | gzip > /path/to/image.gz

Hdx could be hda, hdb etc. In the second example gzip is used to compress the image if it is really just a backup.

Restore Backup of hard disk
copy

dd if=/path/to/image of=/dev/hdx

gzip -dc /path/to/image.gz | dd of=/dev/hdx

MBR backup

In order to backup only the first few bytes containing the MBR and the partition table you can use dd as well.

dd if=/dev/hdx of=/path/to/image count=1 bs=512

MBR restore

dd if=/path/to/image of=/dev/hdx

Add “count=1 bs=446″ to exclude the partition table from being written to disk. You can manually restore the table.

Thanks
Manoj