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 set up NFS File sharing in CentOS6.8

2025-04-06 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 set up NFS file sharing in CentOS6.8. 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.

NFS file sharing can solve the problem of file sharing such as pictures and attachments in the cluster environment.

Now suppose there are two machines, 192.168.1.10 and 192.168.1.11.

We use 192.168.1.10 as the server and 192.168.1.11 as the client.

I. server-side operation

1. Check to install the nfs service

Rpm-qa | grep nfs rpm-qa | grep rpcbind

If nfs-utils and rpcbind are not installed here

Yum install nfs-utils rpcbind

As shown in the picture above, the installation is successful.

two。 Set up Boot Auto start Service

Chkconfig nfs on chkconfig rpcbind on

3. Start the service

Service rpcbind start service nfs start

4. Create a shared directory

Mkdir / usr/local/jsp/www

5. Open the / etc/exports file

Vi / etc/exports

Join

/ usr/local/jsp/www * (rw,sync,no_root_squash)

*: allow all network segments to access

Rw: read and write permissions

Sync: write data synchronously to internal and hard disk

No_root_squash:nfs client shared directory user rights

If you need to specify that it can only be set for a certain network segment (for example, 192.168.1.1 / 192.168.1.192)

/ usr/local/www/ 192.168.1.* (rw,sync,no_root_squash,no_subtree_check)

You can also specify multiple network segments manually

/ usr/local/www/ 192.168.1.10 (rw,sync,no_root_squash,no_subtree_check) 192.168.1.11 (rw,sync,no_root_squash,no_subtree_check)

Multi-directory sharing can be done by adding multiple lines.

6. Refresh configuration takes effect immediately

Exportfs-a

At this point, you can use the showmount-e server ip to view the mount directory

Showmount-e 192.168.1.10

Second, client-side operation (the first four steps are the same as the server)

1. Check the installation of nfs

Yum install nfs-utils rpcbind

two。 Set up Boot Auto start Service

Chkconfig nfs on chkconfig rpcbind on

3. Start the service

Service rpcbind start service nfs start

4. Create a shared directory

Mkdir / usr/local/jsp/www

5. Mount directory

1) View the mountable directory

Showmount-e 192.168.1.10

2) Mount

Mount-t nfs 192.168.1.10:/usr/local/jsp/www / usr/local/jsp/www

This command has mounted the / usr/local/jsp/www directory on 10 to the client's / usr/local/jsp/www directory

If the mount times out, check the firewall configuration, but service iptables stop can temporarily turn off the firewall for testing.

3) View the mounted directory

Df-h

4) Uninstall the mounted directory

Umount / usr/local/jsp/www

6. Set up boot auto mount

Vi / etc/fstab 192.168.1.10:/usr/local/jsp/www nfs rw,tcp,intr 0 1

III. Appendix NFS Common parameters

Ro read-only access rw read-write access sync all data on request write sharing async nfs can respond to a request secure nfs send insecure nfs over a secure TCP/IP port below 1024 send wdelay over more than 1024 ports if multiple users want to write to the nfs directory, group write (default) no_wdelay if more than one user wants to write to the nfs directory, write immediately, when using async, this setting is not required. Hide does not share its subdirectory no_hide shared nfs directory in the nfs shared directory subtree_check if you share a subdirectory such as / usr/bin, force nfs to check the permissions of the parent directory (default) no_subtree_check and the above relative, do not check the parent directory permissions UID and GID mapping anonymous user anonymous of the all_squash shared file, which is suitable for public directories. No_all_squash preserves UID and GID of shared files (default) all requests of root_squash root users are mapped to the same permissions as anonymous users (default) no_root_squas root users have full administrative access to the root anonuid=xxx specify UID anongid=xxx of anonymous users in nfs servers / etc/passwd files specify GID of anonymous users in nfs servers / etc/passwd files about "how to in CentOS6.8 This is the end of the article "setting up NFS File sharing" 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

Servers

Wechat

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

12
Report