Friday, July 30, 2010

How to install jdk1.6 on 64 bit linux machine?

JDK (Java Development Toolkit) :

It is a bundle of software that you can use to develop Java based applications. Java Development Kit is needed for developing java applications.

JRE (Java Runtime environment) :

It is an implementation of the Java Virtual Machine which actually executes Java programs. Java Run Time Environment is a plug-in needed for running java programs.

Here are the steps those I followed :

=======================
1. wget http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/VerifyItem-Start/jdk-6u21-linux-x64.bin?BundledLineItemUUID=YeSJ_hCxIl0AAAEqJYBp5yJ3&OrderID=luWJ_hCxQbYAAAEqDYBp5yJ3&ProductID=xKiJ_hCySHIAAAEpT7wzBGsB&FileName=/jdk-6u21-linux-x64.bin

Note : You can get the .bin file from the sun.com's site. Oracle is now the owner of sun. You can search the "download + jdk-6u21-linux-x64.bin" in google to get the binary.

2. chmod +x above_bin_file
3. ./above_bin_file
4. Now you'll see RPM file of JDK. So, execute the following command to install it:
----
root@server [/usr/local/src]# rpm -Uvh jdk-6u21-linux-amd64.rpm
----
Here is the installation path :

64 bit Java: /usr/java/64/ or /usr/java... (or /opt/java/64/...)
32 bit Java: /usr/java/... (or /opt/java/...)

4. Added JAVA_HOME path like :
root@server [/]# grep JAVA_HOME ~/.bash_profile
JAVA_HOME=
root@server [/]#
and

root@server [/]#export PATH=$PATH:/usr/java/64/jdk1.6.0_21/bin

root@server[/]# grep jdk ~/.bash_profile
JAVA_HOME=/usr/java/64/jdk1.6.0_21
export PATH=$PATH:/usr/java/64/jdk1.6.0_21/bin
You can do like :

echo "JAVA_HOME=/usr/java/jdk1.6.0_21" >> ~/.bash_profile
echo "export PATH=$PATH:/usr/java/jdk1.6.0_21/bin" >> ~/.bash_profile

6. Check the path(You may logout and login into the server) :

root@fre [/]# echo $JAVA_HOME
/usr/java/64/jdk1.6.0_21
root@server[/]
=======================

That's it. Try :)

How to install RMS(Ray Media Server) server on 64 bit linux machine?

Here are the steps those I followed :

====================
cd /usr/local
mkdir RMS
cd RMS
wget http://get.boonex.com/RMS-LINUX-v.7.0
tar xzvf RMS-LINUX-v.7.0

Steps for configuring RMS :

1. access.dat – input all domain names which will be allowed to access RMS. Every domain name should be written on a separate line and should not contain "http://" and "www", just yourdomain.com;
2. .in red5.sh (UNIX only) – set the value for JAVA_HOME variable. It should be the path to the folder where JRE is installed. For example:
JAVA_HOME=/opt/ray_server/jre1.x; or /usr/local/jdk_1.6.0 or /usr/java/jdk1.6.0_05

Note : java might not be installed on the server. I have published another article about the jdk installation and you can get help from there.

3. in run_daemon.sh (UNIX only) – set the value for RAY_SERVER_PATH variable. It should be the path to the RMS folder on your server. For example:

RAY_SERVER_PATH=/opt/ray_server; in my case RAY_SERVER_PATH=/usr/local/src/RMS_7.0

4. change the IP addresses in the files located in

path_to_rms/webapps/widget_name/WEB-INF/red5-web.properties

where "path_to_rms" stands for path to your Ray Media Server folder, and "widget_name" stands for board, chat, im, video and global ("global" is only for 3.5 version). For example: open

/opt/ray_server/webapps/chat/WEB-INF/red5.properties or /usr/local/src/RMS_7.0/webapps/chat/WEB-INF/red5-web.properties and replace the following line:

webapp.virtualHosts=0.0.0.0 with webapp.virtualHosts=server ip address
5. RMS Test launch: ./red5.sh
6. RMS runtime : ./run_daemon.sh
7. set the following lines in /etc/rc.local
cd /usr/local/src/RMS_7.0
./run_daemon.sh &
======================

That's it try :)

Thursday, July 29, 2010

How to upgrade lite speed webserver from the version 4.0.15 Ente to 4.1RC3-ent?

Guys,

I have referred the following steps as per the discussion with lite speed tech.

=====
Manual update:
cd /usr/local/src
wget http://www.litespeedtech.com/packages/4.0/lsws-4.1RC3-ent-x86_64-linux.tar.gz
tar zxvf lsws-4.1RC3-ent-x86_64-linux.tar.gz
cd lsws-4.1RC3
./install.sh

specify same installation folder as previous one, for example,
/usr/local/lsws
select U(upgrade), just press enter and proceed further. Also restart the service.

It's quite safe. Then in admin console, you can see 4.1RC3, 4.0.15.
switch between version by one-click.

Important : You don't need to rebuild the php with the this latest version of lsws.
=====

Note : Here are links of sources files :

====
For : i386-std package(32 bit)
http://www.litespeedtech.com/packages/4.0/lsws-4.1RC3-std-i386-linux.tar.gz

For : i386-ent package (32 bit)

http://www.litespeedtech.com/packages/4.0/lsws-4.1RC3-ent-i386-linux.tar.gz
For : x86_64-ent package(64 bit)

http://www.litespeedtech.com/packages/4.0/lsws-4.1RC3-ent-x86_64-linux.tar.gz
====

Try :)

Tuesday, July 27, 2010

ERROR: Failed to find flength ?

Guys,

Just add the following directives in the htaccess file.

=====

# Turn off mod_security filtering.
SecFilterEngine Off

# The below probably isn't needed,
# but better safe than sorry.
SecFilterScanPOST Off

=====

If the above method does not work, try putting the following lines into the
file

=====

SetEnvIfNoCase Content-Type \
"^multipart/form-data;" "MODSEC_NOPOSTBUFFERING=Do not buffer file uploads"



mod_gzip_on No

=====

Another options :

1. Disable the particular line for phpmotion script:
you can change the text "ERROR: Failed to find flength" file in ,cgi-bin/uu_ini_status.pl

or

make it on : my $flength_file_exists = 1;


try :)

Thursday, July 22, 2010

How to install phpshield on 32 or 64 bit linux machine?

Guys,

phpSHIELD protects your PHP Source Code with a powerful, easy to use encoder, which creates a native bytecode version of the script and then encrypts it. It's needed to video script enabled sites.


Here are the steps those I have followed :

===========
1. Check the architecture of your machine. like :

root@j [~]# arch
x86_64
root@j [~]#
It's 64bit
or :
root@juggernaut [~]# which ps
/bin/ps
root@j [~]# file /bin/ps |grep bit
/bin/ps: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped
root@j [~]#

2. Make sure following parameters has appropriate value in php.ini file like :

# Thread Safety is disabled
# enable_dl is set to on
# The path to your extension_dir
# Path to your php.ini file

php.ini file path :

root@j [~]# php --ini
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File: /usr/local/lib/php.ini
Scan for additional .ini files in: /usr/local/lib/php.ini.d
Additional .ini files parsed: (none)
root@j [~]#

3. Execute following CMD via ssh:
# mkdir ~/phpshield
# cd ~/phpshield

4. Download the phpSHIELD loaders:

# wget http://phpshield.com/loaders/phpshield.loaders.linux.zip //for 32bit machine
# wget http://phpshield.com/loaders/phpshield.loaders.linux-64.zip //for 64 bit

5. #unzip phpshield.loaders.linux.zip
6. #cp phpshield.5.2.lin /usr/lib/php/extensions/no-debug-non-zts-20060613/
7. Add following line in php.ini file and restart webserver :

extension="phpshield.5.2.lin"
echo "extension="phpshield.5.2.lin"" >> /usr/local/lib/php.ini

or

extension="phpshield.5.2ts.lin"
===========

That's it. try :)

Wednesday, July 21, 2010

How to install RVsitebuilder with cpanel on linux server?

Guys,

Here are the steps those I have followed :)

SSH into the server :

=========
cd /usr/local/cpanel/whostmgr/docroot/cgi/
rm -rf /usr/local/cpanel/whostmgr/docroot/cgi/rvsitebuilderinstaller/
rm -f rvsitebuilderinstaller.tar
wget http://download.rvglobalsoft.com/rvsitebuilderinstaller.tar
tar -xvf rvsitebuilderinstaller.tar
chmod 755 addon_rvsitebuilder.cgi
rm -f rvsitebuilderinstaller.tar
=========

Note : If CGI directory is not present you can create it.

Then access login into WHM >>Plugins>>RVSiteBuilder Installer >>click next>>enter license key and proceed further.

That's it. Try :)

Tuesday, July 20, 2010

How to install suPHP on linux server?

Guys,

This is not my article. However, I have searched it in Google and got the results. I am pasting it only so that you can easily get it.

=======================================
suPHP is a tool that allows PHP scripts to be executed with the permissions of their owners. By not running PHP script using web server’s user rights, suPHP increase the server security.

First install httpd-devel and compiler tools:
yum install httpd-devel gcc gcc-c++ make
Download suPHP source code and extract it
wget http://www.suphp.org/download/suphp-0.7.1.tar.gz
tar -xvzf suphp-0.7.1.tar.gz
cd suphp-0.7.1
Now we compile suPHP
./configure --with-apxs=/usr/sbin/apxs --with-apache-user=apache --with-logfile=/var/log/httpd/suphp_log --with-setid-mode=paranoid --sysconfdir=/etc --with-apr=/usr/bin/apr-1-config --with-php=/usr/bin/php-cgi --enable-SUPHP_USE_USERGROUP=yes

make
make install
Next create suphp.conf to configure Apache so it will call suPHP for interpreting PHP scripts
nano /etc/httpd/conf.d/suphp.conf
Add this configuration:
LoadModule suphp_module modules/mod_suphp.so
suPHP_Engine on
AddType application/x-httpd-php .php

suPHP_AddHandler application/x-httpd-php

Save the file and the next step is to disable mod_php configuration as we are now using suPHP
mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.disabled
After we finished with Apache configuration, next we create suphp.conf file which contain suPHP configuration
nano /etc/suphp.conf
and copy this to the new file:
[global]
;Path to logfile
logfile=/var/log/suphp.log

;Loglevel
loglevel=info

;User Apache is running as
webserver_user=apache

;Path all scripts have to be in
docroot=/var/www:${HOME}/public_html

;Path to chroot() to before executing script
;chroot=/mychroot

; Security options
allow_file_group_writeable=false
allow_file_others_writeable=false
allow_directory_group_writeable=false
allow_directory_others_writeable=false

;Check wheter script is within DOCUMENT_ROOT
check_vhost_docroot=true

;Send minor error messages to browser
errors_to_browser=false

;PATH environment variable
env_path=/bin:/usr/bin

;Umask to set, specify in octal notation
umask=0077

; Minimum UID
min_uid=0

; Minimum GID
After Apache and suPHP is configured, we need to add suPHP_UserGroup option on each virtual hosting we hosted on the server. For example, the domain.com virtual host would look like:

DocumentRoot /home/user/public_html

allow from all
Options +Indexes

ServerName domain.com
ErrorLog /var/log/httpd/domain.com
LogLevel warn
suPHP_UserGroup user user

"user" should be replaced with the real username on your server who own the PHP scripts. Make sure all file owned by the "user" username otherwise you’ll get 500 error code (Internal Server Error).
Now let's test the configuration
service httpd configtest
if everything is OK, restart the Apache server
=======================================

Try :)

How to install mod_evasive(DDOS protection tool) on 64 bit linux machine?

Guys,

I have referred the following steps to install that modules :

========
cd /usr/local/src
wget http://www.sfr-fresh.com/unix/privat/mod_evasive_1.10.1.tar.gz
tar -zxvf mod_evasive_1.10.1.tar.gz
cd mod_evasive

For apache 2.0.x :

/usr/sbin/apxs -cia mod_evasive20.c //integrating with apache.

Then add these in httpd.conf :


DOSHashTableSize 3097
DOSPageCount 6
DOSSiteCount 100
DOSPageInterval 2
DOSSiteInterval 2
DOSBlockingPeriod 600



For apache 1.3.x :

/usr/local/apache/bin/apxs -cia mod_evasive.c //integrating with apache.

Then add this too httpd.conf


DOSHashTableSize 3097
DOSPageCount 6
DOSSiteCount 100
DOSPageInterval 2
DOSSiteInterval 2
DOSBlockingPeriod 600

========

That's it. Try :)

How to install APC(alternative php cache) on 64 bit linux? machine

Guys,

Here are the steps those I followed :

=========
#cd /usr/local/src
#wget http://pecl.php.net/get/APC-3.0.14.tgz
#tar -xzvf APC-3.0.14.tgz
#cd APC-3.0.14
#phpize
#./configure --enable-apc --enable-apc-mmap --with-apxs --with-php-config=/usr/bin/php-config
#make
#make test
#make install

The extension will be stored inside "/usr/lib/php/extensions/no-debug-non-zts-20060613/".

Now, find php.ini file like : #php --ini
Add the extension="apc.so" at the last in php.ini file and restart apache.
=========

Note : You can install latest APC. Just search in google like : download APC-3.

That's it. try :)

Sunday, July 18, 2010

How to install ImageMagick on linux?

Here are the steps that I have followed :

============
1.Check whether ImageMagick has been installed or not.
which convert or which montage like this or locate ImageMagick. Or rpm -qa |grep ImageMagic
2. yum install ImageMagick
3. Now check once again.
4. rpm -ql ImageMagic| more
5. rpm -qf /usr/local/bin/convert //to check the exact rpm which has used for this binary.
============

That's it. Try now :)

Friday, July 16, 2010

How to use ncftpget command to download files from remote server?

Guys,

Please make it sure that ncftp has been installed on the destination server. check it out like :

===
root@mixstream [~]# which ncftpget
/usr/bin/ncftpget
root@mixstream [~]# which ncftp
/usr/bin/ncftp
root@mixstream [~]#
===

If these are not there, please install it on the server.

Ref URL :
===
http://www.question-defense.com/2010/01/25/install-ncftp-ncftpget-ncftpput-using-yum-on-centos-linux-server
===

Now FTP to remote server to download files :

===
root@mixstream [~/migrated_via_ncftp]# ncftpget -T -R -v -u FTP_user -p FTP_PW IP_ADDRESS_of_remote_SERVER /root/migrated_via_ncftp /
===

Here : /root/migrated_via_ncftp is destination folder
/ is source folder
root@mixstream : Local machine

You can set it at screen:

Like :
1. #command : screen //Now execute this command.
2. now CTRL +A+D // to log out from screen
3. screen -ls //to see the session ID of the screen
4. To login into the screen : screen -r seesID
5. CTRL+D //to kill the screen and logout from there.

Try :)

Wednesday, July 14, 2010

How to install suPHP on centos linux OS?

Installing suPHP on Centos 5

suPHP is a tool that allows PHP scripts to be executed with the permissions of their owners. By not running PHP script using web server’s user rights, suPHP increase the server security.

First install httpd-devel and compiler tools:

-----
yum install httpd-devel gcc gcc-c++ make
-----
Download suPHP source code and extract it

----
wget http://www.suphp.org/download/suphp-0.7.1.tar.gz
tar -xvzf suphp-0.7.1.tar.gz
cd suphp-0.7.1
----
Note: source : http://www.suphp.org/Download.html

Now we compile suPHP :

----
./configure --with-apxs=/usr/sbin/apxs --with-apache-user=apache --with-logfile=/var/log/httpd/suphp_log --with-setid-mode=paranoid --sysconfdir=/etc --with-apr=/usr/bin/apr-1-config --with-php=/usr/bin/php-cgi --enable-SUPHP_USE_USERGROUP=yes

make
make install
----
Next create suphp.conf to configure Apache so it will call suPHP for interpreting PHP scripts

vi /etc/httpd/conf.d/suphp.conf
Add this configuration:

----
LoadModule suphp_module modules/mod_suphp.so
suPHP_Engine on
AddType application/x-httpd-php .php

suPHP_AddHandler application/x-httpd-php

----

Save the file and the next step is to disable mod_php configuration as we are now using suPHP :

---
mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.disabled
---

After we finished with Apache configuration, next we create suphp.conf file which contain suPHP configuration :

vi /etc/suphp.conf

----
[global]
;Path to logfile
logfile=/var/log/suphp.log

;Loglevel
loglevel=info

;User Apache is running as
webserver_user=apache

;Path all scripts have to be in
docroot=/var/www:${HOME}/public_html

;Path to chroot() to before executing script
;chroot=/mychroot

; Security options
allow_file_group_writeable=false
allow_file_others_writeable=false
allow_directory_group_writeable=false
allow_directory_others_writeable=false

;Check wheter script is within DOCUMENT_ROOT
check_vhost_docroot=true

;Send minor error messages to browser
errors_to_browser=false

;PATH environment variable
env_path=/bin:/usr/bin

;Umask to set, specify in octal notation
umask=0077

; Minimum UID
min_uid=0

; Minimum GID
----

After Apache and suPHP is configured, we need to add suPHP_UserGroup option on each virtual hosting we hosted on the server. For example, the domain.com virtual host would look like:

----

DocumentRoot /home/user/public_html

allow from all
Options +Indexes

ServerName domain.com
ErrorLog /var/log/httpd/domain.com
LogLevel warn
suPHP_UserGroup user user

----

Restart httpd. try :)

How to install Red5 (Ray Media server) on linux machine ?

Guys,

What is red5 server?

Red5 is an Open Source Flash Server written in Java that supports:

a)Streaming Audio/Video : flv, mp3, s4v,mp4,aac, m4a
b) Recording Client Streams (FLV only)
c) Shared Objects
d) Live Stream Publishing : Sorenson, VP6,h.264,Nelly Moser, MP3, Speex, AAC , NSV
e) Remoting

How does it work?

Red5 server converts the video file to the flash file and we everyone knows that flash files play instantly once someone accesses it. Here when we request or select a particular video, the video script will send the video(stream the video) to red5 server. Red5 will convert the video file to flash and sends the output to the video script to display on the browser. Lot of video scripts are being used now a days like dolphin, videowhisper etc for the site. You can configure the admin panel using the server's IP and port details.

You have the opportunity to test most of RED5 servers functions at this site. For example, webcam and audio/video streaming, clients webcam stream recording, live stream publishing, multi user video chat - you must be logged in as a site member to your account for testing.


Installation steps :

To install red5 on linux you need to install JDK and ANT first. I have already published two articles on jdk and ant. Here are those links.

------
http://kmaiti.blogspot.com/2010/07/how-to-install-jdk16021-on-64-bit-linux.html
http://kmaiti.blogspot.com/2010/08/how-to-install-apache-ant-on-linux.html
------

Once you successfully install jdk and ant then refer the following steps.

====
1. Download the Red5 tar from :
http://code.google.com/p/red5/
wget http://www.red5.org/downloads/0_9/red5-0.9.1.tar.gz
2. Make it untar:
tar -xvzf red5-0.9.1.tar.gz
3. copy content :
cd red5-0.9.1
mkdir /usr/local/red5
cp -apr * /usr/local/red5
4. Run red5 :
./red5.sh &
or
/usr/local/red5/red5.sh &
6. Add following line in /etc/rc.local
/bin/bash /usr/local/red/red5.sh &
OR run red5 server as a daemon:
./red5.sh >/dev/null 2>&1 & or nohup sh red5.sh &

7) Now test :
The RED5 installation by opening following URL in browser
http://server_ip:5080

ps : Red5 http service run on port 5080 and rtmp on port 1935.
====


Note :
Allow port 5080 and 1935 in the firewall.

Port and server details :

====
root@server [/usr/local/red5]# cat red5.properties
# HTTP
http.host=0.0.0.0
http.port=8080
# RTMP
rtmp.host=0.0.0.0
rtmp.port=1935
rtmp.event_threads_core=16
rtmp.event_threads_max=32
# event threads queue: -1 unbounded, 0 direct (no queue), n bounded queue
rtmp.event_threads_queue=-1
rtmp.event_threads_keepalive=60
rtmp.send_buffer_size=271360
rtmp.receive_buffer_size=65536
rtmp.ping_interval=5000
rtmp.max_inactivity=60000
# RTMPT
rtmpt.host=0.0.0.0
rtmpt.port=8080
rtmpt.ping_interval=5000
rtmpt.max_inactivity=60000
# Debug proxy (needs to be activated in red5-core.xml)
proxy.source_host=127.0.0.1
proxy.source_port=1936
proxy.destination_host=127.0.0.1
proxy.destination_port=1935
====

Try :)

WHM + http showing failed ?

Guys,

Please check the log of the apache server like :

1. tail -f /usr/local/apache/logs/error_log
2. check the http port in /usr/local/apache/conf/httpd.conf
3. Check MaxClients in /usr/local/apache/conf/httpd.conf. Just grep it in log.

In WHM, http was displaying failed. I got the following error message in apache log.

=====
[Tue Jul 13 22:48:38 2010] [error] [client 122.181.3.130] ModSecurity: Access denied with code 501 (phase 2). Match of "rx ^((?:(?:POS|GE)T|OPTIONS|HEAD))$" against "REQUEST_METHOD" required. [file "/usr/local/apache/conf/modsec2.user.conf"] [line "38"] [id "960032"] [msg "Method is not allowed by policy"] [severity "CRITICAL"]
=====

Please go to the 38th line and disable the rules. Then restart the apache. It'll work :) try

Tuesday, July 13, 2010

WHM + http showing failed ?

Guys,

Please check the log of the apache server like :

1. tail -f /usr/local/apache/logs/error_log
2. check the http port in /usr/local/apache/conf/httpd.conf
3. Check MaxClients in /usr/local/apache/conf/httpd.conf. Just grep it in log.

In WHM, http was displaying failed. I got the following error message in apache log.

=====
[Tue Jul 13 22:48:38 2010] [error] [client 122.181.3.130] ModSecurity: Access denied with code 501 (phase 2). Match of "rx ^((?:(?:POS|GE)T|OPTIONS|HEAD))$" against "REQUEST_METHOD" required. [file "/usr/local/apache/conf/modsec2.user.conf"] [line "38"] [id "960032"] [msg "Method is not allowed by policy"] [severity "CRITICAL"]
=====

Please go to the 38th line and disable the rules. Then restart the apache. It'll work :) try

Monday, July 12, 2010

How to Install confluence wiki on linux server(64 bit) + mysql database configuration error

Guys,

I have referred following URL to install the confluence wiki on linux(64 bit).

=====
http://confluence.atlassian.com/display/DOC/Installing+Confluence+Standalone+on+UNIX+or+Linux
=====

Regarding the DB setting you can refer the following URL :

====
http://confluence.atlassian.com/display/DOC/Database+Setup+For+MySQL

NB: You need to create one db user and db password. Just give grant privileges to the "confluence" db or customized DB that you had manually created.

====
http://confluence.atlassian.com/display/DOC/Configuring+a+MySQL+Datasource+in+Apache+Tomcat
====

Here are the error messages that I had received during configuring the DB at the browser.

====
* Configuring the database failed. Couldn't create the database schema.
* com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:
Could not create connection to database server. Attempted reconnect 3 times.
Giving up
====

Sol : 1. The error is basically happened for mismatching of DB engine.
2. checked the DB engine at the backend like mysql# show variable like "%engine%";
3. Now you'll see the URL to connect the DB via jdbc driver like :
jdbc:mysql://localhost/confluenceuser?autoReconnect=true&sessionVariables=storage_engine%3DInnoDB

4. For my case DB engine was MyIsAm at mysql.
5. I setup the following URL :
jdbc:mysql://localhost/confluenceuser?autoReconnect=true&sessionVariables=storage_engine%3DMyIsAm
6. Then I proceeded further and I had successfully installed the software.

Try :)

Sunday, July 4, 2010

How to repair a corrupt MBR on linux machine?

Here are the steps:

========
1. Incert CD and boot from cd(you have to change the option at BIOS).
2. boot: linux rescue //command while boot prompt comes
3. chroot /mnt/sysimage //command
4. grub-install /dev/hda //command
5. reboot the machine.
========

That's it. try :)

How to take backup/restore of MBR with dd command?

The MBR is located in the first 512 bytes of the disk (the first sector).

Size (bytes) Description
446 Executable code section
4 Optional Disk signature
2 Usually nulls
64 Partition table
2 MBR signature

1. backup : execute following command

dd if=/dev/hda of=/mbrbackup.bin bs=512 count=1

2. Restore :

dd if=/mbrbackup.bin of=/dev/hda bs=512 count=1

Try it now :)

Saturday, July 3, 2010

How to check mysql slow queries or which queries are consuming cpu resources?

1. vi /etc/my.cnf and add following entries after mysqld.
[mysqld]
set-variable=long_query_time=1
log-slow-queries=/var/log/mysql/log-slow-queries.log

2. Perform following steps:
mkdir /var/log/mysql
touch /var/log/mysql/log-slow-queries.log
chown mysql.mysql -R /var/log/mysql
3. Restart mysql. /etc/init.d/mysqld restart
4. Now you can use mysqlsla tool to check the slow queries. Here are the steps.
cd /usr/src
wget http://hackmysql.com/scripts/mysqlsla-2.03.tar.gz
tar -xvzf mysqlsla-2.03.tar.gz
cd mysqlsla-2.03/bin
5. Execute following command :
./mysqlsla -lt slow --sort t_sum --top 5 /var/log/mysql/mysqld.slow

Now you'll able to see the results :) Contact developer to optimize the code.
optimize command is used to optimize the table. Here it is:
mysql>optimize table table_name;

check whether slow log has enabled or not.

mysql> SHOW VARIABLES like "%slow%"; //if not
mysql> SET @log_slow_queries=1;

Again restart mysql and use above tool after few minutes to check log.

Try :)