38

Solaris 10 administration 2 Configuring NFS

Embed Size (px)

Citation preview

Page 1: Solaris 10 administration 2 Configuring NFS
Page 2: Solaris 10 administration 2 Configuring NFS

What is NFS ?Benefits of NFS NFS ServerNFS ClientThe Share CommandNFS Server Configuration NFS Client Configuration Ethics NFS TroubleShooting

Page 3: Solaris 10 administration 2 Configuring NFS

NFS stands for Network File System

The objects that can be shared through the NFS software include any whole or partial directory tree or a file hierarchy—including a single file. A computer cannot share a file hierarchy that overlaps one that is already shared.Peripheral devices such as modems and printers cannot be shared.Note . NFS software works across operating systems, and the concept of a file system may be meaningless in other, non-UNIX environments. the use of the term file system refers to a file hierarchy that can be shared and mounted over NFS environments.

Page 4: Solaris 10 administration 2 Configuring NFS

In Solaris 10 Environment :

The NFS service enables computers of different architectures running different operating systems to share file systems across a network .

Note– The NFS was developed by Sun Microsystems and is recognized as a file server standard. Its protocol uses the Remote Procedure Call (RPC) method of communication between computers on the Internet.

So you have to know it’s benefits

Page 5: Solaris 10 administration 2 Configuring NFS

Allows multiple computers to use the same files, because all users on the network can access the same data

Reduces storage costs by sharing applications on computers instead of allocating local disk space for each user application

Provides data consistency and reliability, because all users can read the same set of files

Reduces system administration overhead

Page 6: Solaris 10 administration 2 Configuring NFS

the NFS service enables you to place one copy of the files on one computer’s hard disk. All other systems can then access the files across the network.

When using the NFS service, remote file systems are almost indistinguishable from local file systems.

The NFS Environment contains the following components

-NFS Server -NFS Client

Page 7: Solaris 10 administration 2 Configuring NFS

The NFS server contains file resources shared with other systems on the network.

A computer acts as a server when it makes files and directories on its hard disk available to the other computers on the network.

NFS server shares disk storage with NFS client.

“NFS Server Configuration” shows how files and directories on an NFS server are made available to NFS clients. The NFS server is sharing the /export/rdbms directory over NFS

Page 8: Solaris 10 administration 2 Configuring NFS
Page 9: Solaris 10 administration 2 Configuring NFS

The NFS client system mounts file resources shared over the network and presents the file resources to users as if they were local files.

“NFS Client Configuration” shows how an NFS client uses the files and directories shared by an NFS server. The /export/rdbms directory, shared by the NFS server, is mounted on the NFS client on the /opt/rdbms mount point. The resource mount point exists on the NFS client, and the NFS server shares the file resources with other computers on the network

Page 10: Solaris 10 administration 2 Configuring NFS
Page 11: Solaris 10 administration 2 Configuring NFS

The machine which provides the disk files and directories to share is called the NFS server.

The machine which accesses the server is called the NFS client.

* It is possible to restrict access to a defined list of machines.* It is possible to encrypt NFS traffic using secure NFS options when mounting.* NFS activity can be logged using options to NFS shares.

Page 12: Solaris 10 administration 2 Configuring NFS

The command has several options, for example:- # share -F nfs -o ro,rw=ahmed:abada /usr * This shares /usr read-only to all machines except ahmed and abada, to which it is shared read-write.

# share -F nfs -o rw=ahmed:abada,root=ahmed /usr * This shares /usr read-write to only fa and harwell, with root access granted to the root account on harwell. * Sharing as root is dangerous; don’t be tempted to use this too frequently! # share -F nfs -o ro,anon=0 /extra/sol10 * Shares /extra/sol10 read-only, with the UID for unkown user ID access as 0, and logs accesses. * The anon=0 effectively gives all machines full root access to this share, but with ro it’s read-only.

Page 13: Solaris 10 administration 2 Configuring NFS

If the machine is already running as an NFS server, we can dispense with the “-F nfs” option when entering share commands on the command line:-

# share /opt* Default access is read-write to all known

hosts. The root option must be given a list of

machines, or an error message is generated:- "share_nfs: missing root list“

Page 14: Solaris 10 administration 2 Configuring NFS

The share command - file systems / hard slice A couple of points worth noting concerning the way NFStreats file systems/hard slices:- 1. The share command limits the sharing to the current filesystem (i.e. hard slice).

❖ Therefore, if you share "/" you are sharing only the rootslice.

❖ The fact that "/" on the server has other slices mounted within it does not mean that you will see these mounts at The NFS client end.

❖ You will see the empty mount points only. ❖ Suppose we wished to share all local hard slices; a df -k

would quickly show which slices we would need toshare:-Filesystem kbytes used avail capacity Mounted on/dev/dsk/c0t3d0s0 67663 23359 44237 35% //dev/dsk/c0t3d0s6 529294 406096 122669 77% /usr

❖ Those directories mounted from hard slices(/, /usr, /opt,/export/home) are the local file systems available to beshared

Page 15: Solaris 10 administration 2 Configuring NFS

2. Once a directory is shared, you cannot then share adirectory (in the same slice) below it; for example:-

❖ If /usr is shared, /usr/man cannot then be shared separately. (If it is on the same slice as /usr, which it probably is). You’ll get an error message:-share_nfs: /usr/man: parent-directory (/usr) already shared

❖ You may, for example, wish to do this to apply different share permissions such as read-only or read-write.

❖ You will have to share each directory below /usr on an individual basis if you wish to do this.

❖ You can share a subdirectory, if it is on a separate slice;for example, if you have shared "/", you can still share /opt and /usr. Remember: to make the shared file systems available permanently, place the share commands in /etc/dfs/dfstab. Details of file systems currently being shared are held in/etc/dfs/sharetab, but this file is maintained by the system.

Page 16: Solaris 10 administration 2 Configuring NFS

If you have updated /etc/dfs/dfstabwithout running the share commands manually, you can make them come into force by running:- # shareall

Note: shareall command read /etc/dfs/dfstab and share all uncommented share lines all

Unsharing To take a resource out of the share list, simply unshare it:- #

unshare /opt * Unshares the /opt directory# unshareall * Unshares all currently shared directories.Note: unshareall command read /etc/dfs/sharetab and unshare all it’s

values Unsharing, or changing share options, comes into effectimmediately. For example, if I am accessing an NFS mounted file system,and it is then unshared on the server, I will get the message:-Stale NFS file handle• .. if I try to access it.

Page 17: Solaris 10 administration 2 Configuring NFS

The first task is to enable our machines to be NFS servers, then we can proceed to access their files and directories as clients.

The NFS service is provided, as with many other services, by daemons which can automatically be started at boot time.(automatically when you in run level 3)

These daemons are:- ❖ nfsd this daemon provides the actual reading and writing

services. It is written using multi-threading programmingtechnniques, allowing it to handle a specified number ofconcurrent NFS requests. (16 by default - change this in/etc/default/nfs)stopping & Starting nfs daemon

this ensures that the /etc/dfs/dfstab are read and automatic sharing take place but this is not advised when users are currently using nfs share use shareall command instead.

Page 18: Solaris 10 administration 2 Configuring NFS

create a directory , share it ready for mounting and then mount it from the client machine.

we have two machines : mido server , ahmed clien

Server Side first (mido):-

Page 19: Solaris 10 administration 2 Configuring NFS

These daemons are:- ❖ mountd this daemon answers and validates mount requests from remote machines.• Under Solaris 10, the SMF facility must be employed to enable the NFS services - these are actually enabled by default. (More about this shortly)• There is a very simple condition which causes these

daemons to be started at boot time, and thus automatically configure the

machine as an NFS server:- ❖ The file /etc/dfs/dfstabmust exist, and must contain valid share commands.Note : NFS daemons will start automatically at boot time

when there are an uncommented share command in the “/etc/dfs/dfstab”

Page 20: Solaris 10 administration 2 Configuring NFS

If you have placed share entries in /etc/dfs/dfstab, and want to start NFS without rebooting:-

# svcadm enable nfs/server Starting off with our server side, NFS requires at least 4

services running (for sane usage), though possibly up to 8, depending on NFS version and features 

svc:/network/rpc/bind:default           (required)        svc:/network/nfs/status:default         (required)          svc:/network/nfs/nlockmgr:default       (required)         svc:/network/nfs/rquota:default         (optional)         svc:/network/nfs/server:default         (required)         svc:/network/nfs/mapid:default          (NFSv4, required)        svc:/network/rpc/gss:default            (NFSv4, optional)         /usr/lib/nfs/nfslogd                    (NFSv2, NFSv3, optional) we check which services are running and start those

that aren't: ex:- #svcadm enable svc:/network/rpc/bind:default

Page 21: Solaris 10 administration 2 Configuring NFS

You can also use svcadm to restart or disable NFS:-# svcadm restart nfs/server (Will not work if nfs disabled)# svcadm disable nfs/serverWe could have alternately enabled the necessary

NFS services via#svcadm enable -r svc:/network/nfs/server:defaultTo verify our exported filesystems, we can use

'dfshares', 'share', or review the contents of 'sharetab':

Note that if you omit the -F nfs option to the share command (or any NFS-related command which supports-F FSType) the

the first entry in the file /etc/dfs/fstypes is taken as the default filesystem type. The happens to be nfs in all Solaris versions.

Page 22: Solaris 10 administration 2 Configuring NFS

#svcs -a | grep nfs

Page 23: Solaris 10 administration 2 Configuring NFS

It’s not worked because of the are no not commented share entries in /etc/dfs/dfstab file

#hostname mido (server is mido , client is ahmed) So , put an entry in /etc/dfs/dfstab * Steps for sharing an entry from server side 1) #mkdir /sharedserverdir 2) #vi /etc/dfs/dfstab share -F nfs -o r0,rw=ahmed,root=ahmed /sharedserverside Note entries in /etc/dfs/dfstab is saved untill reboot , that means when reboot the server shared uncommented entries with specified clients #svcs –a | grep nfs still disabled 3) Now to run this entry without writing it again through share commans Run #shareall command 4) #svcs –a | grep nfs you will find it’s it has been enabled now For viewing shared filesyatems in the server for other clients 5) #share or #cat /etc/dfs/sharetab or #dfshares 6) #cd /sharedserverside , #echo “hello ahmed” >> test For unshareing this entry use #unshareall command that unshare all

entries exist in /etc/dfs/sharetab file , #share gives you no thing For reshareing the entries again , just run #shareall command

Page 24: Solaris 10 administration 2 Configuring NFS

share commands allow a server to make it’s disk resources available to other machines, for example:-

# share -F nfs /export/home This means:-* - any known host can mount from/export/home or anywhere underneath. To view resources that are currently being shared:- 3 ways 1) #dfshares or 2) #cat /etc/dfs/sharetab 3) # share On the server, you can use 'unshareall' to stop sharing all

exportedfilesystems and verify with 'dfshares'

- /export/home rw “ “Note: This shared resource could be made permanently available

byplacing the share command in the /etc/dfs/dfstab file.

Page 25: Solaris 10 administration 2 Configuring NFS

#hostname ahmed (client )Now that the server is setup, we can work on the client

host.  A Solaris NFS client requires at least 4 services running (for sane usage), though possibly 6 depending on NFS version

      svc:/network/rpc/bind:default           (required)         svc:/network/nfs/status:default         (required)         svc:/network/nfs/nlockmgr:default       (required)         svc:/network/nfs/client:default         (required)          svc:/network/nfs/cbd:default            (NFSv4, required)         svc:/network/nfs/mapid:default          (NFSv4, required)we check the status of the services, starting them as

needed #svcs –a | grep nfs #svcs –a | grep rpc/bindIf any of these services are not enabled , you can enable it

via #svcadm enable servicename

Page 26: Solaris 10 administration 2 Configuring NFS

use 'dfshares' to review what shares are available from the NFS server

From client(ahmed) side to see what server(mido) shares to you

# dfshares mido Note : on Server (ahmed) shared

/sharedserverdir so we on client(mido) we will mount this directory to /getsharedres

Page 27: Solaris 10 administration 2 Configuring NFS

1) test that needed services are enabled #svcs –a | grep rpc/bind #svcs –a | grep nfs if ant of this services not enabled , enable it using #svcadm -v enable “Service_name”2) Show what are the shared resources to you (client) via server (mido) #dfshares mido3) Create “mount point” the directory that you will mount the shared directory from server to it #mkdir /getsharedres #ls –ld /getsharedres drwxr-xr-x   2 root     root           2 Seb 20 03:12 /getsharedres/ #df –h4) Mount the shares resource to the mount point#mount -F nfs -o rw,bg,intr mido:/sharedserverdir /getsharedres5) Test that resource is mounted #df -h #mount #ls /getsharedres6) Try to edit shared resources #echo “thank you” >> test7) To unmount this resource , #umount /getsharedres

Page 28: Solaris 10 administration 2 Configuring NFS

For Mounting the shared resource during boot :-#vi /etc/vfstab #device      device          mount       FS      fsck    mount    mount #to mount   to fsck         point        type    pass   at boot options/devices        -               /devices        devfs   -       no       - /proc           -               /proc           proc    -       no      -   /sharedserverdir - /getsharedre nfs - yes rw,bg,intr

Unmounting shared Resource #df -h #umount /getsharedres #df –h to remount it again via /etc/vfstab#mountall -r mount all remote shared resources that has yes value at mount at boot entry #df -h

Page 29: Solaris 10 administration 2 Configuring NFS

Share from server /testagain dir with options rw,setuid and mount it to /clientgetdir in the client and …. ??????????

Note we can start client services using svcs

nfs/client,not by restart nfs/server service.

Page 30: Solaris 10 administration 2 Configuring NFS

to share a filesystem :1) edit the /etc/dfs/dfstab and type in the followingshare -F nfs -o rw=client mountpoint of shared filesystemNoterw means read write permission use the right permission that will serve your need. it could be ro (read only). client is the client machine

mountpoint of shared filesystem is the mount point of where your intent share resource liveeg /export/home or /var/mail (directory you share )

finally 2) stop and start nfs daemon to make change take effectyou could stop and start nfs by issuing

#/etc/init.d/nfs.server stopfollowed by#/etc/init.d/nfs.server start

make sure nfs daemon is start by issuing#ps -ef | grep nfsthis should show statd and lockd running.

the statd and lockd must be running on server and client

Page 31: Solaris 10 administration 2 Configuring NFS

You might read in the internet that you can share resources using current method

1) share /mountpoint_folderand then on the client run the command2) mount -F nfs server1:/mountpoint_folder /newfolder

Comment about this way the share /mountpoint_folder work fine but this is manual sharing

if the server crash or get rebooted for what ever reasonthe sharing will be lost.

, while an entry in /etc/dfs/dfstab file are shared automatically whenever you start nfs daemon or when the system enter run level 3

- the -F switch allow you specify the filesystem type (FSTYPE) they are different type of filesystem in unix e.g ufs, nfs in this case it is nfs- the -o switch allows you to spacify permission for security reason.

* stopping & Starting nfs daemonthis ensures that the /etc/dfs/dfstab are read and automatic sharing take place but this is not advised when users are currently using nfs share use shareall command instead.

Page 32: Solaris 10 administration 2 Configuring NFS

1. Determine the NFS version:To determine what version and transport of NFS is currently available, run rpcinfo on the NFS server.# rpcinfo -p | grep 100003100003 2 udp 0.0.0.0.8.1 nfs superuser , 100003 3 udp 0.0.0.0.8.1 nfs superuser100003 2 tcp 0.0.0.0.8.1 nfs superuser , 100003 3 tcp 0.0.0.0.8.1 nfs superuserthe second column above is the NFS version, the third column is the transport protocol.Sun has implemented the following versions of NFS on it’s operating systems, for both client and server:*The UDP transport is not supported in NFSv4, as it does not contain the required congestion control methods OS VersionNFSv2NFSv3NFSv4

SunOSUDP  

Solaris[TM] 2.4 and belowUDP  

Solaris[TM] 2.5,2.6,7,8,9

UDP and/or TCP

UDP and/or TCP 

Solaris[TM] 10

UDP and/or TCP

UDP and/or TCPTCP*

Page 33: Solaris 10 administration 2 Configuring NFS

2.  Check the Connectivity for NFS Server from NFS client:1.   Check that the NFS server is reachable from the client by running:#/usr/sbin/ping2.   If the server is not reachable from the client, make sure that the local name service is running. For NIS+ clients:#/usr/lib/nis/nisping -u3.   If the name service is running, make sure that the client has received the correct host information -# /usr/bin/getent hosts4.   If the host information is correct, but the server is not reachable from the client, run the ping command from another client.5.   If the server is reachable from the second client, use ping to check connectivity of the first client to other systems on the local network. If this fails, check the networking configuration on the client. Check the following files:/etc/hosts, /etc/netmasks, /etc/nsswitch.conf,/etc/nodename, /etc/net/*/hosts etc.6.   If the software is correct, check the networking hardware.Additionally you can refer the “NFS Hard mounts vs Soft Mounts”

Page 34: Solaris 10 administration 2 Configuring NFS

3.  From the Server, Verify Service Daemons are runninga) confirm S10 smf  network nfs server services are online:# svcs -a |grep nfsb) statd ,  lockd , mountd and nfsd processes should be running:# ps -elf |grep nfsc) compare the times when nfsd and mountd started  with the timewhen rpcbind was started. The rpcbind MUST have started before the  NFS Daemons.d) verify that the NFS programs have been registered with rpcbind:# rpcinfo -sto confirm specific RPC service use the following commands:# rpcinfo -t 100003# rpcinfo -t 100005# rpcinfo -t 100021e) logging may be enabled (not for NFSv4).

Page 35: Solaris 10 administration 2 Configuring NFS

On the client:a) confirm S10 smf  network nfs client services are online:# svcs -a |grep nfsb)  statd ,  lockd  should be running# ps -elf |grep nfsc) You can verify the server is working from the client side.# rpcinfo -s |egrep ?nfs|mountd|lock?# rpcinfo -u 100003# rpcinfo -u 100005# rpcinfo -u 100021

Page 36: Solaris 10 administration 2 Configuring NFS

4. Confirm proper syntax of  dfstab share entries on NFS server.Solaris OS defines shared (or exported) filesystems in the /etc/dfs/dfstab  file.  The standard syntax of lines in that file is:share [-F fstype] [ -o options] [-d ""] [resource]For example, the following /etc/dfs/dfstab file is for a server that makes available the filesystems /usr, /var/spool/mail and /home:share -F nfs /usrshare -F nfs /var/spool/mailshare -F nfs /homeYou can add normal mount options to these lines, such as ro, rw and root.  This is done by proceeding the options with a -o flag.  The following example shows our /etc/dfs/dfstab file, with all filesystems shared read only:share -F nfs -o ro /usrshare -F nfs -o ro /var/spool/mailshare -F nfs -o ro /homeTo add new shares to existing ones, simply run the shareallcommand:# shareallThis will share ALL filesystems available in the /etc/dfs/dfstab file. If you have never shared filesystems from this machine before, youmust run the nfs.server script:# /etc/init.d/nfs.server startThis will run the shareall(1M) command and start the nfs daemons, mountd(1M), and nfsd. The “nfs.server start” procedure is also run on bootup, when the system enters run level 3.

Page 37: Solaris 10 administration 2 Configuring NFS

5. Confirm file system is shared as seen on both ends.The NFS server is the system that will share a file system. The #showmount-e or #dfshares command will display what  is being shared.  From the client use command with nfs server name.# showmount -eNote: that NFSv4 does not use mountd. If mountd is not running,  showmount will not work. 6. Verify mount point exists and is in useTo display statistics for each NFS mounted file system, use the command #nfsstat -m. This command will also tell you which options were used when the file system was mounted. You can also check the contents of the /etc/mnttab. It should show what is currently mounted. Lastly, check the dates between the server and the client. An incorrect date may show the file created in the future causing confusion

Page 38: Solaris 10 administration 2 Configuring NFS

Thank You