UnixServerAdmin

Server Administration & Management

Service httpd status: httpd dead but subsys locked, but pid exists

I have an apache server acting as a reverse proxy for serveral websites, (which you should see that it is up and running). However, when I check the status of the apache service, I get this:

# service httpd status
httpd dead but subsys locked

================== Method-1 ==================

So I lookup the locked PIDs of apache and get:

# ipcs -s | grep apache
0x00000000 98306 apache 600 1
0x00000000 131075 apache 600 1
0x00000000 163844 apache 600 1

So I delete these resources:

# ipcs -s | grep apache | perl -e ‘while (<STDIN>) { @a=split(/\s+/);print `ipcrm sem $a[1]`}’
resource(s) deleted
resource(s) deleted
resource(s) deleted

and I delete the lock from the subsys folder:

# cd /var/lock/subsys
# rm httpd

and start apache:

# service httpd restart
Starting httpd: [ OK ]

================== Method-2 ==================

If the above is not fixing then try the following.

comment out the following module in your httpd.conf and restart apache

# vim /etc/httpd/conf/httpd.conf
LoadModule unique_id_module modules/mod_unique_id.so

# /etc/init.d/httpd restart

April 27, 2013 Posted by | Apache, Tips & Tricks | , | Leave a comment

How to rotate apache logs

/var/log/httpd/access_log.* {
compress
copytruncate
create 644 root root
rotate 30
size 100K
}

/var/log/httpd/dummy-host.example.com-access_log.* {
compress
copytruncate
create 644 root root
rotate 30
size 10M
}

/var/log/httpd/dummy-host.example.com-error_log.* {
compress
copytruncate
create 644 root root
rotate 30
size 100K
}

/var/log/httpd/error_log.* {
compress
copytruncate
create 644 root root
rotate 30
size 5K
}

/var/log/httpd/mod_jk.log.* {
compress
copytruncate
create 644 root root
rotate 30
size 5M
}

/var/log/httpd/ssl_access_log.* {
compress
copytruncate
create 644 root root
rotate 30
size 10K
}

/var/log/httpd/ssl_error_log.* {
compress
copytruncate
create 644 root root
rotate 30
size 10K
}

/var/log/httpd/ssl_request_log.* {
compress
copytruncate
create 644 root root
rotate 30
size 10K
}

daily :- rotates the catalina.out daily
rotate 7 :- keeps at most 7 log files
compress :- compresses the rotated files
size 10M :- rotates if the size of logs are bigger than 10M
copytruncate :- Truncate the original log file in place after creating a copy, instead of moving the old log file and optionally creating a new one, It can be used when some program can not be told to close its logfile and thus might continue writing (appending) to the previous log file forever. Note that there is a very small time slice between copying the file and truncating it, so some logging data might be lost. When this option is used, the create option will have no effect, as the old log file stays in place.

April 22, 2013 Posted by | Apache, Tips & Tricks, Unix/Linux | , , , | Leave a comment

How to check IDE/SATA Hard Disk Transfer Speed

how to find out how fast is the hard disk, Is it running at SATA I (150 MB/s) or SATA II (300 MB/s) speed without opening computer case or chassis, Use the hdparm command to check hard disk speed. It provides a command line interface to various hard disk ioctls supported by the stock Linux ATA/IDE/SATA device driver subsystem. Some options may work correctly only with the latest kernels (make sure you have cutting edge kernel installed). It provides more accurate result. Measure Hard Disk Data Transfer Speed, Login as the root and enter the following command:

# hdparm -tT /dev/sda

OR

# hdparm -tT /dev/hda

Sample outputs:

/dev/sda:
 Timing cached reads:   7864 MB in  2.00 seconds = 3935.41 MB/sec
 Timing buffered disk reads:  204 MB in  3.00 seconds =  67.98 MB/sec

For meaningful results, this operation should be repeated 2-3 times. This displays the speed of reading directly from the Linux buffer cache without disk access. This measurement is essentially an indication of the throughput of the processor, cache, and memory of the system under test. Here is a for loop example, to run test 3 time in a row: for i in 1 2 3; do hdparm -tT /dev/hda; done; Where,

-t :perform device read timings
-T : perform cache read timings
/dev/sda : Hard disk device file

To find out SATA hard disk speed, enter:

# hdparm -I /dev/sda | grep -i speed

Output:

  *    Gen1 signaling speed (1.5Gb/s)
*    Gen2 signaling speed (3.0Gb/s)

Above output indicate that my hard disk can use both 1.5Gb/s or 3.0Gb/s speed. Please note that your BIOS / Motherboard must have support for SATA-II.

April 17, 2013 Posted by | Tips & Tricks, Unix/Linux | , , | Leave a comment

How to Reload/Take effect .bashrc and /etc/profile files without Reboot

After editing /root/.bashrc or /etc/profile, the file take effect immediately without System Reboot by using given below command.

# source /root/.bashrc

OR

# source /etc/profile

You can either logout and login again.

April 12, 2013 Posted by | Tips & Tricks, Unix/Linux | , , | 1 Comment

How to hide web server version in Tomcat

Add the following attributes to the <Connector> in Tomcat’s server.xml to hide web server version in Tomcat at line no- 73 :-

# vim apache-tomcat/conf/server.xml

<Connector port=”8080″ protocol=”HTTP/1.1″
connectionTimeout=”20000″
redirectPort=”8443″
server=”Tomcat” />

April 7, 2013 Posted by | Security, Tips & Tricks, Tomcat | , , , , | 1 Comment

How to convert RHEL 6.x to CentOS 6.x

In day-today system administration, we need ftp server for internal purposes. What amused me further was the fact that the machine was running RHEL. No way we should be using this machine with RHEL on top bearing licencing cost. Here are following process to convert RHEL 6.x to CentOS 6.x

1. Clean up existing cache of metadata and packages. Also, erase Red Hat subscription manager

# yum clean all
# rpm -e subscription-manager

2. Create a directory to keep CentOS packages

# mkdir /root/centos
# cd /root/centos

3. Download the packages

# wget http://mirror.centos.org/centos/6.3/os/x86_64/RPM-GPG-KEY-CentOS-6
# wget http://mirror.centos.org/centos/6.3/os/x86_64/Packages/centos-release-6-3.el6.centos.9.x86_64.rpm
# wget http://mirror.centos.org/centos/6.3/os/x86_64/Packages/yum-3.2.29-30.el6.centos.noarch.rpm
# wget http://mirror.centos.org/centos/6.3/os/x86_64/Packages/yum-utils-1.1.30-14.el6.noarch.rpm
# wget http://mirror.centos.org/centos/6.3/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

4. Next enter the commands below to first import CentOS GPG key, to install the packages and then to upgrade to CentOS 6

# rpm –import RPM-GPG-KEY-CentOS-6
# rpm -e –nodeps redhat-release-server
# rpm -e yum-rhn-plugin rhn-setup rhn-check rhn-setup-gnome rhnsd
# rpm -Uhv –force *.rpm
# yum update
# yum upgrade

5. Reboot the server in order to complete the installation.

April 2, 2013 Posted by | Tips & Tricks, Unix/Linux | , , | Leave a comment