Dec 20, 2011

Online LUN Detection in RHEL

Online LUN Detection in RedHat Enterprise Linux

Release:
RedHat Enterprise Linux

Problem:
Detect Newly assigned LUN in RHEL without reboot the server

Solution:

1)       Install the required packages

                                # yum install sysfsutils sg3_utils

2)       We need the below parameters to rescan the scsi bus

                                H – HBA Number
                                C – Channel on the HBA
                                T – SCSI target id
                                L – LUN id

3)       We can get the above said parameters using the different command, for me I am using “systool” and “sg_map” command

            # systool -c fc_host -v
           
            Class Device = "host3"
            Class Device path = "/sys/class/fc_host/host3"
            port_name = "0x2100001b32882e82"

Note : In the above sample output class device path is “host3”. So 3 is the HBA number, if dual channel HBA means like the above host4 also will displayed. Here port name is the HBA's wwn id.

            # systool -c fc_transport -v
           
            Class Device = "0:0"
            Class Device path = "/sys/class/fc_transport/target3:0:0"
            port_name = "0x200400a0b84889b5"
                               
Note: In the above command output, class device path is “3:0:0”, that is in the order of “HBA number:channel on HBA:SCSI Target id”  (H:C:T). Here port name is the storage's wwpn id.

            # sg_map -x

            /dev/sg0  0 0 0 0  0
            /dev/sg1  0 0 1 0  0
            /dev/sg2  0 1 0 0  0  /dev/sda
            /dev/sg3  3 0 0 0  0
            /dev/sg4  3 0 0 31  0
            /dev/sg5  3 0 1 0  0  /dev/sdb
            /dev/sg6  3 0 1 1  0  /dev/sdc
            /dev/sg7  3 0 2 0  0  /dev/sdd
            /dev/sg8  3 0 2 1  0  /dev/sde
                                           
Note: In the above command output, first four digits as represents “H C T L” also known as Host, Bus, Target, Lun  (H B T L). From this we can identify how many luns are already mapped.

4)       Now rescan the SCSI bus using the said parameters

                                # echo “C T L” > /sys/class/scsi_host/HostH/scan

Note: If u are having dual channel HBA card means scan both the HBA numbers using the above command .

5)       Now check with the fdisk command, whether the LUN is detected or  not. If not means use the below command

                                # echo “1” > /sys/class/fc_host/hostH/issue_lip

Note: The above command instruct the driver to rediscover the remote ports. LIP (Loop Initialization  Protocol).

6)       Now confirm with the fdisk command and use the LUN as usual.





Dec 10, 2011

GZIP Compression in Apache


GZIP Compression in Apache Webserver

Introduction:

            The mod_deflate module provides the DEFLATE output filter that allows output from your server to be compressed before being sent to the client over the network.
            The mod_deflate module does not have a lower bound for file size, so it attempts to compress files that are too small to benefit from compression. This results in files smaller than approximately 120 bytes becoming larger when processed by mod_deflate.

Release:
RedHat Enterprise Linux
Apache Webserver 2.x

Problem:
Need to enable the gzip compression in the apache webaserver using the mod_deflate module.

Solution:

1)       Make sure that mod_deflate module is loaded in the configuration file
2)       Mention what type of files gets compressed in the http configuration file

            BrowserMatch ^Mozilla/4 gzip-only-text/html
            BrowserMatch ^Mozilla/4\.0[678] no-gzip
            BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

3)       Add the exception using the blow syntax

            SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
            SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary

Note: The above two lines mention that don't compress the image files (gif,jpe and png) and the pdf files. Like the above syntax we can exclude any other format.

4)       If u want to enable the seperate log for the gzip compression use the blow entries in the http configuration file.

            <IfModule mod_deflate.c>
            DeflateFilterNote Input inputstream
            DeflateFilterNote Output outputstream
            DeflateFilterNote Ratio ratiostream
            LogFormat '"%r" %{outputstream}n/%{inputstream}n (%{ratiostream}n%%)' deflate
            </IfModule>        

Note: In the log, how much the pages are compressed information available.

5)       Restart the http service to take the changes effect.

                        # service httpd restart






Dec 1, 2011

Webalizer Configuration in Linux


Webalizer Configuration for apache in Linux

Introduction:
            The Webalizer is a GPL application that generates web pages of analysis, from access log. It is simple to configure and easy to run.
           
Release:
RedHat Enterprise Linux

Problem:
Need to monitor the webserver hits using webalizer.

Solution:

1)    Install the webalizer rpm

                        # yum install webalizer

2)    Mention the webserver log path in the webalizer configuration file

            # vi /etc/webalizer.conf

            LogFile         /etc/httpd/logs/access_log.2.gz
            OutputDir       /opt/webalizer_apache
            Incremental     yes
            IncrementalName webalizer.current

Note: For my webserver i used logrotate to rotate all my logs. So i mentioned the rotated log file to update the hits. We can mention any webserver access log file (if you didn't have logrotate "/etc/httpd/logs/access_log" will be your default log location of apache webserver). "Incremental"  keyword allows to rotate the logs.

3)    Logrorate script used by me is

            # vi /etc/logrotate.d/apache

            /etc/httpd/logs/*log {
            missingok
            daily
            rotate 20
            compress
            notifempty
            sharedscripts
            postrotate
            /bin/kill -HUP `cat /etc/httpd/logs/httpd.pid 2>/dev/null` 2> /dev/null || true
            endscript
            }

Note: If  you want to know more about logrotate refer http://linuxnextgen.blogspot.com/2011/04/logrotate-in-linux.html.

4)    Log rotate will rotate the logs in every day morning. So i put one cron entry to update the webserver hits  in the daily basics.

            # crontab -e

            4 30 * * * /usr/local/bin/webalizer -c /etc/webalizer.conf

5)    In that output directory “index.html” file will be there using that we can browse webserver hits history
6)    Or we can add the webalizer output directory to the webserver “Document Root” by creating one symbolic link.

            # ln -s /opt/webalizer_apache /var/www/html/webalizer_apache

Note: Here “/var/www/html” is my “Document Root” in apache web server.

7)    Now we can access the webalizer page from the webserver itself by using the below URL

                        http://ServerIPAddress/webalizer_apache