Friday, July 26, 2013

What is this .nfs file and why can I not remove it?

— SkyHi @ Friday, July 26, 2013
Under linux/unix, if you remove a file that a currently running process still has open, the file isn't really removed. Once the process closes the file, the OS then removes the file handle and frees up the disk blocks. This process is complicated slightly when the file that is open and removed is on an NFS mounted filesystem. Since the process that has the file open is running on one machine (such as a workstation in your office or lab) and the files are on the file server, there has to be some way for the two machines to communicate information about this file. The way NFS does this is with the .nfsNNNN files. If you try to remove one of these file, and the file is still open, it will just reappear with a different number. So, in order to remove the file completely you must kill the process that has it open.
If you want to know what process has this file open, you can use 'lsof .nfs1234'. Note, however, this will only work on the machine where the processes that has the file open is running. So, if your process is running on one machine (eg. bobac) and you run the lsof on some other burrow machine (eg. silo or prairiedog), you won't see anything.
Here is an example that demonstrates the issue:
% echo test> foo
% tail -f foo
test
^Z
Suspended
% rm foo
% ls -A
.nfsB23D
% rm .nfsB23D
% ls -A
.nfsC23D
% lsof .nfsC23D
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF    NODE NAME
tail    1257 robh    0r  VREG  176,6        5 3000753 .nfsC23D
%
Once you have located and killed the process that has the file open, the .nfs file will go away automatically. In the above example, when you kill the tail process, the .nfsC23D file will disappear.


REFERENCES

Saturday, July 20, 2013

HOWTO: add disk to VMware Ubuntu guest without reboot using LVM

— SkyHi @ Saturday, July 20, 2013
This howto is mostly built on the great tutorial available athttp://www.comnetslash.com/…hout-reboot/. My spot tries to be more Ubuntu and LVM specific. This manual was tested on Ubuntu 9.04 (jaunty) Server edition guest OS.

Add Virtual Hard Disk

add-disk1A new hard disk can be added easily to a running virtual machine in VMWare Infrastructure Web Access by clicking Add Hardware and following the wizard.
Note: I assume that all of the commands given are run under superuser (root) rights. To become root type
sudo su root

Detect new SCSI Disk

The package scsitools provides the script rescan-scsi-bus.sh, which does exacly what we need. Install it and run it:
apt-get install scsitools
rescan-scsi-bus.sh
This should detect the newly added hard disk and make it available in /dev/ – /dev/sdb in the case you are adding a new drive for the first time. The output of fdisk -l should include the newly detected disk.

Format the new disk

Format the newly detected drive using fdisk
fdisk /dev/sdb
    n (for new partition)
    p (for primary partition)
    1 (partition number)
    (keep the other values default)
    w (write changes)
Change the type of the partition to LVM Linux:
fdisk /dev/sdb
    t (change the partition type)
    8e (for Linux LVM)
    w (write changes)

LVM

Initialize LVM Physical Volume

pvcreate /dev/sdb1

Add Physical Volume to Volume Group

List the Volume groups available at your machine.
vgdisplay
Replace VolGroupName with what you read from the output of the last command.
vgextend VolGroupName /dev/sdb1
You should see the newly aquired free space in the output of
vgdisplay

Resize Logical Volumes

After adding some free space to your Volume Group, you can distribute it to the Logical Volumes. The list of Logical Volumes can be obtained by running
lvdisplay
Run the following commands for each Logical Volume you want to resize (add space to). Again – replace /dev/VolGroupNa­me/Namewith the Logical Volume name you can read from the output of the last command. The +10G means Add 10 GB
lvextend -L +10G /dev/VolGroupName/Name
The last step is to resize the ext3 filesystem (use different tool is you use different filesystem):
resize2fs /dev/VolGroupName/Name

REFERENCES
http://blog.stastnarodina.com/honza-en/spot/howto-add-disk-to-vmware-ubuntu-guest-without-reboot-using-lvm/

Thursday, June 20, 2013

Stop Ubuntu / Debian Linux From Deleting /tmp Files on Boot

— SkyHi @ Thursday, June 20, 2013
Q. I know /tmp as it named is a temporary dircory, Debian policy is to clean /tmp at boot. However, I'd like to configure my Ubuntu Server to stop deleting files from /tmp on boot due to custom configuration issue. How do I configure behavior of boot scripts to stop deleting files on boot?

A. Users should not store files in /tmp, use /home or other partition, if you would like to keep the files. The behavior of boot scripts is controlled via a special configuration file called /etc/default/rcS. Open this file and modify TMPTIME variable.
On boot the files in /tmp will be deleted if their modification time is more than TMPTIME days ago. A value of 0 means that files are removed regardless of age. If you don't want the system to clean /tmp then set TMPTIME to a negative value(-1) or to the word infinite.

Configuration /etc/default/rcS

Open /etc/default/rcS file, enter:
$ sudo vi /etc/default/rcS
Set TMPTIME to 60 so that files in /tmp will deleted if their modification time is more than 60 days ago.
TMPTIME=60
Close and save the file. This configuration is used by /etc/init.d/bootclean script on boot to clean /tmp and other directories under all Debian based Linux distros.

A note about RHEL / CentOS / Fedora / Redhat Linux

Redhat and friends use /etc/cron.daily/tmpwatch cron job to clean files which haven’t been accessed for a period of time from /tmp. The default is 720 hours. If the file has not been accessed for 720 hours, the file is removed from /tmp. You can modify this script as per your requirements:
# cp /etc/cron.daily/tmpwatch /etc/cron.daily/tmpwatch.bak
# vi /etc/cron.daily/tmpwatch

REFERENCES
http://www.cyberciti.biz/faq/debian-ubuntu-removes-files-at-boot-time/

Tuesday, June 11, 2013

IP_CONNTRACK: TABLE FULL, DROPPING PACKET

— SkyHi @ Tuesday, June 11, 2013
Last week, I found myself with a server under low load, but it couldn’t make or receive network connections. When I ran dmesg, I found the following line repeating over and over:
ip_conntrack: table full, dropping packet
I’d seen this message before, but I headed over to Red Hat’s site for more details. It turns out that the server was running iptables, but it was under a very heavy load and also handling a high volume of network connections. Generally, the ip_conntrack_max is set to the total MB of RAM installed multiplied by 16. However, this server had 4GB of RAM, but ip_conntrack_max was set to 65536:
# cat /proc/sys/net/ipv4/ip_conntrack_max
65536
I logged into another server with 1GB of RAM (RHES 5, 32-bit) and another with 2GB of RAM (RHES 4, 64-bit), and both had ip_conntrack_max set to 65536. I’m not sure if this is a known Red Hat issue, or if it’s just set to a standard value out of the box.
If you want to check your server’s current tracked connections, just run the following:
# cat /proc/sys/net/ipv4/netfilter/ip_conntrack_count
If you want to adjust it (as I did), just run the following as root:
# echo 131072 > /proc/sys/net/ipv4/ip_conntrack_max

REFERENCES

Thursday, May 23, 2013

Remount using fstab entries

— SkyHi @ Thursday, May 23, 2013

7.1.2. Remounting the File Systems

After adding the usrquota and/or grpquota options, remount each file system whose fstab entry has been modified. If the file system is not in use by any process, use one of the following methods:
  • Issue the umount command followed by the mount command to remount the file system.(See the manpage for both umount and mount for the specific syntax for mounting and unmounting various filesystem types.)
  • Issue the mount -o remount  command (where  is the name of the file system) to remount the file system. For example, to remount the /home file system, the command to issue is mount -o remount /home.
If the file system is currently in use, the easiest method for remounting the file system is to reboot the system.


REFERENCES

Monday, April 29, 2013

Error : ” child pid exit signal File size limit exceeded (25) in Apache ” Resolution

— SkyHi @ Monday, April 29, 2013

Many times if you find apache processes dying in the top process list or apache failing to start completely then one of the reasons could be a log file larger than 2Gb , which is indicated by the below error in the apache error logs :

child pid XXXX exit signal File size limit exceeded (25)
where XXXX is process id for the process which is failing and generating the error in the error log.
To fix this you will need to locate the log file which has grown to or above 2Gb size and either empty it or make a tar , rename and create a new log file. It can be access_log , error_log itself, the suphp_log , suexec_log etc.
For cPanel serves you should set the log rotation from following link in WHM to avoid this :
WHM >> Service Configuration >> Apache Configuration >> Log Rotation
For finding files greater then 2Gb below commands can be helpful :

This will print the top ten files with respect to size in the current directory
# find `pwd` -xdev -type f -ls | sort -k7nr | head


This will print any files greater than 2Gb
# ls -l | awk '{ if ( $5 > 2147483648 ) print $9 "\t" $5 }'


This will show files greater than 2Gb using simple find command
# find / -size +2G

Note : Depending on the version of find command on your server you may need to use different value, like in Mbs or Kbs in your find command.

REFERENCES

Monday, April 22, 2013

Error ID: 0x800CCC0F

— SkyHi @ Monday, April 22, 2013

Some of the possibilities for this error are as follows :


1. Make sure your e-mail settings are correct: Mail Server, Username, and Password.

2. Clear messages in the outbox folder

3. Delete large emails, if any, in webmail.

4. Adjust mail server timeouts.

5. Your antivirus program has e-mail protection enabled, which checks the mail as it comes in from your Post Office Protocol (POP) server. Temporarily disable the antivirus e-mail protection utility and check.

6. Create a new profile to check if it's a profile issue.