NFSSSS

download NFSSSS

of 7

description

NFSSSS

Transcript of NFSSSS

NFS (Network File System) for Beginners

September 28, 2011

By Yogesh RahejaNFS (Network File System) for Beginners: In this post I am trying to build a base for the beginners. This post will help to proceed further with NFS complex tasks.What is NFS?NFS > Network File System > The Network File System (NFS) is a client-server service that enables users to view, store, and update files on a remote server as though they were on the their own local server. In Simple layman language NFS provides a Centralized File Access.Example: Suppose you have a 100 users in a company. Out of which 50 require complete access to 10 files/softwares etc. for there daily day to day work and other 50 require access to other commonly used 15 files/softwares etc. for there work. Now instead of placing individual files/softwares on each users server (computer) you should keep the files/softwares in a common shared place which users would have access to. Now each user can access (read/write/modify > depending upon access provided) those commonly used files/softwares remotely without having them on his/her local server/computer. This will help to save the diskspace as well on all users server.NFS Model:========Server client mode > NFS is based on Server-C;ient Model. The server where the files are physically stored is called Master server and the server which is using thoses files remotely are called Client server.Note: The Solaris 10 OS supports versions 2, 3, and 4 NFS simultaneously. The default is to use NFSv4.NFS Server Files:============/etc/dfs/dfstab > defines the files/directory to be shared (command used is share), also run shareall command after editing this file. Lists the local resources to share at boot time./etc/dfs/sharetab > shows the result of share command. All share file/dir. will be shown here. Lists the local resources currently being shared by the NFS server. Do not edit this file./etc/dfs/fstypes > Lists the default file system types for remote file systems./etc/rmtab > Contains the table of filesystems remotely mounted by the client. (mountd daemon)./etc/default/nfs > parameters for NFS daemons and protocols./etc/default/nfslogd > Lists configuration information describing the behavior of the nfslogd daemon for NFSv2/3.NFS Server Service:===============NFS Server Service: We have to Enable the NFS server service, svc:/network/nfs/server.# svcs -a | grep -i /network/nfs/server# svcadm enable /network/nfs/server# svcs -a | grep -i /network/nfs/serverNFS SERVER DAEMONS:==================mountd > handles clients filesystem mount requests.nfsd > client FS request.statd > work with lockd for recovery function.lockd > recored locking operation.nfslogd > Provides operational logging for NFSv2 and 3.nfsmapid > NFS users & grps mapping.NFS SERVER COMMANDS:===================share > shows the shared files (i.e shows the contents of /etc/dfs/sharetab). Makes a local directory on an NFS server available for mounting. It also displays the contents of the /etc/dfs/sharetab file.unshare > unshare all. Makes a previously available directory unavailable for client side mount operations.shareall > (/etc/dfs/dfstab) > shows all entries from this file and execute them.unshareall > unshare all. Makes previously shared resources unavailable.dfshares > show the shared resources.dfmounts > Show the currrently mounted FS.

NFS CLIENT FILES:==============/etc/vfstab > Defines file systems to be mounted locally. eg: raheja:/usr/nfstest /yogeshtest nfs yes soft,bg/etc/mnttab > Lists currently mounted file systems, including automounted directories. The contents of this file are maintained by the kernel and cannot be edited./etc/dfs/fstypes > Lists the default file system types for remote file systems./etc/default/nfs > Contains parameters used by NFS protocols and daemons.NFS CLIENT DAEMON:=================statd > Works with the lockd daemon to provide crash recovery functions for the lock manager.lockd > Supports record-locking operations on NFS files.nfs4cbd > callback daemon for NFSv4.NFS CLIENT COMMANDS:===================dfshares > lists shared resources.mount > mount the shared FS. eg: forsharing from single and multiple servers,mountraheja:/usr/nfstest /yogeshtest and mount -o ro raheja1,raheja2,raheja3:/multi_homed_data /remote_shared_dataumount > Unmounts a currently mounted file resource.mountall > Mounts all file resources or a specific group of file resources listed in the /etc/vfstab file with a mount at boot value of yes.umountall > Unmounts all non-critical local and remote file resources.==================================================================================

A Simple example to share a file from NFS master server to Client server.On NFS server:=============1.) make one directory as /usr/nfstest.# mkdir /usr/nfstest2.) edit /etc/dfs/dfstab file with the shared dir/file info.# share -F nfs -o ro -d test NFS sharing /usr/nfstest3.) execute share -F nfs /usr/nfstest.# share -F nfs /usr/nfstestshare [ -F nfs ] [ -o options ] [ -d description ] [ pathname ]where:-F nfs Specifies the file system type. This option is not typically required, because NFS is the default remote file system type.-o options Controls a clients access to an NFS shared resource.-d description Describes the shared file resource.pathname Specifies the absolute path name of the resource for sharing.4.) share command will show you the output now.On NFS Client:==========5.) On client edit /etc/vfstabeg: raheja:/usr/nfstest /yogeshtest nfs yes soft,bg6.) Make directory (/yogeshtest) and mount it.# mount raheja:/usr/nfstest7.) df -k will show you the shared dir/file now.Note: 1.) This is the simplest representation of NFS. This will help you to build a base to perform complex NFS tasks. You will find many NFS related issues with theirresolution at our side as we have already posted many posts on NFS.2.) You can check NFS services running on Server or Client via svcs -a | grep -i nfs.3.) Kindly refer default files as stated in the post in the server itself for more clarity (eg: cat /etc/dfs/dfstab etc.)4.) Also it would be more useful to go through the man pages of NFS commands.Solaris 10 : Migration from NFSv3 to NFSv4

May 30, 2012

By RamdevThis post will make some comparisons between NFSv4 and NFSv3, and introduce how to migrate from NFSv3 to NFSv4.As we all aware, NFSv4 is not just a simple protocol evolution of NFSv3. It has been fully redesigned to overcome the limitations of its predecessors.Comparison Between NFSv3 and NFSv41. Transport protocolsFor NFSv3, the MOUNT service is normally supported over the TCP and UDP protocols.For NFSv4, only the TCP protocol is supported.NFS v4 is designed for internet use. One unique network port is used on NFSv4. This predetermined port is fixed. The default is port 2049. Using NFS v4 through firewalls is easier than with earlier NFS versions.

2. Locking operationNFS v3 protocol is stateless, so an additional Network Lock Manager (NLM) protocol,an auxiliary protocol for file locking, is required to support locking of NFS-mounted files READ/WRITE. Also NLM is stateful in that the server LOCKED keeps track of locks.

NFSv4 is stateful. Locking operations(open/read/write/lock/locku/close) are part of the protocol proper. NLM is not used by NFSv4.

3. Required ServicesNFSv3 relies on Remote Procedure Calls (RPC) to encode and decode requests between clients and servers. NFSv3 depends on portmapper, rpc.mountd, rpc.lockd, rpc.statd.

NFSv4 has no interaction with portmapper, rpc.mountd, rpc.lockd, and rpc.statd, since protocol support has been incorporated into the v4 protocol. NFSv4 listens on well-known TCP port (2049) which eliminates the need for the portmapper interaction. The mounting and locking protocols have been incorpated into the V4 protocol which eliminates the need for interaction with rpc.mountd and rpc.lockd.

4. Security

NFS v3 supports export/mount. Thus the host makes the mount request, not a user of the file system.

With NFSv4, the mandatory security mechanisms are oriented towards authenticating individual users, e.g. by configuring the Kerberos version 5 GSS-API or other security mechanism.

Migration From NFSv3 to NFSv4Migrating a system from NFSv3 to NFSv4 is a five step process:

1. Listing the data to exportThe first step is to list all data to be exported by NFSv3. Usually, there are several directories to be exported. In the example that follows, the following directories are used.

#showmount-eExportlistforjch-lnx:/myshare*/distros*

2. Choosing the NFSv4 virtual rootTo define the NFSv4 virtual root:a) Create a NFSv4 root directory. Example: /exports/ .b) Choose an existing directory which will be used as virtual root for. Example: /home/ .In the following examples, /exports is used as the virtual root.

3. Data migration to the virtual rootOnce we have a virtual root, we need to move data exported from the NFSv3 virtual root, as defined previously. There are two main possibilities:

A.Copy or move data from its path to the virtual root (recommended):

# mv/myshare/exports/myshare_v4# mv/distros/exports/distros_v4B.Move the data path sub tree to the virtual root (recommended):

# mkdir/exports/myshare_v4# mount-bind/myshare/exports/myshare_v4/# mkdir/exports/distros_v4/# mount-bind/distros/exports/distros_v4/

4. Modifying export optionsThe goal is to convert the NFSv3 export options into NFSv4 ones. Most of the NFSv3 and NFSv4 options are the same (though NFSv4 requires an additional option to exportfs to provide the virtual root).

1)Virtual root export

#exportfs-ofsid=0,insecure,no_subtree_check*:/exports2) Exporting subdirectories of the virtual root

# exportfs-orw,nohide,insecure,no_subtree_check*:/exports/myshare_v4# exportfs-orw,nohide,insecure,no_subtree_check*:/exports/distros_v4

5.Mounting

With the previous configuration and examples, the following commands would be used:

# mkdir /mnt/nfs_v4_root# mount-tnfs410.182.121.238://mnt/nfs_v4_root#echo$?0