In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to use NFS in centos7. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
NFS is the abbreviation of Network File System, that is, the network file system. The client mounts the data directory shared by the NFS server to the local directory.
Why does nfs need RPC?
Because NFS supports many functions, different functions will be started by different programs, so the corresponding port of the corresponding function of NFS can not be fixed.
Irregular ports cause communication barriers between the client and the server, so RPC is needed to help.
When NFS starts, it will randomly access several ports, and then actively register with the RPC service for access to relevant port and function information. RPC uses fixed port 111to listen for requests from NFS clients.
And return the correct NFS service port information to the client, so that the client and the server can carry out data transmission.
II. The work flow of NFS
1. The program initiates the request for file access in the NFS client, and the local RPC (rpcbind) service on the client side sends the request for file access function to the RPC port 111of the NFS server through the network.
2. The RPC of the NFS server finds the corresponding registered NFS port and notifies the client of the RPC service.
3. The client gets the correct port and accesses the data online with NFS daemon.
4. After successfully accessing the data, return to the front-end access program to complete an access operation.
So whether the client or server needs to use NFS, the RPC service must be installed.
The RPC service of NFS is named rpcbind under portmap,Centos6 under Centos5.
3. Installation and configuration of NFS service
Nfs-utils 、 rpcbind
Check to see if NFS is installed
> rpm-qa nfs-utils rpcbind > yum install nfs-utils rpcbind
Start the rpcbind service
View service status
> systemctl status rpcbind.service
If you don't know where the rpcbind command is,
> which rpcbind
Start the rpc service
> systemctl restart rpcbind.service
View rpc
> lsof-I: 111 > netstat-lntup | grep rpcbind
If-bash does not find a command, execute the following command
> yum install net-tools lsof
View the port information that the nfs service registers with rpc
> rpcinfo-p localhost
Check to see if rpcbind is booted
> chkconfig-- list rpcbind
Start the NFS service
> systemctl start nfs.service
View statu
> systemctl status nfs.service
View the port information registered by rpc again
> rpcinfo-p localhost
VI. Detailed explanation of common processes in NFS
> ps-ef | egrep "rpc | nfs" rpc 101101 10 17:11? 00:00:00 / sbin/rpcbind-wrpcuser 101188 17:22? 00:00:00 / usr/sbin/rpc.statd-- no-notifyroot 101190 20 17:22? 00:00:00 [rpciod] root 101200 10 17:22? 00:00:00 / usr/sbin/rpc.idmapdroot 101201 10 17:22? 00:00:00 / usr / sbin/rpc.mountdroot 101206 20 17:22? 00:00:00 [nfsd4] root 101207 20 17:22? 00:00:00 [nfsd4_callbacks] root 101213 20 17:22? 00:00:00 [nfsd] root 101214 20 17:22? 00:00:00 [nfsd] root 101215 20 17:22? 00:00:00 [nfsd] root 101216 20 17:22? 00 00:00 [nfsd] root 101217 20 17:22? 00:00:00 [nfsd] root 101218 20 17:22? 00:00:00 [nfsd] root 101219 20 17:22? 00:00:00 [nfsd] root 101220 20 17:22? 00:00:00 [nfsd] root 101243 1008300 17:28 pts/0 00:00:00 grep-E-- color=auto rpc | nfs
The main process of nfsd (rpc.nfsd) is to manage whether the client can log in to the server or not, and the login is judged by the ID.
Mountd (rpc.mountd) manages the NFS file system, and login rights management
Rpc.lockd (unnecessary) is used to lock files for clients to write at the same time
Rpc.statd (unnecessary) check file consistency
Rpc.idmapd name mapping background process
7. Configure NFS to boot automatically
> chkconfig rpcbind on > chkconfig nfs on > chkconfig-- list rpcbind > chkconfig-- list nfs
VIII. NFS server configuration
> vi / etc/exports
Exports file configuration format:
NFS shared directory NFS client address 1 (parameter 1, parameter 2.) Client address 2 (parameter 1, parameter 2, etc.)
Description:
NFS shared directory:
To use an absolute path, it can be read and written by nfsnobody.
NFS client address:
Specify IP: 192.168.0.1 all hosts in the specified subnet: 192.168.0.0and24 hosts in the specified domain name: test.com all hosts in the specified domain: * .test.com all hosts: *
Parameters:
Ro: directory read-only
Rw: directory read and write
Sync: write data synchronously to memory buffers and disks, which is inefficient, but can ensure data consistency.
Async: save the data in a memory buffer before writing to disk if necessary
All_squash: maps all ordinary users and groups that are accessed remotely to anonymous users or user groups (nfsnobody)
No_all_squash: inverted from all_squash (default)
Root_squash: map root users and their groups to anonymous users or user groups (default)
No_root_squash: inverted from rootsquash
Anonuid=xxx: maps all users accessed remotely to anonymous users and specifies the user as a local user (UID=xxx)
Anongid=xxx: maps all user groups accessed remotely to anonymous user group accounts
For example:
/ data/tmp 192.168.1.0 Compact 24 (rw,sync,all_squash)
Create directories that need to be shared
> mkdir-p / data/tmp > chown nfsnobody.nfsnobody / data/tmp
Reload the nfs configuration
> exportfs-rv
Check the mount status of nfs server
Showmount-e localhost
IX. Mounting test
> mkdir-p / data/tmp2 > mount-t nfs 192.168.1.233:/data/tmp / data/tmp2
View mount
> df-h
Create a file under tmp
> touch / data/tmp/1.txt
Check to see if there are files under tmp2
> ls / data/tmp2
Unmount
> this is the end of the umount / data/tmp2 article on "how to use NFS in centos7". I hope the above content can be helpful to you so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.