I. Introduction TO Services for NFS
NFS is the abbreviation for the network file system, which is the web filesystem. A contract for the decentralized file system, developed by Sun, was announced in 1984. Function: To enable different machines, different operating systems to share individual data with each other through the network, so that the application can access the data on the server's disk through the network, is a way to realize disk file sharing among Unix-like systems.
The basic principle of NFS is to "allow different clients and services to share the same file system through a set of RPCs", which is independent of the operating system, allowing different hardware and operating systems to share files together.
NFS relies on the RPC protocol during file transfer or information transfer. RPC, a remote procedure call is a mechanism that enables clients to perform other system programs. NFS itself does not provide the protocol and functionality for transmitting information, but NFS allows us to share information over the network, because NFS uses some other transport protocols. This RPC function is used by these transport protocols. It can be said that NFS itself is a program that uses RPC. Or, NFS is an RPC SERVER. So as long as the NFS place must start the RPC service. Summary: NFS is just a file system, and RPC is responsible for the transmission of information.
Ii. installation of NFS services
NFS requires two packages
nfs-utils-* includes basic NFS commands and monitoring programs
rpcbind-* support for secure NFS RPC Service Connections
1. Check if NFS is installed on the system
Rpm-qa|grep NFS
Rpm-qa|grep Rpcbind
if not, first yum grouplist yum groupinstall "NFS"
Third, NFS server configuration
NFS Common Directory
/etc/exports Primary configuration file for NFS services
/usr/sbin/exportfs Management commands for NFS services
/usr/sbin/showmount Client View commands
/var/lib/nfs/etab record full permission SetPoint for NFS-shared directory
/var/lib/nfs/xtab Logging of client information that has been logged on
The NFS service configuration file is /etc/exports, the system does not have a default value, so this file does not necessarily exist, you can use vim to build it manually, and then write the configuration content in the file.
/etc/exports File content format:
< output directory > client 1 Options (access rights, user mappings, other) "Client 2 option (access rights, User mapping, other) "
A. output directory: The output directory refers to the directory that needs to be shared with the client in the NFS system
B. client: A computer in the network that can access this NFS output Directory
the client is commonly used in the specified manner:
Specify the IP address of the host:192.168.0.200
specify all hosts in the subnet:192.168.0.0/24 192.168.0.0/255.255.255.0
host of the specified domain name:david.bsmart.cn
specify all hosts in the domain name:*.bsmart.cn
All hosts:*
C. options: Used to set the output Directory access rights, user mappings, etc.
There are 3 main types of NFS options:
Access Permissions Options
Set Output Directory read-only:ro
Set Output directory Read/write:RW
User mapping Options
All_squash: maps all normal and owning groups for remote access to anonymous users or groups of users (nfsnobody)
No_all_squash: Opposite to all_squash (default setting)
Root_squash: to map root users and their owning groups to anonymous users or user groups
No_root_squash: Contrary to the above
ANONUID=XXX: maps All remote access users to anonymous users and specifies that the user is a local user
Anongid=xxx: Maps All remote Access user groups to anonymous user group accounts and specifies that the anonymous user group account is a local user group account
Other options (ignore, with default values)
Iv. start and stop of server for NFS
After you have configured the/etc/exports file correctly, you can start the NFS server.
1. start the NFS server
in order for the NFS server to work properly, you need to start rpcbind and NFS Two services, and Rpcbind Be sure to start on NFS First
Service Rpcbind Start
Service NFS Start
2. querying Server Status for NFS
Service Rpcbind Status
Service NFS Status
3. Stop server for NFS
To Stop NFS, Stop NFS before stopping the rpcbind Service for other services in the system such as NIS need to be used without stopping Rpcbind Service
Service NFS Stop
Service Rpcbind Stop
4. set the auto-start Status for NFS server
Chkconfig--add
Chkconfig--level 35
V. Examples
1. share the/home/cairui of NFS server to 192.168.66.128, read and Write permissions
#vim/etc/exports
/home/cairui 192.168.66.128/24 (rw)
2. restart Rpcbind and NFS Services
Service Rpcbind Restart
Service NFS Restart
Exportfs
3. server-side query NFS shared status using the Showmount command
Showmount-e
Showmount-a Displays directory information that is already connected to the client
4. client uses the showmount command to query The shared status of NFS
SHOWMOUNT-E Service-side IP
5. Client Mounts A shared directory in server for NFS
command format:mount NFS server IP: Shared directory local mount point directory
To see if the mount succeeds:mount|grep NFS
See if the file is consistent with the server side
Sharing permissions and access control for 6.NFS
Modify permissions on the server /home/cairui make the client writable, readable
chmod 777-r/home/cairui
6. uninstalling the mounted NFS shared directory
format:Umount/tmp/cai
Eight Start automatic Mount NFS file system
format:<server>:<remote/export>
</local/directory> NFS <option> 0 0
#vim/etc/fstab
Added after the last act
Save exit, restart System
Linux NFS Network File system