NFS服务与触发挂载

简介: NFS服务与触发挂载

NFS服务与触发挂载

一、介绍

Network File System,网络文件系统
– 用途:为客户机提供共享使用的文件夹
– 协议:NFS( 2049)、RPC( 111)

由 autofs 服务提供的“按需访问”机制
– 只要访问挂载点就会触发响应,自动挂载指定设备
– 闲置超过时限(默认5分钟)后,会自动卸载

二、使用

1.NFS


// 安装对应的软件包
[root@tk ~]# yum -y install nfs-utils
// 建立共享文件夹
[root@tk ~]# mkdir /public
[root@tk ~]# echo "test_nfs" > /public/test_nfs.txt
[root@tk ~]# ls /public/
test_nfs.txt
[root@tk ~]# vim /etc/exports
// 写如下的配置语句,表示共享的文件是/public *代表所有主机都可以访问
// ro表示只有只读权限
[root@tk ~]# cat /etc/exports
/public *(ro)
// 重启服务
[root@tk ~]# systemctl restart rpcbind
[root@tk ~]# systemctl restart nfs-server
// 关闭防火墙
[root@tk ~]# systemctl stop firewalld
[root@tk ~]# cat /etc/exports
/public *(ro)
[root@tk ~]#
// 检查201的主机的共享
[root@gitlab ~]# showmount -e 10.0.0.200
Export list for 10.0.0.200:
/public *
[root@gitlab ~]# mkdir /mynfs
[root@gitlab ~]# mount 10.0.0.200:/public /mynfs/
[root@gitlab ~]# ls /mynfs/
test_nfs.txt
[root@gitlab ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   39G  6.2G   33G  17% /
devtmpfs                 2.0G     0  2.0G   0% /dev
tmpfs                    2.0G     0  2.0G   0% /dev/shm
tmpfs                    2.0G   12M  2.0G   1% /run
tmpfs                    2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/sr0                 4.3G  4.3G     0 100% /mydvd
/dev/sda1               1014M  133M  882M  14% /boot
/dev/mapper/centos-home   19G   33M   19G   1% /home
tmpfs                    394M     0  394M   0% /run/user/0
10.0.0.200:/public        39G  3.7G   35G  10% /mynfs
[root@gitlab ~]#

2.触发挂载


// 触发挂载实现,必须多级的目录结构: /监控目录/挂载点目录
// 主配置文件 /etc/auto.master
// 建立监控目录
[root@gitlab ~]# mkdir /myauto
// 此时没有文件
[root@gitlab ~]# ls /myauto/
// 添加配置语句 /myauto /autonfs.txt
[root@gitlab ~]# vim /etc/auto.master
[root@gitlab ~]# cat /etc/auto.master
#
# Sample auto.master file
# This is a 'master' automounter map and it has the following format:
# mount-point [map-type[,format]:]map [options]
# For details of the format look at auto.master(5).
#
/misc   /etc/auto.misc
#
# NOTE: mounts done from a hosts map will be mounted with the
#       "nosuid" and "nodev" options unless the "suid" and "dev"
#       options are explicitly given.
#
/net    -hosts
// ... 
+auto.masteri
/myauto /autonfs.txt
// 建立对应的文件
[root@gitlab ~]# vim /autonfs.txt
[root@gitlab ~]#
[root@gitlab ~]# cat /autonfs.txt
nfs -fstype=nfs 10.0.0.200:/public
// 重启服务
[root@gitlab ~]# systemctl restart autofs.service
// 进入目录,发现自动挂载
[root@gitlab ~]# ls /myauto/nfs
test_nfs.txt
[root@gitlab ~]#

相关文章
|
2月前
|
Linux
Linux安装NFS挂载NFS卸载客户端服务端都有
Linux安装NFS挂载NFS卸载客户端服务端都有
66 0
|
2月前
|
Ubuntu 网络协议 Unix
【Linux】新唐NUC977挂载NFS实现网络文件传输
【Linux】新唐NUC977挂载NFS实现网络文件传输
|
2月前
|
Linux Shell Windows
通过Linux挂载Windows端NFS服务实现板端Linux传输文件到PC
通过Linux挂载Windows端NFS服务实现板端Linux传输文件到PC
215 0
|
2月前
|
存储 监控 网络协议
【Linux】文件服务NFS(Network File System)
【Linux】文件服务NFS(Network File System)
138 0
|
2月前
|
Unix Linux 文件存储
文件传输、文件挂载MOUNT:NFS、CIFS、ADB、SAMBA
文件传输、文件挂载MOUNT:NFS、CIFS、ADB、SAMBA
118 0
|
1月前
|
Ubuntu
ubuntu搭建NFS服务 磁盘共享 nfs 搭建
ubuntu搭建NFS服务 磁盘共享 nfs 搭建
53 2
|
2月前
|
存储 网络协议 Linux
NFS(Network File System 网络文件服务)
NFS(Network File System 网络文件服务)
|
2月前
|
域名解析 Unix Linux
AIX上如何正确挂载Linux 的nfs共享目录分享篇
AIX上如何正确挂载Linux 的nfs共享目录分享篇
47 1
|
2月前
|
存储 Kubernetes 应用服务中间件
k8s-配置与存储-持久化存储-NFS 挂载、StorageClass 存储类 动态创建NFS-PV案例
k8s-配置与存储-持久化存储-NFS 挂载、StorageClass 存储类 动态创建NFS-PV案例
286 0
|
2月前
|
Ubuntu 网络协议
开发板挂载 Ubuntu 的 NFS 目录
开发板挂载 Ubuntu 的 NFS 目录