Tuesday 29 May 2012

Sar/SysStat Installation and configuration


Sar/SysStat Installation and configuration
=================================

yum install sysstat

Then check the file /etc/cron.d/sysstat .  It should be as given below :

# run system activity accounting tool every 10 minutes
*/10 * * * * root /usr/lib64/sa/sa1 1 1
# generate a daily summary of process accounting at 23:53
53 23 * * * root /usr/lib64/sa/sa2 -A


Permission of this file should be 644, other wise you will get the following error in cron log.

==============
 (*system*) BAD FILE MODE (/etc/cron.d/sysstat)
==============

Another possible error is,

Cannot open /var/log/sa/sa28: No such file or directory

This file will be automatically created after 10 minutes. For testing this, you can execute the following command, which will save the current details.

root /usr/lib64/sa/sa1 1 1

Monday 28 May 2012

MySQL database repair - myisamchk

Hi,

To check/repair MySQL database which using the database engine MyISAM, we can use the command "myisamchk" . Syntacx is as given below :

 To check the status :

myisamchk /var/lib/mysql/DATABASE_NAME/*.MYI

This will displays the tables that should be repaired.

To repair the whole database,

myisamchk --silent --force --fast --update-state /var/lib/mysql/DATABASE_NAME/*.MYI

To repair a single table:

myisamchk -r /var/lib/mysql/DATABASE_NAME/TABLE_NAME.MYI


Saturday 19 May 2012

NameServer IPSs shows wrong in WHM

Hi,

Sometimes we can see that NameServers IPs in WHM shows wrong values,
Fix :
Check the file /etc/nameserverips and make sure that it shows as given below :

IPADDRESS1=ns1.example.com
IPADDRESS2=ns2.example.com

Example : 

192.168.1.1=ns1.example.com
192.168.1.2=ns1.example.com


If no, then edit the file and check the Name server IPs in WHM again. If yes, then execute the following script :
/scripts/updatenameserverips


Check Name server IPs in WHM again and if the issue persists then please edit the following file :
/var/cpanel/nameserverips.yaml
It should be as given below :

---
ns1.example.com:
 "192.168.1.1": 1
  count: '1'
  zones: example.com
ns2.example.com:
  "192.168.1.2": 1
  count: '1'
  zones: example.com

Installing suPHP


Installing suPHP

1) Download and extract the package : wget http://www.suphp.org/download/suphp-0.6.1.tar.gz

2) ./configure --prefix=/usr/suphp1 --sysconfdir=/etc --with-apache-user=apache --with-setid-mode=paranoid --with-apxs=/usr/local/apache2/bin/apxs --with-apr=/usr/local/apache2/bin/apr-1-config

3) make

4) make install

5) cp /root/software/php/suphp-0.6.1/doc/suphp.conf-example /usr/local/etc/suphp.conf

After that we need to load the suPHP module in httpd.conf file. To do this, we need to add the following lines :

LoadModule suphp_module modules/mod_suphp.so
AddHandler x-httpd-php .php
AddType application/x-httpd-php-source .phps

Once we loaded the modules, we can create the virtual host entries.

Example :

<VirtualHost 192.168.0.57>
ServerName www.example.com
ServerAdmin webmaster@example.com
DocumentRoot /home/www

suPHP_Engine on
suPHP_UserGroup www www
AddHandler x-httpd-php .php .php3 .php4 .php5
suPHP_AddHandler x-httpd-php

<Directory "/home/www">
Allow from all
</Directory>
</VirtualHost>

MySQL 5.5 Installation from source


Installation of MySQL :

1) Download and extract the package :


2) shell> cmake .

3) shell> make

4) make install

End of source-build specific instructions

Post-installation setup
----------------------------------
1) cd /usr/local/mysql
2) chown -R mysql .
3) chgrp -R mysql .
4) scripts/mysql_install_db --user=mysql
5) chown -R root .
6) chown -R mysql data


#Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf

To start MySQL
-------------------------
bin/mysqld_safe --user=mysql &

#Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

Once we done this, we can start MySQL using the command “/etc/init.d/mysql.server start” .  

Thursday 17 May 2012

Change collation of MySQL database

Hi,

Please use the following PHP script to change the collation of MySQL databases.

=============================
<?php
$db = mysql_connect('localhost','myuser_mydbuser','mypassword');
if(!$db) echo "Cannot connect to the database - incorrect details";
mysql_select_db('myuser_mydbname'); $result=mysql_query('show tables');
while($tables = mysql_fetch_array($result)) {
foreach ($tables as $key => $value) {
mysql_query("ALTER TABLE $value COLLATE utf8_general_ci");
}}
echo "The collation of your database has been successfully changed!";
?>


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


Replace the necessary fields.


Tuesday 8 May 2012

Convert InnoDB TO MyISAM Script

Hi,

To convert InnoDB to MyISAM, you can use the following script. This is applicable for a single database. Stop Apache before doing this.

=======================
 #/bin/bash
#script to convert the whole database to myisam format.
cp -iRfp /var/lib/mysql /var/lib/mysql-$(date +%s)
for DATABASE_NAME in $(mysql --batch --column-names=false -e "show databases");
do
for t in $(mysql --batch --column-names=false -e "show tables" $DATABASE_NAME);
do
mysql -e "alter table $t type=MyIsam" $DATABASE_NAME;
echo "converted "$t" to MyIsam"
done
done 
========================

Thanks.