Showing posts with label rhel. Show all posts
Showing posts with label rhel. Show all posts

Jan 17, 2012

Reverse Proxy in apache

Reverse Proxy Configuration in apache

Introduction:

            A reverse proxy is a gateway for servers, it can be used whenever multiple web servers must be accessible via a single public IP address. The web servers listen on different ports in the same machine, with the same local IP address or, possibly, on different machines and different local IP addresses altogether. The reverse proxy analyses each incoming call and delivers it to the right server within the local area network.

Release:
RedHat Enterprise Linux
Apache 2.x

Problem:
Configure Apache webserver as a reverse proxy server

Solution:

1)       Install the required rpm

            # yum install httpd

2)       Enable the proxy related modules in the httpd,conf file

            # vi /etc/httpd/conf/httpd.conf

LoadModule  proxy_module      modules/mod_proxy.so
LoadModule  proxy_http_module modules/mod_proxy_http.so


3)       Add the below entries to the http configuration file.

                        # vi /etc/httpd/conf/httpd.conf

            <IfModule mod_proxy.c>

            ProxyRequests Off
            <Proxy *>
            Order deny,allow
            Allow from all
            </Proxy>

            ProxyPreserveHost On
            ProxyVia On
            SSLProxyEngine on

            ProxyPass /webdav http://ServerIP:8080/webdav 
            ProxyPassReverse /webdav http://ServerIP:8080/webdav
 
            </IfModule>

Note: In the above sample all the request comes to /webdav URL redirect to the another tomcat server. For example Apache server IP is 10.0.0.1 and the tomcat server IP is 10.0.0.2, then the request like http://10.0.0.2/webdav will be redirect to http://10.0.0.2:8080/webdav

4)       To enable logging for the reverse proxy, add the below lines in the configuration file

            # vi /etc/httpd/conf/httpd.conf

            <IfModule mod_proxy.c>

            CustomLog logs/access_proxy.log combined
            ErrorLog logs/error_proxy.log

            </IfModule>

5)       Restart the httpd service

                        # /etc/init.d/httpd restart

                       



Jan 5, 2012

webdav configuration in apache


Sample Webdav Configuration in Apache

Introduction:
            WebDAV stands for "Web-based Distributed Authoring and Versioning". It is a set of extensions to the HTTP protocol which allows users to collaboratively edit and manage files on remote web servers.

Release:
RedHat Enterprise Linux 5.x
Apache 2.x

Problem:
Need to enable the webdav (Web-based Distributed Authoring and Versioning) in apache web server.

Solution:

1)      Install the required rpms

                        # yum install httpd

2)      Enable the webdav related modules in the httpd,conf file

            # vi /etc/httpd/conf/httpd.conf

            LoadModule dav_module modules/mod_dav.so
            LoadModule dav_fs_module modules/mod_dav_fs.so

3)      Create a directory to publish over web server

                  # mkdir /var/www/webdav

4)      Create one new configuration file for the webdav

            # vi /etc/httpd/conf.d/webdav.conf

            <IfModule mod_dav.c>
            LimitXMLRequestBody 131072

            Alias /webdav "/var/www/webdav"
            <Directory /var/www/webdav>
            Dav On
            Options +Indexes
            IndexOptions FancyIndexing
            AddDefaultCharset UTF-8
            Order allow,deny
            Allow from all
            </Directory>
            </IfModule>

5)      If want to enable authentication for the webdav means, add the below lines in the webdav.conf file and also create the user database
           
            # vi /etc/httpd/conf.d/webdav.conf

            AuthType Basic
            AuthName "WebDAV Server"
            AuthUserFile /etc/httpd/webdav.users.db
            Require valid-user
           
6)      Create the user database using the below command

            # htpasswd -c /etc/httpd/webdav.users.db testuser

7)      Restart the httpd service

            # service httpd restart

8)      Access the webdav from the client using the below URL

            http://ServerIPAddress/webdav






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 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







Nov 11, 2011

db documentation using schemaspy in linux


SchemaSpy in Linux

Introduction:
            SchemaSpy is a Java-based tool that analyzes the metadata of a schema in a database and generates a visual representation of it in a browser-displayable format. It lets you click through the hierarchy of database tables via child and parent table relationships as represented by both HTML links and entity-relationship diagrams.
           
Release:
RedHat Enterprise Linux
MSSQL 2005

Problem:
Need to create database documentation using SchemaSpy utility.

Dependencies:

1)    JVM 1.5 or above
2)    Graphviz (graph visualization software)
3)    JTDS 1.2.5
4)    HTTP Server (Optional)

Solution:

1)    Download the JVM from the below URL

                        http://www.oracle.com/technetwork/java/javase/downloads/index.html

2)    Give the executable permission and install the downloaded java

            # chmod +x jdk-1_5_0_22-linux-amd64.bin
            # ./jdk-1_5_0_22-linux-amd64.bin

3)    Then download the graphviz package from the below URL


4)    Install the downloaded the rpm using rpm or yum

                        # yum install graphviz

5)    Downlad the JTDS from the below link

                        http://sourceforge.net/projects/jtds/files/

6)    JTDS is used to connect the MSSQL database. JTDS does not need any special installation.

7)    Download the SchemaSpy from the below link

                        http://sourceforge.net/projects/schemaspy/files/

8)    Before running the schemaspy make sure that, the “dot” program should be in your PATH. If not present then we need to mention the path of that command using “-gv” option.
9)    Now execute the below command to create the relationship diagrams

                        # /opt/jdk1.5.0_22/bin/java -jar /asp/data/schemaSpy_5.0.0.jar -t mssql05-jtds -u user -p password -db database  -host IPAddress -port 1433 -o /opt/test_schema/ -s schemaname -dp /opt/jtds/jtds-1.2.5.jar

            Where,
            -t → Type of database (e.g. ora, db2, etc.). Defaults is ora
            -u → Valid database user id with read access.
            -p → Password associated with that user. Defaults to no password.
            -db → Name of database to connect to
            -host → database server ip or hostname
            -port → tcp port used to connect the database
            -o → Directory to write the generated HTML/graphs
            -s → Database schema
            -dp → Looks for drivers here before looking in driverPath

10)  The above command takes some time that depends upon your schema size and generate the graphs in the given output directory (in my case /opt/test_schema/).
11)  In that output directory “index.html” file will be there using that we can browse everything.
12)  If we have http server installed in the same server means we can include this directory to the “Document Root” by creating on symbolic link.

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

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

13)  Now we can access the schemaspy graphs through the webserver.
                       
                        http://ServerIPAddress/test_schema