How to , and other stuff about linux, photo, php … A linux, photography blog. To remember some linux situation, and fix them quickly.

February 29, 2012

Standalone vs inetd

Filed under: Linux — Tags: , , , , , , — admin @ 11:34 am

What to use ?
Inetd or standlone server ?
Well I personally chose standalone, however if you have a server with low resources, and a service that you want to run from time to time, then you should go with inetd.

Inetd only spawns the process when it is needed, so the process does not consume resources when no one is using it. However, there is an overhead on each connection as inetd spawns a new process to handle it.

So if you have a heavy used service go with standalone.

February 28, 2012

MYSQL slow queries log

Filed under: Linux — Tags: , , — admin @ 5:18 pm

MySQL has built-in functionality that allows you to log SQL queries to a file , You can enable the full SQL queries logs to a file or only slow running queries log. It is easy for us to troubleshoot/ debug the sql statement if SQL queries log enable.
* To enable slow Query Log only
log-slow-queries = /var/log/mysql/mysql-slow.log
long_query_time = 1

The minimum and default values of long_query_time are 1 and 10, respectively.

* To enable full Log Query
log=/var/log/mysqldquery.log
This will log all queries on your mysqld.

Selecting Queries to Optmize
– The slow query log
– Logs all queries that take longer than long_query_time
– Can also log all querie s that don’t use indexes with
–log-queries-not-using-indexes
– To log slow administatve commands use
–log-slow-admin-statements
– To analyze the contents of the slow log use
mysqldumpslow

February 26, 2012

Create a 1g 100MB 10Mb file for testing transfer speed

Filed under: Linux — Tags: , , , — admin @ 11:39 am

Well yesterday I face another problem.
I have to try transfer speed from one client, because of complaining that his site is loading slow. After a short look on his server the load was below 1 on a quad core, the server didn’t swap, and didn’t have any slow mysql query.
Well last thing I wanted to see how is the bandwidth from that server . So how to create a large file fast ?
Well dd is the command from linux that i use.
So to create 1G file go with
dd if=/dev/zero of=testfile bs=1024 count=1024000
to create 100Mb try
dd if=/dev/zero of=testfile bs=1024 count=102400
and for 10Mb use
dd if=/dev/zero of=testfile bs=1024 count=10240

You can find on other forum that they use /dev/urandom or /dev/random however this are load intensive for your server and take longer to make the file.
So use /dev/zero for this purpose.

February 9, 2012

EBS hangs in “attaching” mode

Filed under: Linux — Tags: , , , , , — admin @ 11:30 am

Well with the script bellow automatic script for backup up redis on a amazon ebs
I saw that was a problem.
From time to time the ebs hang with “attaching”
And the mount command die in D state. And the load on that server grow.
Well, we have modify the script to wait for the volume to be actually “attached” .

This is a improvement version of the script.


#!/bin/bash
date
instance=i-xxxxx
volume=vol-xxxx
iplocalhost=10.00.00.111

export EC2_HOME=/path/ec2-1.4.4.2
export JAVA_HOME=/usr/lib/jvm/jre
export CLASSPATH=${EC2_HOME}/lib
export EC2_PRIVATE_KEY=/root/path/pk.pem
export EC2_CERT=/root/path/cert.pem
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin:/root/bin

if [ ! -d /mnt/backup ]; then
mkdir /mnt/backup
fi

if [ ! -f /tmp/redis1 ]; then
echo "Cron Started"
touch /tmp/redis1
else
echo "Cron already running"
exit 0
fi
atached=1
while [ $atached -eq 1 ];do
echo "">/root/status.txt
/opt/aws/bin/ec2-describe-volumes -K /root/path/pk.pem -C /root/path/cert.pem > /root/status.txt
if grep -q "available" "/root/status.txt" ; then
echo "Volume is available."
echo "Attaching Volume"
/opt/aws/bin/ec2-attach-volume -K /root/path/pk.pem -C /root/path/cert.pem $volume -i $instance -d /dev/sdh
atached=0
else
echo "Volume is already attached on other instance. Sleeping for 60 seconds"
sleep 60
fi
done
avaiable=1
COUNTER=1
while [ $avaiable -eq 1 ];do
/opt/aws/bin/ec2-describe-volumes -K /root/path/pk.pem -C /root/path/cert.pem $volume > /root/status.txt
if grep -q "attached" "/root/status.txt" ; then
echo "Volume is attached."
avaiable=0
echo "Mounting Volume"
mount /dev/sdh /mnt/backup
sleep 10
if [ -f /mnt/backup/montat ]; then
rsync -vrplogDtH /var/lib/redis/ /mnt/backup/redis
fi
else
echo "Volume is attaching. Sleeping for 60 seconds"
sleep 60
fi
if [ $COUNTER -eq 5 ]; then
echo "Quiting ater 5 minutes"
break
fi
let COUNTER+=1
done
umount -lf /mnt/backup
sleep 5
/opt/aws/bin/ec2-detach-volume -f -K /root/path/pk.pem -C /root/path/cert.pem $volume -i $instance -d /dev/sdh
sleep 5
rm -rf /tmp/redis1
exit;

February 7, 2012

service php-fpm restart with error after upgrade from 5.3.8 to 5.3.10

Filed under: Linux — Tags: , , , , , , , — admin @ 4:32 pm

Well
I have to upgrade a server from php 5.3.8 to 5.3.10 on a centos server.
After this the service php-fpm restart didn’t work.
Stopping php-fpm: [FAILED]

So after a short look to the problem, what I discover is that problem is on this file
/etc/init.d/php-fpm

What I have was
pidfile=${PIDFILE-/var/run/php-fpm/php-fpm.pid}
and this line should be
pidfile=${PIDFILE-/var/run/php-fpm.pid}

« Newer PostsOlder Posts »

Powered by WordPress