Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The use of Network File system (NFS)

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

one. Brief introduction

NFS--Network FileSystem, that is, the network file system, the main function is to enable different operating systems on the network to share data.

The files or directories are shared by the remote server, and then the files or directories shared by the remote carbonyl can be mounted to different operating systems, and finally the local system can easily use the remote file service. Realize data sharing

As you can see in the figure above, NFS consists of two parts: the NFS client and the NFS server.

two. Realization principle

After the NFS server starts, open the port number corresponding to the client connection (1-1024), but each time you start the NFS server, the corresponding server port number is different.

To ensure that the client connects correctly each time, NFS assists the NFS server with the connection through the RPC (Remote Procedure Call) protocol. A program requests services from a program on another computer in the network by using this protocol. In NFS, the main function of RPC is to specify and monitor the corresponding commodity number of the NFS daemon, and notify the client of the port information, so that the client can connect to the correct port.

three. Installation and configuration

1. To see if it is installed:

Rpm-qa | grep rpcbind

Rpm-qa | grep nfs

If there is no output, the rpm package corresponding to NFS is required to install.

2.NFS server-side settings

Setting profile: / etc/exports

Format: shared resource path [host address] [option]

Example: / webdata * (sync,rw,all_squash)

/ tmp * (rw,no_root_squash)

/ home/share 192.168.1 * (rw,root_squash) * (ro)

/ opt/data 192.168.1.18 (rw)

/ usr/local/doc * .ixdba.net (rw, anonuid=686,anongid=686)

Description: shared resource path: such as / tmp, / home/share directory above

Host address: can be hostname / domain name / IP, etc.

Options:

Ro:read only, the client only has read permission

Rw:read write

No_root_squash: according to the user UID, if the user logging in to the NFS host is root, then

The user has the highest privileges. Not safe, not recommended

Root_squash: the system default value, when logging in to the user root of the NFS host, the user's permissions will be reduced to anonymous users. Both UID and GID become nfsnobody identities with only readable permissions.

All_squash: no matter who logs in to the NFS host, the UID and GID of the shared file are mapped to the anonymous user nfsnobody.

No_all_squash: only when the client user's UID and GID are the same as the server's shared file UID and GID, do they have read and write permissions to the shared file, ensuring that the user and group permissions of the shared file will not be changed.

Anonuid: set all users who log in to the NFS host to the specified UID. This UID must exist in the NFS server / etc/passwd

Anongid: similar to anonuid

Sync: data is written to disk synchronously. Default

Async: data is temporarily stored in memory and is not directly written to disk

two。 Start and stop the NFS server

Systemctl start/stop/restart/enable nfs

Systemctl start/stop/restart/enable rpcbind

Start: start

Stop: off

Restart: restart

Enable: server boot self-boot

Turn off the firewall

Systemctl stop firewalld

Systemctl disable firewalld

Settings of 3.NFS client

Install nfs-utils and rpcbind services

Yum-y install nfs-utils

Systemctl start rpcbind

Systemctl enable rpcbind

View the services provided by the NFS server

Showmount [- ea]

-e: this option is followed by the server host address to display the currently exported directory

-a: there are no parameters after use on the server; when the client uses it, follow the server host address

Mount a shared resource mount

Mount-t nfs Hostname (orIP): / directory / mountpoint

Hostname: specify the NFS server address

/ directory: represents the directory resources shared by the NFS server

/ mountpoint: the mount point specified by the client host

Automatically mount the NFS directory on boot

192.168.60.133:/mydata / data/nfs nfs default 0 0

Uninstall the NFS directory

Umount / mountpoint

Safety setting

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report