NFS共享服务(简单了解)

NFS共享存储服务

■ NFS (Network File System)网络文件系统
● 依赖于RPC (远端过程调用)
● 需安装nfs-utils、rpcbind软件包
● 系统服务: nfs、 rpcbind
● 共享配置文件: /etc/exports

使用NFS发布共享资源

■ 安装nfs-utils、rpcbind软件包
[root@localhost ~]# yum -y install nfs-utils rpcbind
[root@localhost ~]# systemqtl enable nfs
[root@localhost ~]# systemctl enable rpcbind

■ 设置共享目录
[root@localhost ~]# mkdir -p /opt/wwwroot
[root@localhost ~]# vi /etc/exports
/opt/wwwroot 192.168.7.0/24(rw,sync,no_ root_ squash) /var/ftp/pub 192.168.4.11(ro) 192.168.4.110(rw)

(ro)权限是只读,不允许更改(rw是读写权限,sync是服务器和客户机间开启同步, no_root_squash表示可以是root身份访问服务器)

■ 启动NFS服务程序
■ 查看本机发布的NFS共享目录

[root@localhost ~]# systemctl start rpcbind      
[root@localhost ~]# systemctl start nfs     
[root@localhost ~]# netstat -anpt | grep rpc       
tcp 0   00.0.0.0:20048   0.0.0.0:* LISTEN  10508/rpc.mountd      
tcp 0   00.0.0.0:52732   0.0.0.0:* LISTEN  10495/rpc.statd      
tcp6    00 ::20048            ::*  LISTEN  10508/rpc.mountd       
tcp6    00 ::47669            ::*  LISTEN  10495/rpc.statd      
[root@localhost ~]# showmount -e      
/opt/wwwroot 192.168.7.0/24     
/var/ftp/pub 192.168. 4.110,192.168.4.11

在客户机中访问NFS共享资源

■ 安装rpcbind软件包, 并启动rpcbind服务
[root@localhost ~]# yum -y install rpcbind nfs-utils
[root@localhost ~]# systemctl enable rpcbind
[root@localhost ~]# systemctl start rpcbind
[root@localhost ~]# showmount -e 192.168.7 .250
Export list for 192. 168.7.250:
/opt/wwwroot 192. 168.7.0/24
/var/ftp/pub 192.168.4.110,192.168.4.11

■ 手动挂载NFS共享目录

[root@localhost ~]# mount 192.168.7.250:/opt/wwwroot /var/www/html      
[root@localhost ~]# tail -1 /etc/mtab      
192.168.7.250:/opt/wwwroot /var/www/html nfs4       
rw,relatime,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,port=0,       
timeo=600,retrans=2,sec=sys, clientaddr=192.168.7.21,local lock=none,       
addr=192.168.7.250 0 0      
[root@localhost ~]# vi /var/www/html/index.html       
Real Web Server Document

■ fstab自动挂载设置

[root@localhost ~]# vi /etc/fstab       

.... //省略部分信息      

192.168.7.250:/opt/wwwroot /var/www/html nfs defaults,_netdev 0 0

■ 强制卸载NFS
[root@localhost ~]# umount /mnt
umount: /mnt: device is busy
[root@localhost ~]# umount -If /mnt
[root@localhost ~]#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值