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

How to configure NFS in Linux system

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article will explain in detail how to configure NFS in the Linux system. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

About NFS: NFS is an acronym for Network File System, that is, the network file system. A protocol for distributed file systems developed by Sun and published in 1984.

The function is to enable different machines and different operating systems to share individual data with each other through the network, and to let applications access the data located in the server disk through the network. It is a method to realize disk file sharing among Unix-like systems.

Linux system configuration NFS detailed steps: 1. The environment is ready to configure 2. 0 with the user name [root@doudou ~] ip:192.168.24.181/24 as the server and the user name [root@linfan ~] ip:192.168.24.132/24 as the client server. Basic environment configuration shuts down firewalld firewall [root@doudou ~] # systemctl disable firewalld [root@doudou ~] # systemctl stop firewalld closes selinux [root@doudou ~] # sed-ri'# ^ SELINUX=#cSELINUX=Disabled' / etc/selinux/config [root@doudou ~] # setenforce 0 installs NFS-Server// installs nfs service main program [root@doudou ~] # yum-y install nfs-utils rpcbind3. Start NFS-server// to start the rpcbind service And check the rpc registration information [root@doudou ~] # systemctl start rpcbind [root@doudou ~] # systemctl enable rpcbind [root@doudou ~] # systemctl start nfs-server [root@doudou ~] # systemctl enable nfs-server [root@doudou ~] # rpcinfo-p localhost program vers proto port service 100000 4 tcp portmapper 100000 3 tcp 100000 2 tcp 100000 portmapper 100000 4 udp 111 portmapper 100000 3 udp 111 portmapper 100000 2 udp 111 portmapper4. Check the NFS-related processes running in the system [root@doudou ~] # ps-ef | egrep "rpc | nfs" 5.NFS server configuration shared directory editing nfs main configuration file, shared directory linfan to 192.168.24.132 Universe 24, read / write, unified user

[root@doudou ~] # vi / etc/exports / data 192.168.24.132 go 24 (rw,sync,all_squash) create directories that need to be shared

[root@doudou ~] # mkdir / data restart the NFS-server service to see if the shared file exists

[root@doudou ~] # systemctl restart nfs-server [root@doudou ~] # cat / var/lib/nfs/etab / data 192.168.24.132 rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=65534,anongid=65534,sec=sys,secure,root_squash,all_squash 24 (rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,all_squash,no_subtree_check,secure_locks,acl,no_pnfs,anonuid=65534,anongid=65534,sec=sys,secure,root_squash,all_squash) nfs unifies the client to 65534 user rights, check which user 65534 belongs to, and recursively assign data directory nfsnobody

[root@doudou] # grep "65534" / etc/passwd nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin [root@doudou ~] # chown-R nfsnobody.nfsnobody / data/ [root@doudou ~] # ls / data/-dl drwxr-xr-x. 2 nfsnobody nfsnobody 6 Aug 2 16:12 / data/ restart nfs-server service effective [root@doudou ~] # systemctl restart nfs-server client 1. Turn off the firewall, turn off selinux [root@linfan ~] # systemctl stop firewalld [root@linfan ~] # systemctl disable firewalld [root@doudou ~] # sed-ri'# ^ SELINUX=#cSSELINUX=Disabled' / etc/selinux/config [root@doudou ~] # setenforce 02. Install related services and just start the rpcbind service to [root@linfan ~] # yum-y install nfs-utils rpcbind [root@linfan ~] # systemctl enable rpcbind [root@linfan ~] # systemctl start rpcbind3. The client views the remote server to provide mountable information [root@linfan ~] # showmount-e 192.168.24.181 Export list for 192.168.24.181: / data 192.168.24.132 Export list for 244. Client mount shared data [root@linfan ~] # mount-t nfs 192.168.24.181:/data / mnt [root@linfan ~] # df-h Filesystem Size Used Avail Use% Mounted on / dev/mapper/centos-root 17G 6.0G 12G 35% / devtmpfs 478M 0478M 0% / devtmpfs 489M 0489M 0% / dev/shm tmpfs 489m 26M 464m 6% / run tmpfs 489M 0489m 0% / sys/fs/cgroup / dev/sda1 1014M 125M 890M 13% / boot tmpfs 98m 098m 0% / run/user/0 192.168.24.181:/data 17G 1.8G 16G 11% / mnt5. Test whether the nfs is successful or not the client operation creates a file under the client mnt hello # # [root@linfan ~] # ls / mnt/ [root@linfan ~] # cd / mnt/ [root@linfan mnt] # touch hello [root@linfan mnt] # ls hello server operation to check whether the file hello [root@doudou ~] # ls / data hello exists under data on the server side, so much for the article "how to configure NFS in Linux system". Hope that 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.

Share To

Development

Wechat

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

12
Report