nfs

作者: 带着小猪闯天下 | 来源:发表于2019-12-19 09:27 被阅读0次

NFS

1.安装软件

 yum -y install nfs-utils(主包提供文件系统)
  yum -y install rpcbind(提供rpc协议)

2.启动服务------>这两个服务必须同时启用

systemctl start nfs
systemctl start rpcbind    

一、nas(存储端)

[root@nas ~]# yum -y install nfs-utils
[root@nas ~]# mkdir /webdata                        //存储网站代码
[root@nas ~]# echo "nfs test..." > /webdata/index.html

[root@nas ~]# vim /etc/exports
/webdata        192.168.122.0/24(rw,sync,no_root_squash)    //不压制root(当client端使用root挂载时,也有root权限)  挂载是root ,同样保持root权限
[root@nas ~]# systemctl start nfs-server
[root@nas ~]# systemctl enable nfs-server
[root@nas ~]# exportfs -v
/webdata        192.168.122.0/24(rw,wdelay,no_root_squash,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)

二、web1 web2 web3 客户端

以web1为例

[root@web1 ~]# yum -y install nfs-utils httpd
[root@web1 ~]# systemctl start httpd
[root@web1 ~]# systemctl enable httpd
##1. 查看存储端共享
[root@web1 ~]# showmount -e nas
Export list for nas:
/webdata 192.168.122.0/24
ps -ef | grep nfs
##2. 手动挂载 [可选]
[root@web1 ~]# mount -t nfs nas:/webdata /var/www/html/
##卸载
[root@web1 ~]# umount /var/www/html/

##3. 自动挂载到网站主目录
[root@web1 ~]# vim /etc/fstab
nas:/webdata      /var/www/html           nfs     defaults        0 0
[root@web1 ~]# mount -a

##4. 查看挂载
[root@web1 ~]# df
nas:/webdata     7923136 692416   6821568  10% /var/www/html
[root@web1 ~]# ls /var/www/html/
index.html

相关文章

网友评论

      本文标题:nfs

      本文链接:https://www.haomeiwen.com/subject/qrtmnctx.html