Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Friday, August 5, 2011

To manually sync CentOS time to NTP Servers

1. Stop NTP service in CentOS
  • service ntpd stop
2. Run manual NTP update command
  • ntpd update 192.168.10.100
3. Run sync command
  • sync
4. Restart NTP service in CentOS
  • service ntpd start

Change CentOS IP address


To change interface eth0 IP address.
  1. Edit /etc/sysconfig/network-scripts/ifcfg-eth0
  2. Run service network restart

Friday, August 13, 2010

Linux - Tuning NFS for better performance

The Network File System (NFS) is still very popular on Linux systems, but it can use some help to increase performance by tweaking the relatively conservative defaults that most Linux distributions ship with. This can be done by tweaking both NFS servers and clients.

On the server side, you must ensure that there are enough NFS kernel threads to handle the number of connections by the clients. You can determine whether or not the default is sufficient by looking at RPC statistics using nfsstat on the NFS client:

# nfsstat -rc
Client rpc stats:
calls retrans authrefrsh
3409166 330 0

Here you can see that the retrans value is quite high, meaning that retransmissions were often necessary since the last reboot. This is a clear indication that the number of available NFS kernel threads on the server is insufficient to handle the requests from this client. The default number of threads for rpc.nfsd to start is typically eight threads.

To tell rpc.nfsd to use more kernel threads, the number of threads must be passed as an argument to it. Typically, most distributions will have a file such as/etc/sysconfig/nfs to configure this; on a Mandriva Linux system, the configuration item RPCNFSDCOUNT in /etc/sysconfig/nfs is used to determine the number of kernel threads to pass to rpc.nfsd. Increase this number — perhaps to 16 — on a moderately busy server, or increase up to 32 or 64 on a more heavily used system. Re-evaluate using nfsstat to determine whether or not the number of kernel threads is sufficient; if the retrans setting is 0 then it is enough; but, if the client still needs to retransmit, increase the number of threads further.

On the client side of things, remote NFS mounts should be mounted with the following options:

rsize=32768,wsize=32768,intr,noatime

By default, most clients will mount remote NFS file systems with an 8-KB read/write block size; the above will increase that to a 32-KB read/write block size. It will also ensure that NFS operations can be interrupted if there is a hang and will also ensure that the atime won’t be constantly updated on files accessed on remote NFS file systems.

If NFS file systems are mounted via /etc/fstab, make the changes there; otherwise, you will need to make them to any configuration files belonging to your chosen automounter. In the case of amd, the /etc/amd.net file would look like:

/defaults fs:=${autodir}/${rhost}/root/${rfs};opts:=nosuid,nodev,rsize=32768,wsize=32768,intr,noatime
* rhost:=${key};type:=host;rfs:=/

By tweaking the defaults of NFS servers and clients, you can make using NFS faster and more responsive, particularly if you make heavy use of NFS file systems.

Linux - How to Find the Block Size

To find the block size for the second partition of the first HDD, the following can be used:

/sbin/dumpe2fs /dev/hda2 | grep 'Block size'

Because dumpe2fs provides a large amount of information, it is convenient to use the filter grep to remove everything from the output except the block size. Because grep is case-sensitive and the word Block begins with an upper case (i.e., capital) B, it is necessary to use an upper case B in this command.

Wednesday, April 14, 2010

CentOS - edit /etc/fstab when at "Repair filesystem" prompt

Linux gives you a “Repair Filesystem” prompt and you can enter that by providing the root password. The problem is that on “Repair Filesystem” prompt, linux file system and rest of the file systems are generally not mounted and if mounted then it is “Read-Only” so you can not change files.

Solution:

Use following command to mount the filesystem with writable permission:

Repair filesystem # mount -w -o remount /

After this you can go and change /etc/fstab file. Restart your computer.