版权声明:作者:傲娇天子 博文主页地址:https://blog.csdn.net/qq_41116956 欢迎转载,转载请在文章页面明显位置给出原文链接,谢谢 https://blog.csdn.net/qq_41116956/article/details/83541818
服务端
1:安装NFS服务
[root@www ~]# yum install nfs-utils -y
......
完毕!
2:创建NFS共享服务文件
[root@www ~]# mkdir /nfsfile
[root@www ~]# echo "这个是nfs文件" > /nfsfile/1.txt
[root@www ~]# vim /etc/exports #修改nfs共享内容
/nfsfile 192.168.1.*(rw,sync,root_squash)
备注:
文件的绝对路径 允许访问的ip地址 (权限设置)
3:启动nfs服务
nfs服务依赖RPC服务,所以先检查RPC服务是否启动
检查RPC服务
[root@www ~]# systemctl status rpcbind.service
● rpcbind.service - RPC bind service
Loaded: loaded (/usr/lib/systemd/system/rpcbind.service; indirect; vendor preset: enabled)
Active: inactive (dead)
启动RPC服务
[root@www ~]# systemctl start rpcbind.service
[root@www ~]# systemctl status rpcbind.service
● rpcbind.service - RPC bind service
Loaded: loaded (/usr/lib/systemd/system/rpcbind.service; indirect; vendor preset: enabled)
Active: active (running) since 二 2018-10-30 14:54:44 CST; 1s ago
Process: 42908 ExecStart=/sbin/rpcbind -w ${RPCBIND_ARGS} (code=exited, status=0/SUCCESS)
Main PID: 42917 (rpcbind)
CGroup: /system.slice/rpcbind.service
└─42917 /sbin/rpcbind -w
10月 30 14:54:44 www.linuxprobe.com systemd[1]: Starting RPC bind service...
10月 30 14:54:44 www.linuxprobe.com systemd[1]: Started RPC bind service.
启动nfs服务并设置开机启动
[root@www ~]# systemctl start nfs-server.service
[root@www ~]# systemctl enable nfs-server.service
客户端
1:配置客户端
在客户端上安装nfs服务
[root@CactiEZ ~]# yum install nfs-utils -y
查询可用nfs服务
[root@CactiEZ ~]# showmount -e 192.168.1.65
Export list for 192.168.1.65:
/nfsfile 192.168.1.*
创建本地挂载并挂载nfs文件
[root@CactiEZ ~]# mkdir /localnfs
You have new mail in /var/spool/mail/root
[root@CactiEZ ~]# mount -t nfs 192.168.1.65:/nfsfile /localnfs
[root@CactiEZ ~]# cd /loaclnfs/
[root@CactiEZ localnfs]# ls
1.txt
[root@CactiEZ localnfs]# cat 1.txt
这个是nfs文件
2:开机挂载文件
[root@CactiEZ ~]# vim /etc/fstab
192.168.1.65:/nfsfile /localnfs nfs defaults 0 0