Friday, 24 May 2013

Shell Script for rebooting system at a particular time

#!/bin/bash
time=`date | cut -f4 -d" " | cut -f1,2 -d:`
yes=05:10
if [ "$time" = "$yes" ]
then
/sbin/reboot
else
 echo " `date` -  Not Re-booted" > /etc/motd
fi

Save file as rboot.sh and put it in /bin file. And now add the cronjob to execute the script.

# crontab -e
42 05 * * * sh /bin/rboot.sh

If the script is not executed it will display the message in motd

Friday, 10 May 2013

How to connect S3Bucket - S3fox A Plugin for S3 Bucket

Check the setting up of s3 fox plugin to access S3 bucket








How to install MSSQL Server2008

Here we follow the step by step procedure to install mssql server on windows






















Wednesday, 1 May 2013

How to setup AUTOFS / AUTOMOUNT in NFS

Using Automount services(Autofs)

# vim auto.master
  /home   /etc/auto.home

# vim auto.home
   nfs  -rw  192.168.0.130:/home/nfs

Started autofs. Logged in as an NFS user and the exported home directory get automatically mounted.

# vim /etc/auto.master
/home /etc/auto.home  ------ means to mount directory specified in auto.home into "/home" all NFS shares specified in auto.home should mount under "/home"

# vim auto.home
nfs -rw 192.168.0.130:/home/nfs 

------ "192.168.0.130:/home/nfs" will be mounted into
 "nfs"(nfs -- first field)

SERVER SetUP


# mkdir /automount
# cd /automount/
# mkdir documents
# touch documents/commands.txt

# vim /etc/exports
/automount      10.0.0.154/255.0.0.0(rw,sync)
 

# service nfs restart
# service nfslock restart

CLIENT SetUp

 
# vim /etc/auto.master
   /test    /etc/auto.test

# vim/etc/auto.test
  autofs  rw,sync  10.0.0.180:/automount

# service autofs restart

NFS Mounting options -Soft v/s Hard Mounting

Soft v/s Hard Mounting

There are some options which govern the way the NFS client handles a server crash or network outage. one of the cool things about NFS is that it can handle this gracefully if you set up the client right. There are two distinct failure modes:
 
Soft

 
If a file request fails, the NFS client will report an error to the process on thee client machine requesting the file access.

Hard

The programme accessing a file on a NFS mounted file system will hang when the server crashes. The process cannot be interrupted or killed (except be a "sure kill") unless you also specify intr. When the NFS server is back online the program will continue undisturbed from where it was. We recommend using hard,intr on all NFS mounted file systems.

ex:
  
Device    mountpoint fs-type   options      dump  fsckorder

Host:/home /home1     nfs     rw,hard,intr    0      0

Setting block size to optimize transfer speed

The rsize and wsize mount options specify the site of the chunks of data that the client and server pass back and forth to each other.

rsize = n will set the NFS read buffer size to n bytes

        (default is 4096)
wsize - n will set the NFS write buffer size to n bytes(")

While mounting manually the mount options can be specified as below
 
# mount -t nfs 192.168.0.25:/home /home1 -o rsize=8292,wsize=8192,hard,intr,nolock

nolock disables NFS locking and stops the statd and lockd daemons and lock will enable it.

How to Setup NFS Server in Linux

NFS depends on the portmapper daemon
/etc/init.d/portmap start
/etc/init.d/portmap status

Providing NFS service requires the service of si daemons,

portmap:Enables NFS clients to discover the NFS services

         available on a given NFS server
nfsd   :provides all NFS services except file locking and

         quota management
lockd  :Starts the kernels NFS lock manager
statd  :Implements NFS lock recovery when an NFS server

        system crashes
rquotad:Handles user file quotas on exported volumes to NFS

        clients
mountd : Processes NFS client mount requests

The daemons are all part of the nfs-utils package. If your distribution does not include them in the startup scripts, then you should add them and configure it to start in the following

order,
  portmap
  nfsd
  mountd
  statd
  rquotad (if necessary)

The nfs-utils package has a sample startup script for redhat and the script will take care of starting all the NFS server daemons for you except the portmapper.

/etc/rc.d/init.d/nfs start/stop/status/restart
/etc/init.d/portmap start
/etc/init.d/nfs start
/etc/init.d/nfslock start


Verifying that NFS is running

To do this, query the portmapper with the command 


# rpcinfo -p
 

to find out what services it is providing. You should get something like this:

# rpcinfo -p portmapper

Making changes to /etc/exports later on

If you come back and change your /etc/exports file, the changes you make may not take effect immediately.  You should therefore run the command


# rpcinfo -pra -- to force nfsd to re-read the /etc/exports file. If you can't find exportfs command, then you can kill nfsd and restart it.

exportfs command will also let you manipulate the list of available exports or list the currently exported file systems

# exportfs -v // List currently exported file systems

# exportfs -v -u 192.168.0.25:/home // remove an exported 

         file system

Setting up an NFS Client

1. Mounting remote directories:

Firstly, kernal on the client machine needs to be compiled with NFS support.

Portmapper should be running on the client machine and to use NFS file locking you also need statd and lockd running on both the client and the server. With portmap,lockd, and statd running you should now be able to mount the remote directory from your server just the way you mount a local hard drive, with the mount command

mounting home dir of master.com to slave.com

 # mount -t nfs 192.168.0.25:/home /home1 OR
 # mount -t nfs 192.168.0.25:/home /home1 -o -rw,soft

to unmount the file system

# umount /home1
 

Getting NFS file system to be mounted at boot time

NFS file systems can be added to /etc/fstab, the only difference is that the file system type will be set to nfs and the dump and fsck order will have to
be set to zero.

ex:
   

Device        mountpoint fs-type options dump fsckorder
host.com:/home  /home1    nfs      rw     0     0