Skip to content

通过知识获得解放,通过技术获得自由

Menu
  • 专题目录
  • 液压相关
    • 液压技术
    • 液压相邻技术
    • 液压应用
  • 计算机相关
    • 计算机和软件
    • 网络和网站技术
  • 哲学
  • 关于本站
Menu

centos8部署nfs[0]

Posted on 2023年11月14日 by

NFS 是Network File System的缩写,即网络文件系统。

功能是通过网络让不同的机器、不同的操作系统能够彼此分享文件,让应用程序在客户端通过网络访问位于服务器磁盘中的数据,是在类Unix系统间实现磁盘文件共享的一种方法。

NFS使用RPC协议进行通信,也就是说NFS系统只是一组RPC程序。RPC是远程过程调用 (Remote Procedure Call) 的英文缩写,它是能使客户端执行其他系统中程序的一种机制。NFS可以看作是一个RPC Server,主要功能是管理需要分享的目录和文件。它不负责通信和信息传输,而是把这部分工作交给RPC协议来完成。即NFS在文件传送或信息传送过程中依赖于RPC协议。所以只要用到NFS的地方都要启动RPC服务,不论是NFS SERVER或者NFS CLIENT。这样SERVER和CLIENT才能通过RPC来实现PROGRAM PORT的对应。可以这么理解RPC和NFS的关系:NFS是一个文件系统,而RPC是负责负责信息的传输。

NFS 的基本原则是“容许不同的客户端及服务端通过一组RPC分享相同的文件系统”,它是独立于操作系统,容许不同硬件及操作系统的系统共同进行文件的分享。

  • 部署过程

服务端(ip=1.1.1.1):

yum install nfs-utils -y
systemctl start rpcbind
systemctl start nfs-server
systemctl enable rpcbind
systemctl enable nfs-server

cat /proc/fs/nfsd/versions

mkdir -p /backup1
chmod 777 /backup1
chown 1001:1001 /backup1

#设置允许的客户端和权限,2.2.2.2是客户端地址
echo "/backup1  2.2.2.2(rw,sync,no_subtree_check)" >> /etc/exports
#检查设置
exportfs -a

#设置防火墙
systemctl restart firewalld
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="2.2.2.2/32" port protocol="tcp" port="2049" accept"
systemctl restart firewalld

权限说明:

rw 读写
ro 只读
sync 同步模式,内存数据实时写入磁盘
async 非同步模式
no_root_squash 客户端挂载NFS共享目录后,root用户不受约束,权限很大
root_squash 与上面选项相对,客户端上的root用户收到约束,被限定成某个普通用户
all_squash 客户端上所有用户在使用NFS共享目录时都被限定为一个普通用户
anonuid/anongid 和上面几个选项搭配使用,定义被限定用户的uid和gid

 

客户端(ip=2.2.2.2):

yum install nfs-utils -y 
systemctl enable rpcbind

mkdir -p /backup0
#挂载服务端到本地,1.1.1.1是服务端
#客户端继承服务端的权限,用ls -la检查
mount -t nfs -o vers=4.2 1.1.1.1:/backup1 /backup0
echo "nfs客户端部署完成"

 

  • 测试

测试通过,其他vps无法通过nfs连接.

 

补充说明:

1)nfs系统的操作模式和s3fs类似

2)nfs无需用户名和密码,支持的身份验证是基于ip,简化了认证过程

3)kodexplrer挂载nfs文件

在客户端vps上

ln -s /backup1  /home/wwwroot/xxx.fanlog.org/data/User/admin/home/
#打开文件
cd /home/wwwroot/xxx.fanlog.org/data/User/admin/home/backup1

通过kodexplorer能够实现文件的上传,下载和删除

实现功能类似于网盘的远程挂载,若有优化的线路也能够实现较好的上传下载速度,上传速度3M/s,下载速度1.5M/s,不建议单个文件>100M,适合管理文件

 

参考资料:

  1. https://www.myfreax.com/how-to-install-and-configure-an-nfs-server-on-centos-8/
  2. https://cloud.tencent.com/developer/article/1626790
  3. https://qizhanming.com/blog/2018/08/08/how-to-install-nfs-on-centos-7
  4. https://juejin.cn/post/7035489642434527269
  5. https://blog.csdn.net/king_wei_qiang/article/details/109090633
  6. https://blog.csdn.net/armeasy/article/details/6005703
  7. https://www.jianshu.com/p/f85c4371a43d
  8. http://blog.ryjer.com/posts/a1ba025983.html
  9. https://juejin.cn/post/7155784804150018056

欢迎回来

希望本站对你有所帮助!

如有疑问请联系info@fanlog.org
2023 年 11 月
一二三四五六日
 12345
6789101112
13141516171819
20212223242526
27282930 
« 6 月    

AI辅助 (17)

© 2025 | Powered by Superbs Personal Blog theme
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT