Tuesday, December 14, 2010

Install perl GD module

Hi all,

If you are getting below error while instaling perl GD module module

Could not find gdlib-config in the search path. Please install libgd 2.0.28 or higher


Follow the below steps

1:do yum install gd gd-devel
2: go to cpan
3:then fire install GD

You are all set to go, your GD module should install now

Wednesday, July 7, 2010

How to Log slow queries in postgresql database

Hi All,

Postgresql db can log sql queries that takes more time to execute then specified time limit.


Suppose you want to log sql queries that takes more than 100ms to execute.

Follow the below steps

1: Open postgresql.conf file. You will find this file in data folder of postgres.
2: Modify the below paratmeters

a:logging_collector = on
b:log_min_duration_statement = 100
c:log_duration = on

3: Save and close this file.
4: Restart the DB

Now execute the queries again. P{ostgres will log all the queries in pg_log folder
pg_log folder will be inside your data folder of postgresql.
Name of log file will be in the following format

postgresql-%Y-%m-%d_%H%M%S.log


If you want to change log directory and log file name, just modify these parameters to desired value

#log_directory = 'pg_log' # directory where log files are written,
# can be absolute or relative to PGDATA
#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,

Get Index statistics in Postgresql database

I always observed that around 30 to 40% indexes created on a database are never used by any queries.

Having extra indexes on a DB, can degrade the performance (update and insert statements) , consumes lot of space and can increase the time of backup and restoring the DB.

It make sense to check the index utilization.

To check the same in Postgresql Database follow below steps.


1: Open postgresql.conf file. This file is inside your data directory of postgres.
2: Change following parameters

A: logging_collector = on
B:track_activities = on
C:track_counts = on
3: save and close the file
4: Restart the postgresql server

Now do all possible operartions using application, just to make sure all possible queries got fired to database.

Now just run the following query



select * from pg_stat_all_indexes where schemaname= order by relname,idx_scan desc;


You will find statistics of all indexes.

Sunday, April 11, 2010

Always make sure your JVM is runnig is SERVER mode not in client mode

Hi,

JVM can run in many modes and selecting a proper mode can help improve your application performance

In servers, make sure JVM is runnig in server mode . This activates the server hotspot JIT.
It may need more time to start. But this delivers best performance.

Other modes of JVM are client and classic mode.

make sure -server, should be the first argument to java

Sunday, March 28, 2010

Too Many Open Files problem in Linux

Hi All,

Most of the time during stress testing on linux server, you may encounter the following problem

SEVERE: Endpoint ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=80] ignored exception: java.net.SocketException: Too many open files
java.net.SocketException: Too many open files

We get this error when system reaches the the max file limit set on your Linux OS

first check the limit set on your OS with the following command
cat /proc/sys/fs/file-max

if you want to check the current open files .
1:lsof |wc -l ( to check number of all open files)
2:lsof -p | wc -l ( to check number of opened files by a process)

in Ubuntu
ulimit -n



to change the value
1 edit /etc/sysctl.conf and set fs.file-max to any desired value

then run

sysctl -p

you may have to restart your system after this




Monday, March 22, 2010

troubleshoot mysql database connection pool problems

If you are getting following error messages, then its time to tune your mysql max_connection value

1:User 'mysqldba' has exceeded the 'max_user_connections' resource
2:Too many connections
3:GenericJDBCException: Cannot open connection
4:message from server: "Too many connections"

Now once u got these messages, we need to change value of max_connection variable in mysql database.

There are two ways to do this.

Method 1:Without restarting the mysql DB.
a;login to the mysql db.
b: run the query ----
show variables like "max_connections";
c: this will display the current value to max_connections.
d: Now to change the value of max_connection, run this query
set GLOBAL max_connections=NewValue;

max_connection value is changed , now again run the query
'show variables like "max_connections";'
to check if the value is reflecting.

But this value will be temporary, if you restart the mysql DB, max_connection value will again set to its default value

Method 2: This requires restarting the DB, but this change will be permanent and will not go even after restart of the db

a: For this you need to change the global setting file of mysql ie "my.cnf" file
b: By default, path of my.cnf will be under etc directory. If you dont know the path, run the
following command to get the path of my.cnf file
find / -name my.cnf
c: Once you got the path . open the file in vi editor.
d: You will find [mysqld] inside this file
e: Just add one line below this

max_connections=NewValue
f: restart the db.
g: login to the mysql and run the following query to check the value of max_connection

show variables like "max_connections";

Wednesday, January 13, 2010

Monitor cpu utilization of all threads in a process in windows

Hi All,

We can monitor cpu utilization of all threads for a process in windows using perfmon tool and this tool also writes logs to a file.
We can also use process explorer for this but this tool can not write logs.

To monitor threads in a process in windows,
1: Launch perfmon
2:Click Performance Logs and Alerts tree on left most window
3:Select Counter Logs from tree structure
4: Right click Counter Logs and select "New Log setting"
5: Give any name for new logs.
6: Click on Add general tab at top.
7: click "add counters" button.
8:From "Performane objects" drop down, select thread.
9:At right hand side, it will display all currently executing threads in windows.
10:Select the threads, you want to monitor and counter to monitor from lft hand side window.
11:Click close and go to "Log Files" tab.
12:Set the log file path and type.