nfs autos

简介: nfs autos

NFS AutoFS

两台机器

image.png

一、NFS服务端配置

1.配置本地 hosts 解析

[root@nfs-server ~]# echo "192.168.195.145 "nfs-server" >> /etc/hosts
[root@nfs-server ~]# echo "192.168.195.146 "client" >> /etc/hosts
[root@nfs-server ~]# tail -n2 /etc/hosts
192.168.195.145 nfs-server
192.168.195.146 client

2.安装 nfs 以及 rpc 所需要的包

[root@nfs-server ~]# yum -y install nfs-utils rpcbind

3.启动 rpc nfs 服务并设置为开机自启动

[root@nfs-server ~]# systemctl start rpcbind //先启动 rpc 服务再启动 nfs 服务。
[root@nfs-server ~]# systemctl start nfs
[root@nfs-server ~]# systemctl enable rpcbind
[root@nfs-server ~]# systemctl enable nfs

4.配置挂载目录

[root@nfs-server ~]# vi /etc/exports
/mnt 192.168.195.0/24(rw,async)
/opt *(rw,async)

5.关闭防火墙和selinux

[root@nfs-server ~]# systemctl stop firewalld
[root@nfs-server ~]# systemctl disable firewalld
[root@nfs-server ~]# setenforce 0
[root@nfs-server ~]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are
protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

6.验证NFS

[root@nfs-server ~]# systemctl restart rpcbind nfs-server
[root@nfs-server ~]# showmount -e 127.0.0.1
Export list for 192.168.195.145:
/opt *
/mnt 192.168.195.0/24

二、NFS客户端挂载

1.安装NFS

[root@nfs-client ~]# yum -y install rpcbind nfs-utils

2.配置本地 hosts 解析

[root@nfs-client users]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.195.145 nfs-server
192.168.195.146 nfs-client

3.验证NFS

[root@nfs-client ~]# showmount -e 192.168.195.145
Export list for 192.168.195.145:
/opt *
/mnt 192.168.195.0/24

4.挂载NFS

[root@nfs-client ~]# mount -t nfs 192.168.195.145:/mnt /mnt
[root@nfs-client ~]# mount -t nfs 192.168.195.145:/opt /opt
[root@nfs-client ~]# df -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
192.168.195.145:/mnt nfs4 17G 1.5G 16G 9% /mnt
192.168.195.145:/opt nfs4 17G 1.5G 16G 9% /opt

三、使用autofs配置自动挂载

1.配置本地 hosts 解析

[root@client users]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.195.145 nfs-server
192.168.195.147 client

2.创建挂载目录并挂载

[root@client ~]# mkdir /nfsdir
[root@client ~]# mount -t nfs 192.168.195.145:/mnt /nfsdir
[root@client ~]# df -Th
文件系统 类型 容量 已用 可用 已用% 挂载点
192.168.195.145:/mnt nfs4 17G 1.5G 16G 9% /mnt
192.168.195.145:/opt nfs4 17G 1.5G 16G 9% /opt
192.168.195.145:/mnt nfs4 17G 1.5G 16G 9% /nfsdir

3.编辑 “/etc/auto.master” 主配置文件

[root@client ~]# echo "/nfsdir /etc/auto.user" >> /etc/auto.master

4.编辑 “/etc/auto.user” 子配置文件

[root@client ~]# echo "users -fstype=nfs,rw,sync,no_root_squash nfs-server:/home"
>> /etc/auto.user

5.启动 autofs 服务并设置为开机自启动

#服务端
[root@server ~]# mkdir /mnt/users
#客户端
[root@client ~]# cd /nfsdir/
[root@client nfsdir]# ls -lh
总用量 0
[root@client nfsdir]# cd users
[root@client users]# pwd
/nfsdir/users
[root@client users]# ls -lh /nfsdir/
total 0
drwxr-xr-x 2 root root 6 Mar 16 03:26 users

6.测试autofs自动挂载

#服务端
[root@server ~]# mkdir /mnt/users
#客户端
[root@client ~]# cd /nfsdir/
[root@client nfsdir]# ls -lh
总用量 0
[root@client nfsdir]# cd users
[root@client users]# pwd
/nfsdir/users
[root@client users]# ls -lh /nfsdir/
total 0
drwxr-xr-x 2 root root 6 Mar 16 03:26 users


相关文章
|
数据采集 自然语言处理 程序员
ChatGPT 调教日记(一):Markdown 解析器
ChatGPT 调教日记(一):Markdown 解析器
447 0
|
存储 前端开发 文件存储
Flutter笔记:关于应用程序中提交图片作为头像
1. 头像选择与提交的一般步骤Flutter笔记关于应用程序中提交图片作为头像作者目 录1. 头像选择与提交的一般步骤2. 选择本地文件到头像的示例代码3. 将图像提交到后端1. 头像选择与提交的一般步骤image将处理后的图像作为用户的头像显示在应用程序中。您可以使用Image或小部件来加载和显示图像。这些步骤涵盖了从选择图像到上传、处理和显示图像的基本流程。请根据您的具体需求和后端实现来自定义这些步骤。此外,确保您的应用程序有适当的权限以访问设备上的相册或相机,这通常需要在和。
605 0
|
JSON 自然语言处理 Serverless
基于阿里云通义千问开发智能写作助手
现代办公中,撰写邮件、会议记录、报告等任务耗费大量时间。一个智能写作助手能显著提升效率,帮助用户快速生成高质量的文本内容。阿里云通义千问作为阿里巴巴推出的强大大语言模型(LLM),具备出色的自然语言理解与生成能力,非常适合用于开发智能写作工具。本博客将介绍如何基于通义千问构建一个智能写作助手,实现高效的内容生成和编辑功能。
1068 2
|
存储 缓存 数据挖掘
阿里云服务器通用算力型u1与经济型e实例对比与常见问题参考
阿里云的通用算力型u1与经济型e实例均以实惠的价格提供云服务,但各有侧重。经济型e实例采用共享模式,适用于个人开发者、学生及小微企业,适合搭建网站、开发测试等轻量级应用;通用算力型u1实例则提供独享资源,更适合对稳定性和性能有一定要求的企业级应用,如中大型网站、数据分析等场景。e实例基于Intel® Xeon® Platinum处理器,提供ESSD Entry云盘,价格亲民;u1实例同样支持ESSD系列云盘,具备更高性价比和稳定算力保障。选择时,个人用户可优先考虑经济型e实例,追求性价比;企业用户则推荐使用通用算力型u1实例,以获得更佳的性能和服务质量保证。
727 4
阿里云服务器通用算力型u1与经济型e实例对比与常见问题参考
|
监控 Linux Python
百度搜索:蓝易云【Linux系统安装HomeAssistant教程。】
请注意,以上步骤提供了基本的Home Assistant安装指南。具体的安装过程可能因您使用的Linux发行版和软件源而有所不同。如果您遇到任何问题,请参考相应的文档,或寻求相关的支持和指导。
685 0
|
监控 安全 BI
数据安全之认识数据库审计系统
数据库审计系统是保障企业核心资产的关键,它监控并分析数据库操作,提供实时告警和取证功能,应对SQL注入等安全威胁。系统依据法规要求,如GDPR,确保合规性,并支持敏感信息脱敏、报表统计、安全审计、告警及智能分析。通过旁路部署、软件插件或分布式方式安装,确保数据安全性,包括实时监控、违规检测、策略管理、记录检索、合规报告和风险预警。与日志审计系统协同工作,共同提升IT安全。
|
存储 Linux Windows
GPT与MBR:硬盘分区表格式的革新与区别
GPT与MBR:硬盘分区表格式的革新与区别
1218 0
|
网络协议 Ubuntu Unix
Go语言TCP Socket编程(上)
Go语言TCP Socket编程
399 0
|
安全 Windows
Resin远程信息泄露漏洞
受影响系统:   Caucho Technology Resin v3.1.0 for Windows   Caucho Technology Resin v3.
1901 0

热门文章

最新文章