How to use NFS with RSYNC

Here is a document describes what is a NFS share and how to use with RSYNC

What is NFS

Prerequisites
Procedure

NFS using with RSYNC

Network File System (NFS)

NFS defines a method of sharing files in which files residing on one or
more remote servers can be accessed on a local client system in a manner
that makes them appear as local files and directories.

Prerequisites
Server NFS daemons:                   Client NFS daemons:
Portmap                                 nlockmgr
Mountd                                  status
nfsd
rquotad
nlockmgr
status

To start the NFS services, run the startup scripts:

/etc/rc.d/init.d/portmap start
/etc/rc.d/init.d/nfs start
/etc/rc.d/init.d/nfslock start

To make sure that the RPC services are running:
/usr/sbin/rpcinfo -p

Easy method on Server: command terminal type setup and select services – NFS,NETFS,NFSLOCK,PORTMAP,YPBIND select and restart.
Easy method on Client: command terminal type setup and select services – NETFS,NFSLOCK,PORTMAP,YPBIND select and restart.

The portmap  holds the port, service number and version numbers
for each RPC service. If the portmap goes down, then all services
need to be restarted after the portmap is restarted.
Procedure and implementation.

Mounting a remote file system over NFS:

Client                         Server
mount    — RPC request —>  portmapper

mount    <– port number —   portmapper

mount    — RPC request —>   mountd

mount    <– respond ——–   mountd
I/O (Read/Write) access

Client                         Server
write()  —- I/O ————–>  nfsd

write()  <– ACK upon complete—  nfsd
A server exports a file system to the specified hosts and allows
them to mount it.

NFS Server side
Create a dir for nfs share and mount
mkdir /mnt/nfsdir
edit /etc/exports with

/mnt/nfsdir    *(rw,sync)
Type automount command to mount the volume(or you can doit manually)
mount –a   or      mount /mnt/nfsdir

Every time when you modify /etc/exports file, run
/usr/sbin/exportfs -r
or
/usr/sbin/exportfs -a
to preserve any manual exports

To verify exports, run
/usr/sbin/exportfs -v
or
/usr/sbin/showmount -e

To start NFS services at bootup time, run ntsysv,
and check-in portmap, nfs and nfslock. Alternatively,

chkconfig –level 3 portmap on
chkconfig –level 3 nfs on
chkconfig –level 3 nfslock on
NFS client side

NFS clients mount directories exported to them from the NFS servers.

To verify that the server allows you to access its RPC (including NFS)
services, run
/usr/sbin/rpcinfo -p server_name

To check what directories it exports to you, run
/usr/sbin/showmount -e server_name

To unmount a directory, you can run command
umount /mnt/nfs

Create emptydir in  /(where ever) named nfsdir
edit /etc/fstab with

Server name or IP address:/mnt/nfsdir  /nfsdir    nfs    default 0 0

Type automount command to mount the volume
mount -a

When /etc/fstab has been modified, you can run
mount –a  or    mount –r      or reboot the machine

Using with RSYNC

shows how NFS with RSYNC for accessing Wiki Images
RSYNC is using for sync datas

Install rsync or check RSYNC is running
#/usr/bin/rsync

To check it is started
#Service rsync status

Start service
#Service rsync start

Put it for initscript automaticall run when it restart
#chkconfig rsync on

Using rsync with ssh
#rsync -avz -e “ssh -i /RSA/DSAkeyfile location” remoteuser@remotehost:/remote_dir  /local_dir

File in /etc/fstab
10.1.1.12:/usr/local/wikiimages /wikiimages  nfs  defaults 0 0

Advertisements

Posted on July 12, 2011, in LInux Based, Uncategorized. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: