标签:share systemctl nfs autofs Linux NFS root localhost
一、NFS服务配置步骤
NFS的作用:能够使两台虚拟机之间实现文件共享、数据同步
准备:主机名、网络、yum源
Server端:
1、安装nfs-util和rpcbind:(图形化自带)
[root@localhost ~]# yum -y install nfs-util rpcbind
2、新建共享目录及标记文件:
[root@localhost ~]# mkdir /opt/share
[root@localhost ~]# touch /opt/share/flag
3、开放读写权限:
[root@localhost ~]# chmod -R 777 /opt/share
4、修改配置文件:
[root@localhost ~]# vim /etc/exports
写入:/opt/share 192.168.100.0/24(rw,sync)
5、生效配置:
[root@localhost ~]# exportfs -r
6、启动并开机自启NFS服务:
[root@localhost ~]# systemctl start rpcbind
[root@localhost ~]# systemctl start nfs
[root@localhost ~]# systemctl enable rpcbind
[root@localhost ~]# systemctl enable nfs
7、查看挂载目:
[root@localhost ~]# showmount -e 192.168.100.10
8、查看端口是否开启(111和2049):
[root@localhost ~]# netstat -pant
Client端:
1、安装nfs-util和rpcbind:(图形化自带)
[root@localhost ~]# yum -y install nfs-util rpcbind
2、关闭SELinux服务:
[root@localhost ~]# setenforce 0
3、挂载共享目录:
[root@localhost ~]# mount -t nfs 192.168.100.10:/opt/share /mnt
4、查看挂载情况:
[root@localhost ~]# df -h
5、在/mnt里面创建文件验证
[root@localhost ~]# cd /mnt
[root@localhost mnt]# touch abc
二、autofs自动挂载配置步骤
准备:要在NSF的基础上进行配置
Server端:
检查nfs是否开启:
[root@localhost ~]# systemctl status nfs
检查端口号:
[root@localhost ~]# netstat -pant
检查防火墙:
[root@localhost ~]# systemctl status firewalld
Client端:
先查看挂载目:
[root@localhost ~]# showmount -e 192.168.100.10
1、安装autofs:
[root@localhost ~]# yum -y install autofs
2、配置/share:
[root@localhost ~]# vim /etc/auto.master.d/test.autofs
写入:/share /etc/auto.test
3、配置pub:
[root@localhost ~]# vim /etc/auto.test
写入:pub 192.168.10.10:/opt/nfsshare
4、重启并开启自启:
[root@localhost ~]# systemctl restart autofs
[root@localhost ~]# systemctl enable autofs
5、访问目录:
[root@localhost ~]# cd /share/pub
注意:第一个文件要以autofs结尾,第二个配置文件名要与第一个配置文件里定义的参数一致
标签:share,systemctl,nfs,autofs,Linux,NFS,root,localhost 来源: https://www.cnblogs.com/wzgwzg/p/15558294.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。