Friday, October 18, 2013

System activity analysis for Linux users.

# Instructions to install SAR on your Ubuntu box.
Step 1.  Install sysstat
bash> sudo apt-get install sysstat mutt postfix

Step 2. Enable stat collection
bash> sudo vi /etc/default/sysstat
change ENABLED=”false” to ENABLED=”true”
save the file

Step 3. Change the collection interval from every 10 minutes to every 2 minutes.
bash> sudo vi /etc/cron.d/sysstat
Change
5-55/10 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1
To
*/2 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 1
save the file

Step 4. Restart sysstat
bash> sudo service sysstat restart

The below step has to run manually at 5:00PM for the next two days.
Step 5. Save the statistics for further analysis to a file and send it via mail to view the same on Ksar
bash> sudo -s
bash> LC_ALL=C sar -A > /tmp/$(date +`hostname`-%d-%m-%y.log) && echo "SAR-`hostname`" | mutt -s "SAR-`hostname`" abc@abc.com -a /tmp/$(date +`hostname`-%d-%m-%y.log)

Tuesday, October 8, 2013

How to increase Oracle Session

Check the existing processes and sessions limit using the following query.

SQL> select count(*) from v$session;
SQL> select * from v$resource_limit;

To increase run the following query:

(change the number according to your need)

Connect AS SYSDBA;
SQL> ALTER system SET sessions= 200 scope=spfile;
SQL> ALTER system SET processes = 200 scope=spfile;

Restart the Oracle server.

Tuesday, September 17, 2013

HowTo: Change oracle http port number.

Login as sys as sysdba and execute the following query:
SQL> select dbms_xdb.gethttpport as "HTTP-Port" from dual;
HTTP-Port  
--------------------
     8080
SQL> exec DBMS_XDB.SETHTTPPORT(8090);
Thats all...!!!

Friday, May 10, 2013

HowTO: Oracle the listener supports no services error

The following are the detailed RCA report for the Oracle database issue :

ERROR:
The listener supports no services

ROOT CAUSE:
The database has no idea about the listener because inside the file 'listener.ora', there is no entry of SID_LIST_{listener_name} where {listener_name} need to be replaced by your listener name.

CORRECTIVE ACTION:
Edited the 'listener.ora' file as explained below:

SID_LIST_LISTENER =
 (SID_LIST =
   (SID_DESC =
     (SID_NAME = PLSExtProc)
     (ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_1/)
     (PROGRAM = extproc)
   )
 (SID_DESC=
       (GLOBAL_DBNAME=orcl)
       (ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1/)
       (SID_NAME=orcl)
  )
 )
SUBSCRIBE_FOR_NODE_DOWN_EVENT_LISTENER=OFF
LISTENER =
 (DESCRIPTION_LIST =
   (DESCRIPTION =
     (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
     (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
   )
 )

And fixed net service names map in 'tnsnames.ora' file
ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
    (CONNECT_DATA =
        (SID_NAME = ORCL)
      (SERVER = DEDICATED)
    )
  )

$ lsnrctl status
$ lsnrctl stop
$ lsnrctl start

Monday, February 18, 2013

HowTo: Script to kill all oracle sessions by a user

Normally to Kill a session connected by a user in oracle, you should collect the sid and serial# from the view V$SESSION and execute the following command with sid and serial# filled in it.

ALTER SYSTEM KILL SESSION 'sid,serial#';

We can create a PL/SQL script to kill all the sessions based ton the same, as given below

 begin    
  for x in (select Sid, Serial# from v$session where Username=upper('TypeUserNameHere'))
  loop 
   execute immediate 'Alter System Kill Session '''|| x.Sid || ',' || x.Serial# || ''' IMMEDIATE'; 
  end loop; 
end;
/

If you want to embed it in to a bash (shell) script, it will be like the following script
 
#!/bin/bash
sqlplus -silent /nolog  << EOS
connect / as sysdba
begin    
  for x in (select Sid, Serial# from v$session where Username=upper('TypeUserNameHere'))
  loop 
   execute immediate 'Alter System Kill Session '''|| x.Sid || ',' || x.Serial# || ''' IMMEDIATE'; 
  end loop; 
end;
/
EOS
exit




Wednesday, February 13, 2013

How to connect SQLPlus without adding SID in 'tnsnames.ora'


The following command is used to connect the remote DB without adding the service name(SID) in 'tnsnames.ora'
Example: Input the below cmd in the terminal to connect the remote db.
sqlplus
user@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = <Remote-host> )(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = <SID>)))


Vasanth KG



Wednesday, January 9, 2013

Kill Oracle user session from Linux

==== Kill ORACLE user Session from LINUX ===
Identify the Session to be Killed
SQL> select a.username, a.sid, a.serial#, b.spid, a.machine from v$session a, v$process b where a.paddr = b.addr and a.username ='COCERP_12NOV12';
Bash~$ kill -9 SPID
Verify using
Bash~$ ps -ef | grep ora_ | grep -v grep

That's it.

Monday, October 8, 2012

HOWTO: Remove GRUB Loader and Restore Windows 7 and Vista Bootloader

Boot your system using CD or from recover partition, Select "Repair my computer" mode and select "Command Prompt".
Then you need to type:
bootrec.exe /FixBoot
bootrec.exe /FixMbr

It takes less than a second. Reboot and it’ll boot into Windows automatically.

Fixing the Windows MBR using a Ubuntu Live CD or USB

The method to fix the MBR is:
1. Boot the machine using the Live USB/CD.
2. Install lilo
sudo apt-get install lilo

3. Fix the MBR using lilo using the command:
sudo lilo -M /dev/sda mbr
Reboot your system, Bingo works like charm!!!!

Monday, January 23, 2012

How To Disable Linux USB Drive

For security’s sake, IT auditor and security team normally request system administrator to disable or turn off USB mass storage device to minimize risk of data theft.

Now, let’s see how to disable USB mass storage device on Redhat Linux (RHEL 5.2 particularly; should be applicable to other Linux distributions too):
  1. Login as root,
     
  2. Open /etc/modprobe.d/no-usb for edit (create this file if it’s not exists),
     
  3. Append this line to the no-usb file (in step-2) and save it:
    install usb-storage /bin/true 

Reboot server to enforce change. To confirm USB mass storage support has disabled, just execute lsmod | grep -i usb or try plug in USB drive to confirm.

Tuesday, December 27, 2011

Using Iptables to JBoss run as non-root.

Configuring an iptables firewall on Ubuntu Hardy Heron server

Introduction

In this article we'll set up a simple firewall on an Ubuntu 8.04 server. The firewall has two purposes:

  1. Block all ports except the few which are used to provide services
  2. Map incoming port 80 to port 8080, so that our Java web servers can run as non-root

And all this must be done on a remote server, so we have to do it in a way that doesn't lock us out.

Wednesday, June 22, 2011

HowTo: Read Your SD card with your UBUNTU

"Ubuntu doesn't detect SD Card automatically, Here’s how to get it working, so that it will auto mount any SD card inserted into the slot."

Imp: Make sure your is detected, Get the details on Card Reader.
$ lspci | grep Card

Do the following things.
1. Backup the file /etc/modules
sudo cp /etc/modules /etc/modules.bak

Tuesday, June 14, 2011

How To Remove Windows Genuine Authentication

Have you updated your copy of Windows and received the "This copy of Windows is not genuine" notification. Have you ever wondered how to get rid of it?
The Windows Genuine Advantage notification checks if you have a genuine copy of Windows registered to that computer. It allows you to update your computer with the Windows updates. If you have installed it, and you do not have a genuine copy of Windows XP installed, then you may notice an icon at the bottom of your window before you Login. It will make you wait three seconds before allowing you to login.

Oracle Password Reset

From Oracle FAQ
ORAPWD is a utility used to create a password file for an Oracle Database.
Run orapwd utility before:
    * setting REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE|SHARED
    * Grant OSDBA/OSOPER to users
Check V$PWFILE_USERS to see who was granted OSDBA/OSOPER access.

Create a new password file:
orapwd file=orapwSID password=oracle entries=5
If the password file already exists:
orapwd file=orapwSID password=oracle entries=5 FORCE=Y
The FORCE parameter is available starting from Oracle 10g.

Friday, May 27, 2011

Howto install Bugzilla on Linux

Howto install Bugzilla on Ubuntu.

Assumptions: 
Ubuntu is already installed and configured on your target machine.
The machine is connected to the Internet you can browse the World Wide Web.
Here are the main steps:
  1. Install Per l(5.8.1 or above)
  2. Install MySQL
  3. Install Apache2
  4. Install Bugzilla 3.2
  5. Install Perl modules
  6. Bugzilla using apache