NFS共享服务存储服务

  1. 使用NFS发布共享资源      关闭selinux
  1. 安装nfs-utils、rpcbind软件包(centos7默认安装,调整为自启状态)

[root@localhost ~]# yum -y install  nfs-utils rpcbind

[root@localhost ~]# systemctl enable  nfs

[root@localhost ~]# systemctl enable  rpcbind

  1. 设置共享目录,默认配置文件为/etc/exports,文件内容默认为空(无共享)。

[root@localhost ~]# mkdir -p /opt/wwwroot                     共享目录

[root@localhost ~]# vim /etc/exports

[root@localhost ~]# cat /etc/exports

/opt/wwwroot 192.168.7.0/24(rw,sync,no_root_squash) 共享给7网段写*代表所有

#如需将同一个目录共享给不同客户机,且分配不同权限,只要以空格分隔指定多个“客户机(权限选项)”即可

  1. 启动nfs服务程序

[root@localhost ~]# systemctl start  rpcbind

[root@localhost ~]# systemctl start nfs

[root@localhost ~]# netstat  -anpt  | grep  rpcbind

  1. 查看本机发布的nfs共享目录

[root@localhost ~]# showmount  -e

Export list for localhost.localdomain:

/opt/wwwroot 192.168.7.0/24

  1. 在客户机中访问nfs共享资源

1)安装nfs-utils、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         查看此ip共享的目录

Export list for 192.168.7.250:

/opt/wwwroot 192.168.7.0/24

  1. 手动挂载nfs共享目录

[root@localhost ~]# mount 192.168.7.250:/opt/wwwroot /var/www/html/ [root@localhost ~]# tail -1 /etc/mtab                  //确认挂载结果

[root@localhost ~]# vim /var/www/html/index.html      //在客户机创建测试文件

[root@localhost ~]# cd /var/www/html/

[root@localhost html]# ls

index.html  //访问客户机/var/www/html文件夹相当于访问服务器/opt/wwwroot,。例如:上述创建的index就可以在服务器/opt/wwwroot/下。

  1. fstab自动挂载设置,在客户机修改/etc/fstab,加入挂载目录的挂载设置。

[root@localhost ~]# vim /etc/fstab    //添加,这样开机后自动挂载nfs共享资源。

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值