Friday, 5 October 2012

Linux Disk performance tuning

Last weekend I had problems with heavily active server. I check and see that iostat is showing high disk activity service time was about 100. Also that caused cpu load. I try to find which process is causing disk activity. For this I turn on kernel messages about I/O. Normally for old kernels you could not directly see which process is causing heavy disk activity.

echo 1 > /proc/sys/vm/block_dump

dmesg | egrep "READ|WRITE|dirtied" | egrep -o '([a-zA-Z]*)' | sort | uniq -c | sort -rn | head 

 found kjournald causing disk activity. And I know many files are 
created in short term for that server. So I decide to tune filesystem. 
Filesystem is ext3. I decide to move writeback journaling. The writeback
 mode does not preserve data ordering when writing to the 
disk, so commits to the journal may happen before the file system is 
written to. This method is faster because only the meta data is 
journaled, but is not quite as neurotic about protecting your data as 
the default.
I edit fstab and add writeback option
LABEL=/                 /                       ext3    defaults,data=writeback      1 1

Before reboot run this command.If not your server won't boot.
tune2fs -o journal_data_writeback /dev/sda1

Friday, 16 March 2012

Python Cx_oracle ImportError ""

I started to use cx_oracle module for inserting data to oracle. I get error below if i put related script to cron. 
"ImportError: cannot open shared object file: No such file or directory"
 For solution you can run command like below in cron
* * * * * (/bin/ksh;export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib/;/usr/local/