基本服务搭建-NFS

  nfs network file system

功能:unix/linux和linux之间的资源共享

优点:是局域网共享中速度最快的

网络文件系统:
是一种将远程主机上的目录经过网络挂载到客户端本地系统的一种机制

rpcbind 提供rpc协议 用来通信

环境:
SERVER 192.168.1.251 server.xmt.com
CLIENT 192.168.1.252 client.xmt.com

服务器端:
搭建服务:
1.安装软件包
# rpm -qa | grep nfs
nfs-utils-1.3.0-0.33.el7.x86_64 主程序包
# rpm -qa | grep rpcbind
rpcbind-0.2.0-38.el7.x86_64 提供rpc协议 用来通信

# rpm -ql nfs-utils
/sbin/mount.nfs
/sbin/umount.nfs
/usr/sbin/exportfs
/usr/sbin/showmount

2.配置共享资源
服务器共享/test目录
# mkdir /test
# echo "nfstest" >> /test/nfstest.txt

3.配置共享/test目录 只读共享
#vim /etc/exports
/test 192.168.1.252(ro)

# man 5 exports
共享资源 共享给谁(共享的属性)

4.启动服务
# systemctl restart nfs-server
# systemctl reload nfs-server //修改配置文件重新读取  当nfs服务已经启动,客户端可能正在使用,不适合用restart

5.查看共享的资源
# showmount -e 192.168.1.251
Export list for 192.168.1.251:
/test 192.168.1.252

客户端使用:
1.查看共享资源
# showmount -e 192.168.1.251
Export list for 192.168.1.251:
/test 192.168.1.252

2.挂载 
语法:mount.nfs 服务器地址:服务器共享的目录  本地的挂载点
# mount.nfs 192.168.1.251:/test /opt

3.查看是否挂载
# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/cl-root 17G 4.9G 13G 29% /
devtmpfs 473M 0 473M 0% /dev
tmpfs 489M 140K 489M 1% /dev/shm
tmpfs 489M 14M 476M 3% /run
tmpfs 489M 0 489M 0% /sys/fs/cgroup
/dev/sda1 1014M 173M 842M 18% /boot
tmpfs 98M 28K 98M 1% /run/user/0
/dev/sr0 4.1G 4.1G 0 100% /mnt/centos7u3
192.168.1.251:/test 17G 4.0G 14G 24% /opt

4.测试
# cd /opt
# ls
nfstest.txt
# cat nfstest.txt
nfstest
# touch a.txt
touch: 无法创建"a.txt": 只读文件系统

错误:
clnt_create: RPC: Port mapper failure - Unable to receive: errno 111 (Connection refused)
查看rpcbind服务是否正常(服务端和客户端两边)

# mount.nfs 192.168.1.251:/root/hometest /mnt
mount.nfs: access denied by server while mounting 192.168.1.251:/root/hometest
客户端对服务器的/root没有权限 




posted on 2018-09-13 15:33  惠生活  阅读(197)  评论(0)    收藏  举报

导航