你好!我是老王。不做隔壁的邻居,只想交个朋友。
欢迎关注我的公众号[王自简]
以下内容若引起您的不适,欢迎指正!您的批评是我成长的动力!
NFS服务器搭建
检查操作系统的环境
cat /etc/redhat-release
CentOS release 6.9 (Final)
uname -r
2.6.32-696.el6.x86_64
uname -m
x86_64
安装 NFS 服务
yum -y install nfs-utils rpcbind
启动rpc
service rpcbind start
查看rpc状态
service rpcbind status
启动 NFS 服务
service nfs start
查看nfs 状态
service nfs status
启动 NFS 服务后 rpc 服务已经启用了对 NFS 的端口映射列表
rpcinfo -p localhost
创建一个共享目录 /data/share ,作为客户端挂载的远端入口,然后设置权限。
1.root角色创建data目录
mkdir /data
chmod 777 data/
2.普通角色
cd data
mkdir share
chmod 777 /data/share/
修改 NFS 配置文件 /etc/exports
vim /etc/exports
/data/share 10.222.77.0/24(rw,sync,insecure,no_subtree_check,no_root_squash)
挂载
linux: mount -t nfs 172.16.1.31:/data /mnt
windows: mount \\192.168.190.131\data\share X:
查看
df -h
取消挂载
umount /mnt
nfs服务开机启动
chkconfig rpcbind on
chkconfig nfs on
chkconfig --list rpcbind
rpcbind 0:off 1:off 2:on 3:on 4:on 5:on 6:off
chkconfig --list nfs
nfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off
永久性生效,重启后不会复原
开启: chkconfig iptables on
关闭: chkconfig iptables off
即时生效,重启后复原
开启: service iptables start
关闭: service iptables stop
正确关闭步骤:
service iptables stop
chkconfig iptables off
说明:
-rw------- (600) 只有拥有者有读写权限。
-rw-r--r-- (644) 只有拥有者有读写权限;而属组用户和其他用户只有读权限。
-rwx------ (700) 只有拥有者有读、写、执行权限。
-rwxr-xr-x (755) 拥有者有读、写、执行权限;而属组用户和其他用户只有读、执行权限。
-rwx--x--x (711) 拥有者有读、写、执行权限;而属组用户和其他用户只有执行权限。
-rw-rw-rw- (666) 所有用户都有文件读、写权限。
-rwxrwxrwx (777) 所有用户都有读、写、执行权限。
备注:
centos6.8版本默认安装nfs3。流程已测试通过。
centos7 版本默认安装nfs4 ,程序中是nfs3。
问题:
mount failure, server: 192.168.24.7, export: /data/share, nfs version: 3, returned state: 13(无操作权限)
解决办法:
cat /etc/exports
原来配置信息:/data/share 192.168.24.0/24(rw,no_root_squash,no_all_squash,sync)
改后配置信息:/data/share *(rw,sync,insecure,no_subtree_check,no_root_squash)
未找到解决方案:
rpc error, server: 192.168.24.7, RPC error: RPC call is ACCEPTED, but the status is not success, acceptStat=2
参考:
https://blog.51cto.com/lzhnb/2086392
https://www.cnblogs.com/yshyee/p/9520181.html
https://blog.csdn.net/aixiaoyang168/article/details/83782336