Summary of principles and mount mounts for Server for NFS

Source: Internet
Author: User
Tags root access nfsd

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. The function is to enable different machines, different operating systems to share individual data with each other, so that the application can access the data on the server disk through the network, and it is a way to implement 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 RPC", 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, remote procedure invocation (Procedure call) is a mechanism that enables clients to perform programs in other systems. 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. And these transport protocols are used for this RPC function. It can be said that NFS itself is a program that uses RPC. Or, NFS is also an RPC SERVER. So whenever you use NFS, you start the RPC service, whether it's NFS server or NFS CLIENT. This allows the server and client to implement the program port correspondence via RPC. You can understand the relationship between RPC and NFS: NFS is a file system, and RPC is responsible for the transfer of information.

Where the NFS server is set up to share the/home/shares (can be other directories) This directory, the other clients can mount this directory to their own system/mnt/nfs mount point (mount point can be customized), as long as the PC1 system into the/mnt/ NFS directory, you can see all the data under the/home/shares directory in the NFS server system (with appropriate permissions),/home/shares is like a partition (but not disk space) in your own PC. Users can use the CP, CD, MV, RM, and other disk or file-related instructions to operate. Although NFS has its own protocol and port number, NFS uses the remote procedure call (Procedure CALL,RPC) protocol to assist in the operation of NFS itself when transmitting data or other related information. RPC is a remote process call. When using some services for remote online, the host's IP address, service port number and corresponding to the service PID and other information needs to be managed and corresponding, the management port corresponding to the service-related work is RPC's task.

NFS itself does not provide a protocol for data transfer, so NFS uses RPC to implement network transport capabilities. NFS itself is a program that uses RPC, in other words, NFS is the RPC server. Of course, not only the server running NFS needs to start the RPC service, to mount the NFS file system client, you also need to synchronously start RPC, so that the server side and the client can be RPC protocol into the port of the corresponding, Linux system by default when the service starts.

The installation of NFS is very simple, requires only two packages, and is normally installed as the default package for the system.

    • nfs-utils-*: Includes basic NFS commands and monitoring programs
    • portmap-*: Support for secure NFS RPC Service connections

1, the installation of the package

Yum Install-y Portmap
Yum Install-y nfs-utils

After installing Portmap through Yum or RPM, the following error was found executing the command service Portmap start times: portmap:unrecognized service.
CentOS6 (Linux Kernel 2.6.32), Portmap has been replaced by Rpcbind, carefully review the installation information will find that the execution of the command yum install Portmap when installed is rpcbind.


After the installation, then the configuration file is modified.

Server-side profile/etc/exports: Specify the directories and permissions that you want to share, such as:
/home/work 192.168.11.* (Rw,sync,root_squash)
/home 192.168.1.105 (Rw,sync)
/public * (Rw,sync)

Each line of the configuration file is divided into two segments: the first segment is the shared directory, the absolute path is used, and the second segment is the client address and permissions.
Addresses can use full IP or network segments, such as 10.0.0.8 or 10.0.0.0/24,10.0.0.0/255.255.255.0, of course, you can use host names, DNS-resolved, and local-/etc/hosts-resolved rows, which support wildcards such as: *. Chengyongxu.com

Permissions are:
Rw:read-write, can read and write, note that this is only set to read and write client or not write properly, but also to set the permissions of the shared directory correctly, refer to question 7
Ro:read-only, read-only;
Sync: The file is written to both the hard disk and memory;
Async: Files are staged in memory instead of directly to memory;
No_root_squash:nfs the client connects to the server, if root is used, it also has root access to the directory shared by the server. Obviously it's not safe to turn it on.
Root_squash:nfs the client connects to the server, if root is used, then the directory shared by the server, with anonymous user rights, usually he will use nobody or nfsnobody identity;
All_squash: Regardless of which user is used by the NFS client to connect to the server, the directory shared by the server has anonymous user rights;
Anonuid: The UID value of the anonymous user, usually nobody or nfsnobody, can be set at this point;
Anongid: The GID value of the anonymous user.
What I'm using:
Vi/etc/exports
/home 192.168.11.* (rw)

2. Set the auto-start Status for NFS server


For the actual application system, it is unrealistic to manually start the NFS server after each boot of the Linux system, and it is necessary to set the system to automatically start the Portmap and NFS services at the specified runlevel.

# chkconfig--list Portmap
# Chkconfig--list NFS

3. Set Portmap and NFS services to start automatically at System run level 3 and 5.

# chkconfig--level Portmap on
# Chkconfig--level NFS on


NFS System Daemon

    • NFSD: It is the basic NFS daemon, the main function is to manage whether the client can log on to the server;
    • Mountd: It is the RPC installation daemon, and the primary function is to manage the NFS file system. After the client has successfully logged on to the NFS server through NFSD, it must also authenticate with the file usage permissions before using the files provided by the NFS service. It reads the NFS configuration file/etc/exports to compare client permissions.
    • Portmap: The main function is to do port mapping work. When a client attempts to connect and use a service provided by the RPC server, such as an NFS service, PORTMAP provides the managed port to the client, which enables the client to request services from the server through that port.

Server for NFS start and stop

After you have configured the exports file correctly, you can start the NFS server.


Service Rpcbind Start
Service NFS Start
Restarting Portmap and NFS services
Service Portmap Restart
Service NFS Restart
Exportfs

In this way, the NFS server is set up, and if you need a client to share his directory, you need to execute such a command on the client:

Mount 192.168.11.210:/home/wow/mnt/wow/config

It is equivalent to mount the/home/wow of the 192.168.11.210 (NFS server) to the/mnt/wow/config directory for file sharing

Where the NFS server is set up to share the/home/shares (can be other directories) This directory, the other clients can mount this directory to their own system/mnt/nfs mount point (mount point can be customized), as long as the PC1 system into the/mnt/ NFS directory, you can see all the data under the/home/shares directory in the NFS server system (with appropriate permissions),/home/shares is like a partition (but not disk space) in your own PC. Users can use the CP, CD, MV, RM, and other disk or file-related instructions to operate. Although NFS has its own protocol and port number, NFS uses the remote procedure call (Procedure CALL,RPC) protocol to assist in the operation of NFS itself when transmitting data or other related information.

Summary of principles and mount mounts for Server for NFS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.