Improve Your Website Performance

This article is a through version for improving website performance. I have tested and configured many websites.

1. Enable gzip compression:

Add mod_deflate.conf at /etc/httpd/conf.d/

LoadModule deflate_module modules/mod_deflate.so

# compress text, html, javascript, css, xml:

AddOutputFilterByType DEFLATE text/plain

AddOutputFilterByType DEFLATE text/html

AddOutputFilterByType DEFLATE text/xml

AddOutputFilterByType DEFLATE text/css

AddOutputFilterByType DEFLATE application/xml

AddOutputFilterByType DEFLATE application/xhtml+xml

AddOutputFilterByType DEFLATE application/rss+xml

AddOutputFilterByType DEFLATE application/javascript

AddOutputFilterByType DEFLATE application/x-javascript

# Or, compress certain file types by extension:

<files *.html>

SetOutputFilter DEFLATE

</files>

 

2. Enable headers expires:

Add mod_expires.conf at /etc/httpd/conf.d/

LoadModule expires_module modules/mod_expires.so

# enable expirations

ExpiresActive On

ExpiresDefault “access plus 1 months”

 

3. Turn off ETTags:

LoadModule headers_module modules/mod_headers.so

Header unset ETag

FileETag None

If you face any problems installing or configuring, please let me know.

I will update the article.

Thanks

 

 

http://linuxdump.com/

 

Go Daddy Deal of the Week: Get Deluxe Web Hosting for just $5/mo! Offer expires 4/24/12
Posted in Linux | 2 Comments

Linux Logs List

The following are the 20 different log files that are located under /var/log/ directory. Some of these log files are distribution specific. For example, you’ll see dpkg.log on Debian based systems (for example, on Ubuntu).

1.  /var/log/messages – Contains global system messages, including the messages that are logged during system startup. There are several things that are logged in /var/log/messages including mail, cron, daemon, kern, auth, etc.

2.  /var/log/dmesg – Contains kernel ring buffer information. When the system boots up, it prints number of messages on the screen that displays information about the hardware devices that the kernel detects during boot process. These messages are available in kernel ring buffer and whenever the new message comes the old message gets overwritten. You can also view the content of this file using the dmesg command.

3.  /var/log/auth.log – Contains system authorization information, including user logins and authentication machinsm that were used.

4.  /var/log/boot.log – Contains information that are logged when the system boots

5.  /var/log/daemon.log – Contains information logged by the various background daemons that runs on the system

6.  /var/log/dpkg.log – Contains information that are logged when a package is installed or removed using dpkg command

7.  /var/log/kern.log – Contains information logged by the kernel. Helpful for you to troubleshoot a custom-built kernel.

8.  /var/log/lastlog – Displays the recent login information for all the users. This is not an ascii file. You should use lastlog command to view the content of this file.

9.  /var/log/maillog – Contains the log information from the mail server that is running on the system. For example, sendmail logs information about all the sent items to this file

10.  /var/log/user.log – Contains information about all user level logs

11. /var/log/Xorg.x.log – Log messages from the X

12. /var/log/alternatives.log – Information by the update-alternatives are logged into this log file. On Ubuntu, update-alternatives maintains symbolic links determining default commands.

13. /var/log/btmp – This file contains information about failed login attemps. Use the last command to view the btmp file. For example, “last -f /var/log/btmp | more”

14. /var/log/cups – All printer and printing related log messages

15. /var/log/anaconda.log – When you install Linux, all installation related messages are stored in this log file

16. /var/log/yum.log – Contains information that are logged when a package is installed using yum

17. /var/log/cron – Whenever cron daemon (or anacron) starts a cron job, it logs the information about the cron job in this file

18. /var/log/secure – Contains information related to authentication and authorization privileges. For example, sshd logs all the messages here, including unsuccessful login.

19. /var/log/wtmp or /var/log/utmp – Contains login records. Using wtmp you can find out who is logged into the system. who command uses this file to display the information.

20. /var/log/faillog – Contains user failed login attemps. Use faillog command to display the content of this file.

 

 

http://linuxdump.com/

Posted in Linux | Leave a comment

Mysql Cluster 7.2.5 On Cent OS 6 (From Scratch)

This article will take you through setting up MySql cluster. As we will be using mysql-cluster tar package, this guide should work with most distros, including fedora, ubuntu. I am testing cluster on centos 6.

For this you need 3 servers, two of which will work as storage cluster & one as management server.
cluster1 192.168.0.36 – management server
cluster2 192.168.0.37 – storage node 1
cluster3 192.168.0.38 – storage node 1

Disable SELinux | iptables | iptables6

Download Mysql-Cluster:
mysql-cluster-gpl-7.2.5-linux2.6-x86_64.tar.gz

Install MySQL on CLUSTER 2 & CLUSTER 3:

Adding mysql user and group:
groupadd mysql
useradd -g mysql mysql

cd /usr/local/
tar -zxvf /root/mysql-cluster-gpl-7.2.5-linux2.6-x86_64.tar.gz
mv mysql-cluster-gpl-7.2.5-linux2.6-x86_64 mysql-cluster
ln -s mysql-cluster mysql

cd /usr/local/mysql
scripts/mysql_install_db –user=mysql

 

Note: please make sure you install shared libraries: libaio with yum.

Change permissions:
chown -R root  .
chown -R mysql data
chgrp -R mysql .

init script:
cp support-files/mysql.server /etc/rc.d/init.d/
chmod +x /etc/rc.d/init.d/mysql.server
chkconfig –add mysql.server

We can check mysql server:
/etc/init.d/mysql.server start
/etc/init.d/mysql.server stop

Install and configure the management server ON CLUSTER 1:

tar -zxvf mysql-cluster-gpl-7.2.5-linux2.6-x86_64.tar.gz
cd mysql-cluster-gpl-7.2.5-linux2.6-x86_64
mv bin/ndb_mgm .
mv bin/ndb_mgmd .
chmod +x ndb_mg*
mv ndb_mg* /usr/bin/

We now need to set up the config file ON CLUSTER 1:

mkdir /var/lib/mysql-cluster
cd /var/lib/mysql-cluster

vi config.ini

[NDBD DEFAULT]
NoOfReplicas=2
[MYSQLD DEFAULT]
[NDB_MGMD DEFAULT]
[TCP DEFAULT]
# Managment Server
[NDB_MGMD]
HostName=192.168.0.36        # the IP of THIS SERVER
# Storage Engines
[NDBD]
HostName=192.168.0.37        # the IP of the FIRST SERVER
DataDir= /var/lib/mysql-cluster
[NDBD]
HostName=192.168.0.38    # the IP of the SECOND SERVER
DataDir=/var/lib/mysql-cluster
# 2 MySQL Clients
[MYSQLD]
[MYSQLD]

mkdir -p /usr/local/mysql/mysql-cluster

Now we can start the Management server:

ndb_mgmd -f /var/lib/mysql-cluster/config.ini

Configure the storage servers and start mysql ON CLUSTER 1 & CLUSTER 2:

vi /etc/my.cnf
[mysqld]
ndbcluster
ndb-connectstring=192.168.0.36    # the IP of the MANAGMENT (THIRD) SERVER
[mysql_cluster]
ndb-connectstring=192.168.0.36    # the IP of the MANAGMENT (THIRD) SERVER

Now, we make the data directory and start the storage engine:

mkdir /var/lib/mysql-cluster
cd /var/lib/mysql-cluster
/usr/local/mysql/bin/ndbd –initial
/etc/rc.d/init.d/mysql.server start

Now we check on cluster1:

ndb_mgm
show

 

Stop Cluster:
To stop cluster run shutdown command in ndb_mgm Console
On storage clusters /etc/init.d/mysql.server stop

Start Cluster:
Management Server – Cluster1
ndb_mgmd -f /var/lib/mysql-cluster/config.ini

On Storage Clusters 2 and 3:
/usr/local/mysql/bin/ndbd
/etc/init.d/mysql.server start

 

Test for Mysql Cluster:

ln -s /usr/local/mysql/bin/mysql /usr/bin/
ln -s /var/lib/mysql/mysql.sock /tmp/

On storage cluster 2 and check on cluster 3:
mysql -u root -p
mysql> use test;
mysql> CREATE TABLE ctest (i INT) ENGINE=NDBCLUSTER;

mysql> INSERT INTO ctest () VALUES (1);
mysql> SELECT * FROM ctest;

 

 

NOTE: PLEASE USE “ENGINE=NDBCLUSTER” OTHERWISE IT MAY NOT WORK.

Thank You….

If you face any other issues please let me know.

 

 

http://linuxdump.com/

Posted in Linux | Leave a comment

invoke-rc.d: unknown initscript, /etc/init.d/mysql not found

#sudo apt-get purge mysql-server-5.1

error : invoke-rc.d: unknown initscript, /etc/init.d/mysql not found.
dpkg: error processing mysql-server-5.1 (–remove):
subprocess installed pre-removal script returned error exit status 100
invoke-rc.d: unknown initscript, /etc/init.d/mysql not found.
dpkg: error while cleaning up:
subprocess installed post-installation script returned error exit status 100
Errors were encountered while processing:
mysql-server-5.1

#sudo touch /etc/init.d/mysql

#sudo apt-get purge mysql-server-5.1

#sudo apt-get install mysql-server-5.1

Now mysql-server- 5.1will install with no issues.

 

 

http://linuxdump.com

Posted in Linux | 2 Comments

Playing with mysql-server

Logging into mysql-server -

#mysql –u username –p db_name

 

To list all databases -

#show databases;

 

To create a database –

#create database db_name;

 

In the above image “Query OK” means that last command executed is correct.

To confirm run show databases to check your newly created db.

To use the newly created database –

#use db_name;

 

Others commands you can try –

#show tables;

#select * from table_name;

#quit (to quit mysql console)

 

http://linuxdump.com/

Posted in Linux | Leave a comment