Wednesday, December 31, 2008

NFS server configuration on solaris 10

The network file system (NFS)

NFS iss the system that can be used to access file systems over the network. NFS version 4 is the default NFS in Solaris 10. The NFS service is managed by the Service Management Facility. That means NFS can be managed (enabled, disabled, or restarted) by the svcadm command, and the status of NFS service can be obtained by using the svcs command. The benefit here is sharing files over the network among computers possibly running different operating systems.

The NFS Service

The NFS service is a network service that enables computers of different architectures running different operating systems to share file systems across the network. A wide spectrum of operating systems ranging from Windows to Linux/UNIX support NFS. It has become possible to implement the NFS environment on a variety of operating systems because it is defined as an abstract model of a file system, rather than an architectural specification. Each operating system applies the NFS model to its specific file system semantics. This means that file system operations such as reading and writing work for the users as if they were accessing a file on the local system.

The benefits of the NFS service are described here:

1) It enables users on the network to share data, because all computers on the network can access the same set of files.

2) It reduces storage costs by letting computers share applications and common files instead of needing local disk space on each computer for each common file and user application.

3) It provides data consistency and reliability, because all users can read the same set of files, and whenever changes are made, they are made only at one place.

4) It makes the mounting of file systems accessing the remote files transparent to users.

5) It supports heterogeneous environments and reduces system administration overhead.

NFS is a network service offered in the client/server environment

NFS Servers and Clients

The NFS is a client/server system, the terms client and server refer to the roles that computers assume in sharing resources (file systems in this case) on the network. In NFS, computers that make their file systems available over the network and thereby offer NFS service to serve the requested files are acting as NFS servers, and the computers that are accessing the file systems are acting as NFS clients. In the NFS framework, a computer on a network can assume the role of a client, a server, or both.

Here is how NFS works:

A server makes a file system on its disk available for sharing, and the file system can then be accessed by an NFS client: on the network.

A client accesses files on the server's shared file system by mounting the file system.

The client does not make a copy of the file system on the server; instead, the mounting process uses a series of remote procedure calls that enable the client to access the file system transparently on the server's disk. To the user, the mounting works just like a mount on the local machine.

Once the remote file system (on the server) is mounted on the client machine, the user types commands as though the file systems were local.

You can mount an NFS file system automatically with autoFS.

The NFS File Systems

In most UNIX system environments, a file hierarchy that can be shared by using the NFS service corresponds to a file system or a portion of a file system. However, a file system resides on a single operating system, and NFS support works across operating systems. Moreover, the concept of a file system might be meaningless in some non-UNIX environments. Therefore, the term file system in NFS refers to a file or a file hierarchy that can be shared and mounted in the NFS environment.

An NFS server can make a single file or a directory subtree (file hierarchy) available to the NFS service for sharing. A server cannot share a file hierarchy that overlaps with a file hierarchy that is already being shared. Note that peripheral devices such as modems and printers cannot be shared under NFS.

Managing NFS

Since the release of Solaris 9, the NFS server starts automatically when you boot the system. Nevertheless, you do need to manage NFS, which includes administering the NFS service, working with NFS daemons, and making file systems available for sharing.

Administering the NFS Service

When the system is booted, the NFS server is automatically started by executing the nfs.server scripts. However, when the system is up, you may need to stop the service or start it again for whatever reason without rebooting the system. For that, you need to know that the NFS service is managed by the Service Management Facility (SMF) under the identifier network/nfs/server. By means of this identifier, you can find the status of the service by using the svcs command, and you can start (enable) or stop (disable) the service by using the svcadm command.

You can determine whether the NFS service is running on your machine by issuing the command shown here:

# svcs network/nfs/server

This command displays whether the NFS service is online or disabled. If you want to stop (disable) the service, issue the following command:

# svcadm disable network/nfs/server

You can start the service by issuing the following command:

# svcadm enable network/nfs/server

When the system is up, some daemons are running to support the NFS service.

Working with NFS Daemons

Since the release of Solaris 9, NFS service starts automatically when the system is booted. When the system goes into level 3 (or multiuser mode), several NFS daemons are started to support the service.

Daemons automatically started in NFS version 4 when the system boots Daemon

Description

automountd - Handles mount and unmount requests from the autofs service.

nfsd - Handles file system requests from clients.

nfs4cbd - Manages the communication endpoints for the NFS version 4 callback program.

nfsmapid - Provides integer-to-String and string-to-integer conversions for the user ID (UID) and the group ID (GID).

The nfsd daemon handles the file system requests from the client and is automatically started with option -a. You can change the parameters of the command by editing the /etc/default/nfs file. The syntax for the nfsd command is as follows:

nfsd [-a] [-c {#_conn}] [-l {listenBacklog}] [-p {protocol}] [-t {device}]
[{nservers}]

The options and parameters are described here:

-a. Start the daemon over all available connectionless and connection-oriented transport protocols such as TCP and UDP. This is equivalent to setting the NFSD_PROTOCOL parameter in the nfs file to ALL.

-c (#_conn.) Set the maximum number of connections allowed to the NFS server over connection-oriented transport protocols such as TCP. By default, the number is unlimited. The equivalent parameter in the nfs file is NFSD_MAX_CONNECTIONS.

-l (listenBacklog). Set the connection queue length (specified by (listenBacklog)) for the number of entries for the NFS TCP. The default value is 32. This number can also be determined by setting the NFSD_LISTEN_BACKLOG parameter in the nfs file.

-p (protocol). Start the daemon over the protocol specified by (protocol). The default in NFS version 4 is TCP. The equivalent parameter in the nfs file is: NFSD_PROTOCOL.

-t (device). Start an nfs daemon for the transport specified by . The equivalent parameter in the nfs file is: NFSD_DEVICES.

(nservers). Set the maximum number of concurrent requests from the clients that the NFS server can handle. The equivalent parameter in the nfs file is: NFSD_SERVERS.


The default NFS version is version 4 in Solaris 10, Unlike previous versions of NFS, NFS version 4 does not use these daemons: lockd, mountd, nfslogd, and statd

Sharing File Systems

On the server machine, you can make a file system available for sharing by using the share command on the machine. You can use this command manually for testing purpose or to make a file system available only until the system is rebooted. If you want to make the sharing of a file system permanent and automatic, you should enter the share command into the /etc/dfs/dfstab file. Each entry of this file is a share command, and this file is automatically executed at boot time when the system enters run level 3. The syntax for the share command is shown here:

share [-F (FSType)] [-o (specificOptions)] [-d (description)] [(pathname)]

The options are described here:

-F (FSType). Specifies the file system type, such as nfs.

-o (specificOptions). The (specificOptions) specifies the options for controlling access to the shared file system. The possible values for (specificOptions) are as follows:

rw. Read/write permissions for all clients. This is the default behavior.

rw = (client1):(client2). . . . Read/write permission for the listed clients; no access for any other client.

ro. Read-only permission for all clients.

ro = (client1):(client2). . . . Read-only permission for the listed clients; no access for any other client.

-d (description). The (description) specifies the description for the shared resource.

If you want to know the resources being shared on the local server, issue the dfshares command without any arguments or options.


Files related to the NFS service

/etc/default/autofs - Configuration information for autofs.

/etc/default/fs - Lists the default file system type for local file systems.

/etc/default/nfs - Configuration information for the nfsd daemon.

/etc/dfs/dfstab - Contains a list of local resources to be shared; the share commands.

/etc/mnttab - Lists file systems that are currently mounted.

/etc/dfs/sharetab - Lists the local and remote resources that are shared.

/etc/vfstab - Defines file systems to be mounted locally.

Some Examples how to share files in NFS

# vi /etc/dfs/dfstab

share -F nfs -o ro,anon=0 /cdrom/sol_10_305_sparc/s0/Solaris_10/Tools - to share the cdrom OS software and read only permission.

share -F nfs -o rw,anon=0 /cdrom - to share files with read and write permission and anon=0 means access to all hosts.

share -F nfs -o rw=hostname1 /cdrom - to give access to only one host.

share -F nfs -o rw=-hostname1 /cdrom - to deny this hostname1 and access to all.

share -F nfs -o rw=hostname1 hostname2 /cdrom - access to hostname1 and hostname2

share -F nfs -o rw=-hostname1 -hostname2 /cdrom - deny hostname1 and hostname2 and allow access to all computer in the network.

wq!

# Shareall (or)
#exportfs -va - to export the filesystem

#share - to see the files shared in nfs and which are exported currently

Client side mount the shared File system

# mount -f nfs hostname1:/cdrom /cdrom - mount shared file directory to local directory.

# cd /cdrom
# ls

8 comments:

Anonymous said...

Please provide few more questions and answers on AutoFS on Solaris-10

Anonymous said...

Hi,
My self is Praveen, I request in you to provide few more questions and answers on AutoFS on Solaris-10.

saikrishna.K said...

how to find out, how many users are accessing nfs mount point in solaris-10

Naveen Kumar said...

netstat | grep nfs
netstat | grep nfsd | wc -l
showmounts also can be used


To find how many clients connected to nfs servers

Unknown said...

i want to know when we are mounting using mount-F nfs ....

then i get read only permissions for that host's share..i want this with write permissions..how is that possible..please mail me at zoom2vikjain@gmail.com

Thanks

nagu said...

HAI PLEASE POST NFS REAL TIME INTERVIEW QUESTIONS

nagu said...

Please post NFS Real time interview questions and problems

Unknown said...

This is amazing all the things you do!
Thank you so much!

Common Interview Questions

Custom Search

Feeds from my other blog

Samsung S2 Brand new for 25900 White piece sealed box

For Sale, Mobile Phones - Accessories in India, Andhra Pradesh, Hyderabad. Date September 17

For Sale in Hyderabad