热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Linux服务——二、配置NFS及autofs自动挂载服务

一、NFS服务配置步骤NFS的作用:能够使两台虚拟机之间实现文件共享、数据同步准备:主机名、网络、yum源Server端:1、安装nfs-util和rpcbind:(图形化自带)[


一、NFS服务配置步骤

NFS的作用:能够使两台虚拟机之间实现文件共享、数据同步


准备:主机名、网络、yum源


Server端:

1、安装nfs-util和rpcbind:(图形化自带)

[[email protected] ~]# yum -y install nfs-util rpcbind

2、新建共享目录及标记文件:

[[email protected] ~]# mkdir /opt/share
[[email protected] ~]# touch /opt/share/flag

3、开放读写权限:

[[email protected] ~]# chmod -R 777 /opt/share

4、修改配置文件:

[[email protected] ~]# vim /etc/exports
写入:/opt/share 192.168.100.0/24(rw,sync)

5、生效配置:

[[email protected] ~]# exportfs -r

6、启动并开机自启NFS服务:

[[email protected] ~]# systemctl start rpcbind
[[email protected] ~]# systemctl start nfs
[[email protected] ~]# systemctl enable rpcbind
[[email protected] ~]# systemctl enable nfs

7、查看挂载目:

[[email protected] ~]# showmount -e 192.168.100.10

8、查看端口是否开启(111和2049):

[[email protected] ~]# netstat -pant

Client端:

1、安装nfs-util和rpcbind:(图形化自带)

[[email protected] ~]# yum -y install nfs-util rpcbind

2、关闭SELinux服务:

[[email protected] ~]# setenforce 0

3、挂载共享目录:

[[email protected] ~]# mount -t nfs 192.168.100.10:/opt/share /mnt

4、查看挂载情况:

[[email protected] ~]# df -h

5、在/mnt里面创建文件验证

[[email protected] ~]# cd /mnt
[[email protected] mnt]# touch abc

二、autofs自动挂载配置步骤


准备:要在NSF的基础上进行配置


Server端:

检查nfs是否开启:

[[email protected] ~]# systemctl status nfs

检查端口号:

[[email protected] ~]# netstat -pant

检查防火墙:

[[email protected] ~]# systemctl status firewalld

Client端:

先查看挂载目:

[[email protected] ~]# showmount -e 192.168.100.10

1、安装autofs:

[[email protected] ~]# yum -y install autofs

2、配置/share:

[[email protected] ~]# vim /etc/auto.master.d/test.autofs
写入:/share /etc/auto.test

3、配置pub:

[[email protected] ~]# vim /etc/auto.test
写入:pub 192.168.10.10:/opt/nfsshare

4、重启并开启自启:

[[email protected] ~]# systemctl restart autofs
[[email protected] ~]# systemctl enable autofs

5、访问目录:

[[email protected] ~]# cd /share/pub

注意:第一个文件要以autofs结尾,第二个配置文件名要与第一个配置文件里定义的参数一致



推荐阅读
author-avatar
阮三岁
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有