环境
两台服务器:一个服务端一个客户端
192.168.1.94 服务端
192.168.1.95 客户端
安装
服务端和客户端都安装
[root@lostrepair ~]# yum install -y nfs-utils rpcbind [root@jobadmin ~]# yum install -y nfs-utils rpcbind
编辑配置文件
[root@lostrepair ~]# vim /etc/exports /home/GR/App/gr-unicorn-lostrepair/upload 192.168.1.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000) /home/GR/App/gr-unicorn-lostrepair/download 192.168.1.0/24(rw,sync,all_squash,anonuid=1000,anongid=1000)
服务端基本配置
[root@lostrepair ~]# mkdir -p /home/GR/App/gr-unicorn-lostrepair/upload [root@lostrepair ~]# mkdir -p /home/GR/App/gr-unicorn-lostrepair/download [root@lostrepair ~]# chmod 777 /home/GR/App/gr-unicorn-lostrepair/upload [root@lostrepair ~]# chmod 777 /home/GR/App/gr-unicorn-lostrepair/download [root@lostrepair ~]# systemctl start rpcbind systemctl start nfs systemctl enable rpcbind systemctl enable nfs [root@lostrepair ~]# systemctl start nfs [root@lostrepair ~]# systemctl enable rpcbind [root@lostrepair ~]# systemctl enable nfs Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.
配置文件注释
rw 读写
ro 只读
sync 同步模式,内存数据实时写入磁盘
async 非同步模式
no_root_squash 客户端挂载NFS共享目录后,root用户不受约束,权限很大
root_squash 与上面选项相对,客户端上的root用户收到约束,被限定成某个普通用户
all_squash 客户端上所有用户在使用NFS共享目录时都被限定为一个普通用户
anonuid/anongid 和上面几个选项搭配使用,定义被限定用户的uid和gid
客户端挂载
查看
[root@jobadmin ~]# showmount -e 192.168.1.94 Export list for 192.168.1.94: /home/GR/App/gr-unicorn-lostrepair/download 192.168.1.0/24 /home/GR/App/gr-unicorn-lostrepair/upload 192.168.1.0/24
挂载
[root@jobadmin ~]# mount -t nfs 192.168.1.94:/home/GR/App/gr-unicorn-lostrepair/download /mnt/ [root@jobadmin ~]# mount -t nfs 192.168.1.94:/home/GR/App/gr-unicorn-lostrepair/upload /opt/
查看挂载
[root@jobadmin ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/sda3 50G 1.8G 49G 4% / devtmpfs 3.9G 0 3.9G 0% /dev tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 3.9G 8.5M 3.9G 1% /run tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sda5 42G 61M 42G 1% /home /dev/sda1 497M 119M 379M 24% /boot tmpfs 786M 0 786M 0% /run/user/0 192.168.1.94:/home/GR/App/gr-unicorn-lostrepair/download 46G 118M 46G 1% /mnt 192.168.1.94:/home/GR/App/gr-unicorn-lostrepair/upload 46G 118M 46G 1% /opt
exportfs命令
常用选项
-a 全部挂载或者全部卸载
-r 重新挂载
-u 卸载某一个目录
-v 显示共享目录
以下操作在服务端上
编辑如下配置文件后
vim /etc/exports
执行
[root@lostrepair ~]# exportfs -arv exporting 192.168.1.0/24:/home/GR/App/gr-unicorn-lostrepair/download exporting 192.168.1.0/24:/home/GR/App/gr-unicorn-lostrepair/upload
继续阅读
- 我的QQ
- QQ扫一扫
-
- 我的头条
- 头条扫一扫
-
评论