NFS介绍、NFS服务端安装配置、NFS配置选项

NFS介绍

NFS介绍

NFS介绍

NFS服务端安装配置

NFS服务端安装配置
#以下为服务端操作
[root@iZbp1e0xboek6oow616aoiZ ~]# yum install -y nfs-utils rpcbind
[root@wsl-001 ~]# vim /etc/exports
#写入下面一行

/home/nfstestdir 172.16.79.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)

[root@wsl-001 ~]# mkdir /home/nfstestdir
[root@wsl-001 ~]# chmod 777 /home/nfstestdir
[root@wsl-001 ~]# netstat -lnpt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd   (这就是rpcbind)
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      874/sshd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1093/master
tcp        0      0 172.16.79.140:8730      0.0.0.0:*               LISTEN      1655/rsync
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd
tcp6       0      0 :::80                   :::*                    LISTEN      62840/httpd
tcp6       0      0 :::22                   :::*                    LISTEN      874/sshd
tcp6       0      0 ::1:25                  :::*                    LISTEN      1093/master
tcp6       0      0 :::90                   :::*                    LISTEN      62840/httpd

[root@wsl-001 ~]# systemctl start rpcbind
[root@wsl-001 ~]# systemctl start nfs
[root@wsl-001 ~]# ps aux|grep nfs
root      77732  0.0  0.0      0     0 ?        S<   22:25   0:00 [nfsd4_callbacks]
root      77738  0.0  0.0      0     0 ?        S    22:25   0:00 [nfsd]
root      77739  0.0  0.0      0     0 ?        S    22:25   0:00 [nfsd]
root      77740  0.0  0.0      0     0 ?        S    22:25   0:00 [nfsd]
root      77741  0.0  0.0      0     0 ?        S    22:25   0:00 [nfsd]
root      77742  0.0  0.0      0     0 ?        S    22:25   0:00 [nfsd]
root      77743  0.0  0.0      0     0 ?        S    22:25   0:00 [nfsd]
root      77744  0.0  0.0      0     0 ?        S    22:25   0:00 [nfsd]
root      77745  0.0  0.0      0     0 ?        S    22:25   0:00 [nfsd]
root      77751  0.0  0.0 112676   984 pts/0    S+   22:26   0:00 grep --color=auto nfs
[root@wsl-001 ~]# ps aux|grep rpc
rpc       77684  0.0  0.0  64956  1420 ?        Ss   22:25   0:00 /sbin/rpcbind -w
rpcuser   77702  0.0  0.0  42376  1748 ?        Ss   22:25   0:00 /usr/sbin/rpc.statd
root      77709  0.0  0.0      0     0 ?        S<   22:25   0:00 [rpciod]
root      77721  0.0  0.0  42564   948 ?        Ss   22:25   0:00 /usr/sbin/rpc.mountd
root      77722  0.0  0.0  43816   548 ?        Ss   22:25   0:00 /usr/sbin/rpc.idmapd
root      77792  0.0  0.0 112676   980 pts/0    S+   22:26   0:00 grep --color=auto rpc
#允许开机启动
[root@wsl-001 ~]# systemctl enable rpcbind
[root@wsl-001 ~]# systemctl enable nfs
Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.

NFS配置选项

NFS配置选项
#以下为客户端操作
[root@wsl-001 ~]# yum install -y nfs-utils
[root@wsl-001 ~]# showmount -e 172.16.79.140
Export list for 172.16.79.140:
/home/nfstestdir 172.16.79.0/24
[root@wsl-001 ~]# mount -t nfs 172.16.79.140:/home/nfstestdir /mnt
[root@wsl-001 mnt]# df -h
文件系统                        容量  已用  可用 已用% 挂载点
/dev/sda3                        16G  1.6G   15G   10% /
devtmpfs                        902M     0  902M    0% /dev
tmpfs                           912M     0  912M    0% /dev/shm
tmpfs                           912M   17M  895M    2% /run
tmpfs                           912M     0  912M    0% /sys/fs/cgroup
/dev/sda1                       297M  160M  137M   54% /boot
tmpfs                           183M     0  183M    0% /run/user/0
172.16.79.140:/home/nfstestdir   16G  7.0G  8.8G   45% /mnt
[root@wsl-001 mnt]# touch /mnt/test.txt
[root@wsl-001 mnt]# ls -l /mnt/test.txt
-rw-r--r-- 1 wsl wsl 0 5月   8 22:34 /mnt/test.txt
[root@wsl-001 mnt]# id wsl
uid=1000(wsl) gid=1000(wsl) 组=1000(wsl) (限定了用户)
#以下为服务端操作
[root@wsl-001 nfstestdir]# ls -l /home/nfstestdir/test.txt
-rw-r--r-- 1 wsl wsl 0 5月   8 22:34 /home/nfstestdir/test.txt
[root@wsl-001 nfstestdir]# id wsl
uid=1000(wsl) gid=1000(wsl) 组=1000(wsl)  (限定了用户)
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 29.1 引言 本章中我们要讨论另一个常用的应用程序:NFS(网络文件系统),它为客户程序提供透明的文件访问。NF...
    张芳涛阅读 1,034评论 0 4
  • 由于实验室的项目需要实现在CephFS之上建立NFS之上,所以记录一下NFS服务器的安装与配置流程。 1.NFS服...
    LeeHappen阅读 9,651评论 0 2
  • 《鸟哥Linux私房菜》《老男孩Linux运维》 NFS介绍 NFS维基百科:网络文件系统(英语:Network ...
    Zhang21阅读 4,348评论 0 13
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,269评论 19 139