Friday, December 4, 2009

A little gift - James

James Thomas belongs to Skoost and sent you a little gift.

Click below to collect your gift:
http://uk.skoost.com/fun?jamesmukalel%2Enelgia%40blogger%2Ecom/24330176/12

P.S. This is a safe and innocent gift that James Thomas sent from Skoost.

This e-mail was sent to jamesmukalel.nelgia@blogger.com on 4.12.2009 03:24:58
on behalf of James Thomas (jamesmukalel@gmail.com)

Friday, July 31, 2009

Upgrading Mysql on a plesk server

Uprading MySQL with plesk is not that hard as it sounds and this guide will prove it to you. Below are the steps you need to execute to upgrade your current MySQL version to the latest release. In this guide, we will going to use MySQL version 4.1 but other versions will work as well.

Backup the following files and directory before doing any of the steps below.

/var/lib/mysql - directory where mysql data is stored.

/etc/my.cnf - default mysql configuration file.

/etc/init.d/mysqld - mysql initialization script.

1. Download the pre-compiled MySQL server binaries.

wget -c http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-standard-4.1.22-pc-linux-gnu-i686-icc-glibc23.tar.gz/from/http://mirror.services.wisc.edu/mysql/

2. Move and decompress the download file.

mv mysql-standard-4.1.22-pc-linux-gnu-i686-icc-glibc23.tar.gz /usr/local/

cd /usr/local

tar -vxzf mysql-standard-4.1.22-pc-linux-gnu-i686-icc-glibc23.tar.gz

3. Create a symbolic link of the decompressed files folder to MySQL folder.

ln -s /usr/local/mysql-standard-4.1.22-pc-linux-gnu-i686-icc-glibc23 mysql

4. Edit the mysqld rc file under /etc/init.d

vi /etc/init.d/mysqld

change the mysql server path from /usr/bin to /usr/local/mysql/bin (e.g /usr/local/mysql/bin/safe_mysqld)

5. Add the following lines to the my.cnf file.

[mysqladmin]
socket=/var/lib/mysql/mysql.sock

[mysql]
socket=/var/lib/mysql/mysql.sock [mysql_fix_privilege_tables]
socket=/var/lib/mysql/mysql.sock

6. Stop and Start MySQL server process.

service stop mysqld

service start mysqld

7. Verify that you are able to connect to the mysql server.

mysql -u admin -p your_plesk_admin_password

mysql> select version();
+—————–+
version()
+—————–+
4.1.22-standard
+—————–+
1 row in set (0.00 sec)

That's all about it, if you encounter any errors just drop a message via the comment box.

Friday, July 24, 2009

SCRIPT TO MONITOR A SERVER IN EVERY 30 MINUTES

This script is used to check the health of Your servers.
# !/bin/bash
# add ip / hostname separated by while space 
HOSTS="aaa.com bbb.com 202.10.193.46 router"
# no ping request
COUNT=1
# email report when 
SUBJECT="Ping failed Server Seems to be DOWN"
EMAILID="Your emailid"
for myHost in $HOSTS
do
count=$(ping -c $COUNT $myHost | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
if [ $count -eq 0 ]; then
# 100% failed 
echo "Host : $myHost is down (ping failed) at $(date)" | mail -s "$SUBJECT" $EMAILID

Apache Error - No space left on device: Couldn't create accept lock or Cannot create SSLMutex

Some times you people may face this following error in your Apache Server. The error is as follows while trying to restart.after a configuration changes or something like that

[emerg] (28)No space left on device: Couldn't create accept lock
OR
[crit] (28)No space left on device: mod_rewrite: could not create rewrite_log_lock Configuration Failed
OR
[Wed Dec 07 00:00:09 2005] [error] (28)No space left on device: Cannot create SSLMutex

This is happened due to someking of memory leaking. Normally people do the following to fix this.

1.Checking the harddisk space usage
2.To explicetely different Lockfiles using the LockFile-directive
3.non-default AcceptMutex (flock) which then solved the acceptlock-issue and ended in the rewrite_log_lock-issue.
4.Reboot

The fourth option will only work,because this is due to the following reason
There were myriads of semaphore-arrays left, owned by my apache-user. Removing this semaphores immediately solved the problem
Do the following as ROOT

[root@apache.org] ipcs -s | grep apache | perl -e 'while () { @a=split(/\s+/); print `ipcrm sem $a[1]`}' -- (If You Love Perl)

[root@apache.org] ipcs -s | grep apache | awk ' { print $2 } ' | xargs ipcrm sem (If you Love Sh)

How to Find Server is Under DDOS

A denial-of-service attack (DoS attack) or distributed denial-of-service attack (DDoS attack) is an attempt to make a computer resource unavailable to its intended users. Although the means to carry out, motives for, and targets of a DoS attack may vary, it generally consists of the concerted efforts of a person or persons to prevent an Internet site or service from functioning efficiently or at all, temporarily or indefinitely. Perpetrators of DoS attacks typically target sites or services hosted on high-profile web servers such as banks, credit card payment gateways, and even root nameservers.


netstat -anp | grep "tcp\|udp" | awk {'print $5'} | cut -d: -f1 | uniq -c | sort -n


So what will be the output ?

1 0.0.0.0
1 208.80.152.2
1 208.80.152.2
1 208.80.152.3
1 209.85.135.103
1 209.85.135.113
1 74.125.43.113
2 208.80.152.2
2 208.80.152.3
2 208.80.152.3
3 0.0.0.0
3 208.80.152.2

Left column indicates the number of connection,from the IP address which shown in right column. This was taken from my local test machine. If you are under an attack,this number may vary. The number will be any number.

How to edit the maxconnection in httpd.conf ?

Depending on the cPanel version, you can modify the setting in WHM > Apache Configuration > Global Configuration > MaxClients
Login to the ssh as root and open the file httpd.conf file.

vi /usr/local/apache/conf/httpd.conf
search for the line MaxClients and edit that, save it and exit vi editor. Restart apache then.
 

Saturday, June 20, 2009

Fixing incorrect quota on cpanel

Run #/scripts/fixquotas
For fixing everuthing including mail boxes and DNS,

#/scripts/fixeverything

If it is showing any error about permission of writing on aquota.user file check its permissions and attributes.

#lsattr aquota.user

To remove attribute

#chattr -i aquota.user
---------------------------------------------------------------------------------
Please check for any spelling mistakes on my commands
-----------------------------------------------------------------------------------