Wednesday, 9 December 2015

Increase Swap Size for linux Server

1. Create Swap file

 > touch /swapfile

2. To create 2GB of swap file,

 > dd if=/dev/zero of=/swapfile bs=1024 count=2048000

  For 4GB,

 > dd if=/dev/zero of=/swapfile bs=1M count=4096

3. mkswap /swapfile

Now the swap file is created.

4. To activate /swapfile file,

 > swapon /swapfile

5. Add entry on /etc/fstab file to activate after serevr reboot,

 > vi /etc/fstab

   /swapfile swap    swap    defaults        0 0

Now check the swap space,

 > free -m

Thursday, 29 October 2015

Increase Max user connection for a database

Max user connection for a database can be increased by following query



mysql > GRANT ALL ON dbname.* TO ‘dbuser’@’localhost’
->     WITH MAX_USER_CONNECTIONS 200;
Similarly max queries, max connections, max updates can be increased with below query
mysql > GRANT ALL ON dbname.* TO ‘dbuser’@’localhost’
->     WITH MAX_QUERIES_PER_HOUR 20
->          MAX_UPDATES_PER_HOUR 10
->          MAX_CONNECTIONS_PER_HOUR 5 ;

GRANT ALL ON dbname.* TO ‘dbuser’@’localhost’
->     WITH MAX_QUERIES_PER_HOUR 20
->          MAX_UPDATES_PER_HOUR 10
->          MAX_CONNECTIONS_PER_HOUR 5
->          MAX_USER_CONNECTIONS 200;

Tuesday, 15 September 2015

Server load alerts via email using shell script

>> cd /root

>> vi loadalert
=========================
EMAIL="your email"
SUBJECT="Alert $(hostname) load average is $L05"
TEMPFILE="/tmp/$(hostname)"
TOPLOAD="10"
echo "Load average Crossed allowed limit." >> $TEMPFILE
echo "Hostname: $(hostname)" >> $TEMPFILE
echo "Local Date & Time : $(date)" >> $TEMPFILE
echo "| Uptime status: |" >> $TEMPFILE
echo "-------------------------------------------" >> $TEMPFILE
/usr/bin/uptime >> $TEMPFILE
echo "-------------------------------------------" >> $TEMPFILE
echo "| Top 20 CPU consuming processes: |" >> $TEMPFILE
ps aux | head -1 >> $TEMPFILE
ps aux --no-headers | sort -rn +2 | head -20 >> $TEMPFILE
echo "| Top 10 memory-consuming processes: |" >> $TEMPFILE
ps aux --no-headers| sort -rn +3 | head >> $TEMPFILE
echo "-------------------------------------------" >> $TEMPFILE
echo "| Memory and Swap status: |" >> $TEMPFILE
/usr/bin/free -m >> $TEMPFILE
echo "-------------------------------------------" >> $TEMPFILE
echo "| Active network connection: |" >> $TEMPFILE
echo "-------------------------------------------" >> $TEMPFILE
/bin/netstat -tnup | grep ESTA >> $TEMPFILE
echo "-------------------------------------------" >> $TEMPFILE
echo "| Disk Space information: |" >> $TEMPFILE
echo "-------------------------------------------" >> $TEMPFILE
/bin/df -h >> $TEMPFILE
echo "-----------------THE END-------------------" >> $TEMPFILE
L05="$(uptime|awk '{print $(NF-2)}'|cut -d. -f1)"
if test $L05 -gt $TOPLOAD
then
mail -s "$SUBJECT  $L05" "$EMAIL" < $TEMPFILE
fi
rm -f $TEMPFILE


chmod 755 loadalert
Updated this script on your cronjob
echo “*/5 * * * * /root/loadalert >/dev/null 2>&1″ >> /var/spool/cron/root
Restart cron service
/etc/init.d/crond restart

Sunday, 14 June 2015

Softaculous installation,backup and restoration on cpanel


Softaculous installation,backup and restoration on cpanel
============================
https://www.softaculous.com/docs/Installing_Softaculous_in_cPanel
https://www.softaculous.com/docs/How_to_Restore_a_Backup_on_a_New_Server

PHP 503 error >> Domain using word press

PHP 503 error >> Domain using word press
========================================
Error log
===========
2015-06-14 03:53:20.879 [INFO] [220.225.193.249:64615-0#APVH_wathletes.com] connection to [/tmp/lshttpd/APVH_wathlete_Suphp.sock.833] on request #0, confirmed, 1, associated process: 987667, running: 1, error: Connection reset by peer!
2015-06-14 03:53:20.879 [NOTICE] [220.225.193.249:64615-0#APVH_wathletes.com] Max retries has been reached, 503!
2015-06-14 03:53:20.879 [NOTICE] [220.225.193.249:64615-0#APVH_wathletes.com] oops! 503 Service Unavailable
2015-06-14 03:53:20.879 [NOTICE] [220.225.193.249:64615-0#APVH_wathletes.com] Content len: 0, Request line: 'GET / HTTP/1.1'
2015-06-14 03:53:20.879 [INFO] [220.225.193.249:64615-0#APVH_wathletes.com] abort request..., code: 4
2015-06-14 03:53:20.879 [INFO] [220.225.193.249:64615-0#APVH_wathletes.com] File not found [/home/wathlete/public_html/503.shtml]

=============
Resolution
==========

Check the Plugin folder and rename the plugin

=================

Wednesday, 27 May 2015

Openvz live migration

This is a quick and easy guide to moving OpenVZ virtual servers around your SolusVM cluster:


1.Run the following code on the node that hosts the container you want to migrate:

wget http://files.soluslabs.com/solusvm/scripts/keyput.sh chmod a+x keyput.sh ./keyput.sh destination_node_ip destination_node_port
  • <destination_node_ip> should be replaced with the IP address of the node you want to migrate the virtual server to
  • <destination_node_port> should be replaced with the SSH port of the node you want to migrate the virtual server to
2. Find the container ID (CTID) of the VPS you want to move and start the migration using vzmigrate:
vzmigrate -v --ssh="-p destination_node_port" destination_node_ip container_id
3.  Update your SolusVM Master when the restore is complete so it knows where the VPS has been moved to. Run the following on your SolusVM Master:

/scripts/vm-migrate [VSERVERID] [NEWNODEID]
 
For example:

/scripts/vm-migrate 150 4
 
 

Openvz node full, 100%

[root@node~]# df -Th
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/sda5      ext4  1.1T  1.1T 1001M 100% /
/dev/sda2      ext4  2.9G  4.6M  2.9G   1% /tmp
/dev/sda1      ext4  479M  184M  295M  39% /boot


Find the container and their disk usage
============================

find /vz/private/  -type f -size +500000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

/vz/private/402/root.hdd/root.hdd: 15G
/vz/private/367/root.hdd/root.hdd: 22G
/vz/private/448/root.hdd/root.hdd: 6.2G
/vz/private/392/root.hdd/root.hdd: 50G
/vz/private/391/root.hdd/root.hdd: 18G
/vz/private/436/root.hdd/root.hdd: 11G
/vz/private/432/root.hdd/root.hdd: 1.4G
/vz/private/416/root.hdd/root.hdd: 16G
/vz/private/387/root.hdd/root.hdd: 50G
/vz/private/386/root.hdd/root.hdd: 20G
/vz/private/405/root.hdd/root.hdd: 23G
/vz/private/443/root.hdd/root.hdd: 8.9G
/vz/private/427/root.hdd/root.hdd: 31G

===================
Delete unwanted space using files like backup files
===========
 for i in `cat /proc/vz/veinfo | awk '{print $1}'|egrep -v '^0$'`; do echo "Container $i"; vzctl exec $i find . -name "*backup*.tar.gz" -type f -delete; done
===========

Find the space usage in containers  >> vzctl enter container ID then
==========
 find /home -type f -size +500000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'


=========================

If the issue still not under control try the below command via node on the containers that have space issues
====
Run this command vzctl compact ctid
===================================


Last method >> migrate any two containers to some other location using openvz live migration
======

https://documentation.solusvm.com/plugins/servlet/mobile#content/view/557438