前端之家收集整理的这篇文章主要介绍了
CentOS 6/7 共享文件目录,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_
404_4@1.服务器端执行:yum install -ynfs-utils rpcbind 下载nfs 和 rpcbind 包
@H_
404_4@2.然后分别执行uname -r 和cat /etc/redhat-release
@H_
404_4@查看linux 内核 和 CentOS版本
/etc/init.d
[root@16-11-119 init.d]# uname -r
3.10.0-514.26.2.el7.x86_64
[root@16-11-119 init.d]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
如果是 ContOS7
NFS服务器端:
@H_
404_4@3.则用systemctl start nfs 和systemctl start rpcbind 分别执行启动两程序
@H_
404_4@4.创建共享目录/data
@H_
404_4@5.systemctl stop firewalld.service
关闭防火墙
@H_
404_4@ getenforce 防火墙检测
@H_
404_4@6.然后编辑 vim /etc/exports
文件
@H_
404_4@/data 192.168.1.120(rw,sync)
@H_
404_4@7.然后重启 rpcbind 和 NFS 必须先启动rpcbind 后启动NFS
@H_
404_4@systemctl restart rpcbind
@H_
404_4@systemctl restart nfs
@H_
404_4@8.rpcinfo -p localhost
@H_
404_4@9.showmount -e 服务端IP
@H_
404_4@第一个框为nfs服务器IP 第二个框展示为Client IP 挂载的服务端的目录
@H_404_4@服务端被挂载目录最好设置权限为chmod 777 /data 否则客户端无写入权限,即使为root用户
NFS客户端配置:
@H_
404_4@10.客户端执行:yum install -ynfs-utils rpcbind 下载nfs 和 rpcbind 包
@H_
404_4@11.客户端只需要启动rpcbind 即可:systemctl restart rpcbind
@H_
404_4@12.客户端挂载
mount -t nfs 服务端IP:/data/ 挂载的位置
@H_
404_4@
如果是 ContOS6
@H_
404_4@过程同上,只是执行命令稍有差别
服务器端:
yum install -y nfs-utils rpcbind
mkdir /data
/etc/init.d/nfs start
service rpcbind start
vim /etc/exports
service rpcbind restart
/etc/init.d/nfs restart
service iptables stop
chmod 777 /data/
客户端
mkdir /data
service iptables stop
service rpcbind restart
mount -t nfs 192.168.20.131:/data/ /data
@H_404_4@取消挂载:umount /mnt/
@H_404_4@CentOS7 关闭防火墙 systemctl stop firewalld.service
@H_404_4@CentOS7 检测防火墙getenforce