Friday, October 26, 2012

How to enable Innodb storage engine ?

What is a storage Engine?

Data in MySQL is stored in files (or memory) using a variety of different techniques. Each of these techniques employ different storage mechanisms, indexing facilities, locking levels and ultimately provide a range of different functions and capabilities. By choosing a different technique you can gain additional speed or functionality benefits that will improve the overall functionality of your application.

You can configure the mysql database to use Innodb Storage engine . Just follow following simple steps for this.

1) Open your file /etc/my.cnf.

2) Comment the line
skip-inndob

3)Add:
default-table-type=innodb

4)Now save the file and restart the mysql service on the server.

5) Now check if the engine has changed with the command:

[root@server~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.92-community MySQL Community Edition (GPL)
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql> show engines;
+————+———+—————————————————————-+
| Engine | Support | Comment |
+————+———+—————————————————————-+
| MyISAM | YES | Default engine as of MySQL 3.23 with great performance |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables |
| InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys |
| BerkeleyDB | NO | Supports transactions and page-level locking |

This should now change the storage engine for mysql on the server

cPanel pid file exists

cPanel pid file exists

In Some occations restarting cpanel service from Terminal/Shell using command “service cpanel restart” if you are getting “cpsrvd dead but pid file exists”, then let us know what should be done to resolve the issue.

ERROR:
root@server[#]/etc/init.d/cpanel status
cpsrvd dead but pid file exists
entropychat (pid 7397) is running…
melange is stopped
stunnel (pid 7523) is running…
interchange is stopped
qrunner is stopped

SOLUTION:
please check whether “cpsrvd” is running or not, using following command.

root@server[#]ps aux|grep cpsrvd
root 25755 0.0 1.3 12664 7072 pts/0 S 04:31 0:00 cpsrvd – waiting for connections
root 30218 0.0 0.1 3012 724 pts/0 S+ 04:37 0:00 grep cpsrvd

If cpsrvd is running on the server then Iptables must be blocking the port cpanel currently running on and hence we need to disable the Default firewall of the Linux i.e., iptables.

But it is strongly recommended that firewall like CSF should be installed on the server to block “Failed Login Attempts”.

Follow these steps :

root@server[#]service iptables stop
root@server[#]/usr/local/cpanel/cpsrvd
root@server[#] /etc/init.d/cpanel restart
root@server[#]/etc/init.d/cpanel status

If still the issue persist, edit the cpanel deamon file :

root@server[#]vi /etc/init.d/cpanel change

change “status cpsrvd” to “status cpsrvd-ssl” and save the changes.

root@server[#]/etc/init.d/cpanel restart
root@server[#]/etc/init.d/cpanel status

This will resolve the issue.

Configure Cluster & Synchronize in cPanel

Configure Cluster & Synchronize

==========================================>
Login to WHM >> Main >> Cluster/Remote Access >> Configure Cluster

•Click “Enable DNS Clustering”
•Click “Change”
•Click “Return to Cluster Status”

WHM >> Main >> Cluster/Remote Access >> Configure Cluster

1. Add a new server to the cluster
2. Configure

————————->
Remote cPanel & WHM DNS host: nameserver
Remote server username: root
Remote server access hash:

DNS Role : Synchronize changes
————————->

/scripts/dnscluster syncall –full
==========================================>

Reference : http://docs.cpanel.net/twiki/bin/view/AllDocumentation/WHMDocs/ConfigureCluster

Monday, October 22, 2012

How to fix cPanel tailwatchd errors

How to fix cPanel tailwatchd errors

Run the following commands first.

/usr/local/cpanel/bin/checkperlmodules –full
/usr/local/cpanel/libexec/tailwatchd –restart
/scripts/cleanmd5
/etc/init.d/cpanel restart

After that run the below scripts.
———–
/scripts/restartsrv chkservd
/scripts/upcp –force

Converting table to InnoDB

Converting table to InnoDB

Converting table to InnoDB: “The used table type doesn’t support FULLTEXT indexes”

Somtimes you may want to change the Mysql table from MyISAM to InnoDB engine to setup foreign keys, to use row level locks, improve performace etc.

The conversion of the MyISAM table to InnoDB is easy however, if the table is setup with “FULLTEXT indexes”, it cannot be converted as this feature is not supported in InnoDB.

If a table is setup with “FULLTEXT indexes”, the conversion of table to InnoDB will result in “The used table type doesn’t support FULLTEXT indexes” error message.

mysql> ALTER TABLE test ENGINE=InnoDB;
ERROR 1214: The used table type doesn’t support FULLTEXT indexes
The solution is to remove “FULLTEXT indexes” from the table before converting to InnoDB. To check if the table is setup with FULLTEXT indexes, execute:

mysql> show create table test;
————————
| Table | Create Table
————————
| test | CREATE TABLE `test` (
`col_name` varchar(10) DEFAULT NULL,
FULLTEXT KEY `keyname` (`col_name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
If FULLTEXT is setup, the output of the above command will display a line as follows:
FULLTEXT KEY `keyname` (`col_name`)

Now, remove “FULLTEXT” indexes from the table:

mysql> ALTER TABLE test DROP INDEX keyname;

Now, this table can be converted to InnoDB using the following command:

mysql> ALTER TABLE test ENGINE=InnoDB;
Query OK, 0 rows affected (0.04 sec)
Records: 0 Duplicates: 0 Warnings: 0

How to Install & compile Zend Guard Loader

How to Install & compile Zend Guard Loader

The Zend Guard Loader runs PHP scripts that are encoded with Zend Guard. The Zend Guard Loader is a PHP extension that runs outputs created by Zend Guard, which provides an easy way to encode, obfuscate and license PHP code via an Eclipse-based interface or from the command line.

The Guard Loader extension must be installed on each Web server that runs files that were encoded with, or use, Zend Guard licenses.
Note:

You can also use the Zend Optimizer that also includes the Guard Loader extension for code written in PHP 5.2. The Zend Optimizer is available as a free download from PHP Web Application Server – PHP Development tools – PHP Training – Zend.com.

The Zend Guard Loader translates encoded files to a format that can be parsed by the Zend Engine. This runtime process uses the Zend engine as a trigger to start the Zend Guard Loader component. Zend Guard is a separate product available from Zend that provides an easy way to encode, obfuscate and license PHP code via an Eclipse-based interface or from the command line. To view the API, click Zend Guard Loader.

To install it you need to follow the below mentioned steps:

# wget http://downloads.zend.com/guard/5.5.0/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
# tar -zxvf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
# cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so /usr/local/lib/php

Now after that open php.ini file and put a

zend_optimizer.optimization_level=15
zend_extension=/usr/local/lib/php/ZendGuardLoader.so
restart apache
php -v to check it will show as

# php -v
PHP 5.3.15 (cgi-fcgi) (built: Sep 17 2012 04:07:04)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
with the ionCube PHP Loader v4.2.2, Copyright (c) 2002-2012, by ionCube Ltd., and
with Zend Guard Loader v3.3, Copyright (c) 1998-2010, by Zend Technologies

Shell Fork Bomb Protection

Shell Fork Bomb Protection

This feature will prevent users with terminal access (SSH or Telnet) from using up the system’s resources and potentially crashing your web server via a malicious attack known as a fork bomb.
Fork bombs work by starting a cascade of small processes that duplicate themselves until the server’s resources are depleted. WHM includes this feature to protect your server against fork bombs.

To enable or disable shell fork bomb protection:

Click Enable Protection or Disable Protection.

After you have enabled shell fork bomb protection, the following limits are available to better protect the server:

Limit Option Description
200000 -c Limits the maximum size of core files created.
200000 -d Limits the maximum size of a process’s data segment.
200000 -m Limits the maximum resident set size.
100           -n Limits the maximum number of open-file descriptors.
8192       -s Limits the maximum stack size.
35          -u Limits the maximum number of processes available to a single user.
200000 -v Limits the maximum amount of virtual memory available for the process.

Note: The “u” option limits bash shell users (default for cPanel users) to 35 processes each.

VPS iptables rule limit is too low

VPS iptables rule limit is too low

You may come across with a "numiptent" error message while restarting iptables or whatever firewall (say csf) you have installed on your VPS. The error appear as follows:

The VPS iptables rule limit (numiptent) is too low (300/450) – stopping firewall to prevent iptables blocking all connections

There is a limit on the number of iptables packet filtering entries for a VPS and if the iptable rules added on a VPS exceeds the “numiptent” set, you will receive the given error message.

To make sure iptables works properly on a VPS, you need to increase the “numiptent” value in the VPS configuration file which is located at /etc/sysconfig/vz-scripts/veid.conf and have to restart the VPS.

Enable fuse on VPS – Openvz

Enable fuse on vps – openvz

In order to enable FUSE on VPS you need first confirm the FUSE module is enabled on Hardware node in which the vps is hosted.

Commands to enable FUSE on Hardware node ::
# modprobe fuse

Check module is loaded properly :
# lsmod | grep fuse
fuse

2. Enable FUSE for VPS :
# vzctl set vpsid –devnodes fuse:rw –save
==================
Reference : http://kb.parallels.com/en/4628

Failed to enter Container

Failed to enter Container

ISSUE: I am unable to enter into one of the vps inside virtuozzo node using “vzctl enter CTID” command. Getting the error “enter failed. Failed to enter container”.

root@virtuozzo# vzctl enter 1330
enter failed
Failed to enter Container 1330
root@virtuozzo#

REASON : VZFS symlinks of the Container private area to system and application templates are somehow corrupted.

FIX: Use the vzctl recover CTID option to re-write the original symlinks to the Container private area.

The vzctl recover command restores the original VZFS symlinks of the Container private area to the OS and/or application template(s) as they were at the time when the Container was created and/or when the application template(s) were added to the Container. This command does not deal with any user files on the Container:

root@virtuozzo# vzctl recover 1330
Optimizing Container private area…
vzquota : (warning) Quota is running for id 1330 already
Setting quota …
Container is mounted
Setup slm memory limit
Setup slm subgroup (default)
Container is unmounted
Recover OS template: redhat-el5-x86
Creating Container private area (redhat-el5-x86)
Recovering Container completed successfully
root@virtuozzo#

As per the parallels documentation the recover option doesn’t touch the user data files, so there is no problem of data missing.

Reference:

http://download.swsoft.com/virtuozzo/virtuozzo4.0/docs/en/lin/VzLinuxReference/387.htm
http://download.swsoft.com/virtuozzo/virtuozzo4.0/docs/en/lin/VzLinuxUG/258.htm

Cannot lock Container in Virtuozzo


Cannot lock Container in Virtuozzo

Cannot lock Container

vim /vz/lock/.lk

ps aux | grep ID

#check vzquota is running , kill the process

vzquota drop
==============================>
vzctl stop vpsid
vzquota drop vpsid
vzctl start vpsid

[root@server ~]# vzquota off VEID
[root@server ~]# vzquota on VEID
[root@server ~]# vzctl start VEID

How to install mod_limitipconn on cPanel


How to install mod_limitipconn on cPanel

limitipconn is a tool which is used to limit the number of connections per IP on our server. This tool can help in lowering the load on your server if someone connecting too many times from the same IP.

First we need to download the file.

#wget http://dominia.org/djao/limit/mod_limitipconn-0.23.tar.bz2

#tar -xjf mod_limitipconn-0.23.tar.bz2

#cd mod_limitipconn-0.23/

Now, we are compile the module into Apache using:

#/usr/local/apache/bin/apxs -cia mod_limitipconn.c

Update the httpd.conf file using this command:

#/usr/local/cpanel/bin/apache_conf_distiller –update

#/usr/local/cpanel/bin/build_apache_conf

Edit the file using vim or vi

vim /usr/local/apache/conf/mod_limitipconn.conf

Lets add in the following lines to the bottom of the file:

# Set a server-wide limit of 10 simultaneous downloads per IP,

# no matter what.

MaxConnPerIP 10

# This section affects all files under http://your.server/somewhere

MaxConnPerIP 3

# exempting images from the connection limit is often a good

# idea if your web page has lots of inline images, since these

# pages often generate a flurry of concurrent image requests

NoIPLimit image/*

# This section affects all files under /home/*/public_html

MaxConnPerIP 3

# In this case, all MIME types other than audio/mpeg and video*

# are exempt from the limit check

OnlyIPLimit audio/mpeg video

Now edit the file /usr/local/apache/conf/includes/pre_main_global.conf and add the following lines

Include “/usr/local/apache/conf/mod_limitipconn.conf”

Now restart apache

/scripts/restartsrv_httpd

You can check whether the module loaded or not using the following command.

/usr/local/apache/bin/httpd -M | grep limitipconn_module
/usr/sbin/httpd -t

Notes:

1) This module will not function unless mod_status is loaded and the
“ExtendedStatus On” directive is set.

2) Server-wide access restrictions and per-directory access restrictions
are computed separately. In the above example, if someone is
downloading 11 images from http://your.server/somewhere
simultaneously, they WILL be denied on the 11th download, because the
server-wide limit of 10 downloads is not affected by the per-directory
NoIPLimit. If you want to set global settings which can be overruled
by per-directory settings, you will need something like

# global per-directory settings here

# local per-directory settings here

3) If you are using any module based upon a quick handler hook (such as
mod_cache), mod_limitipconn will not be able to process any
per-directory configuration directives in time to affect the return
result of the other module. This is a technical limitation imposed
by Apache. In such a situation, you will have to use server-wide
configuration directives only.

Note that previous versions of mod_limitipconn did not allow any
server-wide configuration directives, and hence could not be used
with mod_cache at all. In other words, the present situation still
represents an improvement over previous versions.

4) The limits defined by mod_limitipconn.c apply to all IP addresses
connecting to your Apache server. Currently there is no way to set
different limits for different IP addresses.

5) Connections in excess of the limit result in a stock 503 Service
Temporarily Unavailable response. The job of returning a more useful
error message to the client is left as an exercise for the reader.

6) mod_limitipconn sets the LIMITIP environment variable to 1 whenever a
download is denied on the basis of too high an IP count. You can use
this variable to distinguish accesses that have been denied by this
module. For example, a line like

CustomLog /var/log/httpd/access_log common env=!LIMITIP

in httpd.conf can be used to suppress logging of denied connections
from /var/log/httpd/access_log. (Note that, if you really want to
suppress logging, you’ll probably also want to comment out the
ap_log_rerror lines from mod_limitipconn.c as well.)

7) By default, all clients behind a proxy are treated as coming from the
proxy server’s IP address. If you wish to alter this behavior,
consider installing mod_extract_forwarded from

Tomcat 5 Installation on cPanel server and upgarde to Tomcat 7 


Tomcat 5 Installation on cPanel server and upgarde to Tomcat 7 

To install Tomcat, select the Tomcat option in WHM’s EasyApache (Apache Update) or using
“/scripts/easyapache” (without the quotes) in command line. The Tomcat selection is found in
Step 5’s Apache Options area.

It will install Tomcat 5.5.35 on the server.
Steps to upgrade Tomcat to version 7.0.32 are given below.

1) The Tomcat 5 is installed in /usr/local/jakarta/ directory with the symbolic link tomcat. For
example:

[~]# ll /usr/local/jakarta
drwxr-xr-x 4 tomcat nobody 4096 Apr 5 17:15 ./
drwxr-xr-x 22 root root 4096 Mar 5 15:39 ../
drwxr-xr-x 12 tomcat nobody 4096 Apr 4 17:02 apache-tomcat-5.5.35/
lrwxrwxrwx 1 tomcat nobody 39 Apr 4 17:04 tomcat -> /usr/local/jakarta/apache-tomcat-5.5.35/

2) Then download and extract Tomcat 7 in /usr/local/jakarta directory
[~]# cd /usr/local/jakarta
[/usr/local/jakarta]# wget http://apache.techartifact.com/mirror/tomcat/tomcat-7/v7.0.32/bin/apache-tomcat-7.0.32.tar.gz
[/usr/local/jakarta]# tar -xzvf apache-tomcat-7.0.32.tar.gz
[/usr/local/jakarta]# chown -R tomcat.nobody apache-tomcat-7.0.32/

3) Then Change the tomcat symbolic link to point to your new version (i.e.
/usr/local/jakarta/apache-tomcat-7.0.32)
[/usr/local/jakarta]# rm -rf tomcat
[/usr/local/jakarta]# ln -s /usr/local/jakarta/apache-tomcat-7.0.32 tomcat
[/usr/local/jakarta]# chown -h tomcat.nobody tomcat

4) Then compile the new Tomcat version on cPanel server.
[~]# cd /usr/local/jakarta/apache-tomcat-7.0.32
[/usr/local/jakarta/apache-tomcat-7.0.32]# cd ./bin
[/usr/local/jakarta/apache-tomcat-7.0.32/bin]# tar xvfz commons-daemon-native.tar.gz
[/usr/local/jakarta/apache-tomcat-7.0.32/bin]# cd commons-daemon-1.0.10-native-src/unix
[/usr/local/jakarta/apache-tomcat-7.0.32/bin/commons-daemon-1.0.10-native-src/unix]
[~]# ./configure
[~]# make
[~]# cp jsvc ../..
[~]# cd ../../..

5) Copy over any Host blocks from /usr/local/jakarta/tomcat/conf/server.xml from the old Tomcat install to the new Tomcat install (you may or may not be able to set up new hosts through WHM).

6) Copy over /usr/local/jakarta/tomcat/conf/workers.properties from the old Tomcat install to the new Tomcat install.

7) To use the web administration gui you have to add the gui role in /usr/local/jakarta/apache-
tomcat-7.0.32/conf/tomcat-users.xml file.
<tomcat-users>
<role rolename="admin"/>
<role rolename="admin-gui"/>
<role rolename="manager"/>
<role rolename="manager-gui"/>
<user username="name" password="pwd" roles="admin,admin-gui,manager,manager-gui"/>
</tomcat-users>

You may copy and paste the above code into the tomcat-users.xml file and change the "name"
and "pwd" fields accordingly.

[/usr/local/jakarta/apache-tomcat-7.0.32/conf]#ls -l
-rw------- 1 tomcat nobody 6818 Oct 11 02:04 server.xml
-rw------- 1 tomcat nobody 1734 Oct 9 13:10 tomcat-users.xml
-rw------- 1 tomcat nobody 5563 Oct 9 12:25 workers.properties

8) Restart the server
[/]# reboot
Or
[/]# /usr/local/jakarta/tomcat/bin/shutdown.sh
[/]# /usr/local/jakarta/tomcat/bin/startup.sh
[/]# /etc/init.d/httpd restart

9) Check Tomcat Version
[/]# sh /usr/local/jakarta/tomcat/bin/version.sh

The cPanel EasyApache system makes it easy to recompile Apache with various add-ons and modules.

If you ever need your old Tomcat back just stop Tomcat, flip the tomcat symbolic link back to the old install, and restart Tomcat.