linux之自动挂载

如果想要实现自动挂载,应该挂在客户端!!!!!

客户端:

复制代码
[root@localhost ~]# yum install nfs-utils -y (下载软件)
[root@localhost ~]# systemctl start nfs-utils.service (启动该软件的服务)

[root@localhost ~]# mkdir    /bendi_dir(创建/bendi_dir目录)

[root@localhost ~]# mount 192.168.25.131:/data_server  /bendi_dir(将客户端的目录/bendi_dir挂载到服务端的/data_server上,其中IP地址为服务端的)

[root@localhost ~]# systemctl start rpcbind.service (启动该软件的服务)

[root@localhost ~]# yum search autofs(寻找可以自动挂载的软件)
 [root@localhost ~]# yum install autofs.x86_64 -y (下载软件)
[root@localhost ~]# systemctl start autofs.service (启动软件)

root@localhost ~]# vim /etc/auto.master(进入文件进行编辑)

接着进入

复制代码
[root@localhost ~]# vim  /etc/auto.misc

红框为我们所要加的内容,蓝框为服务端的地址以及目录

复制代码
[root@localhost ~]# systemctl restart autofs.service (重启服务使配置生效)

服务端:

IP地址为192.168.25.131

复制代码
[root@localhost ~]# mount /dev/sr0 /mnt  (挂载)

[root@localhost ~]# mkdir /data_server(创建目录)

[root@localhost ~]# yum install nfs-utils.x86_64 -y(下载软件)

[root@localhost ~]# systemctl start nfs-server.service (启动软件)

[root@localhost ~]# vim /etc/exports.d/xx.exports(进入目录)

        /data_server  *(rw)       (把/data_server目录导出来用,并让其下的所有主机可以读和写)

[root@localhost ~]# systemctl restart nfs-utils.service (重启服务使配置生效)

[root@localhost ~]# systemctl stop firewalld.service (关闭防火墙)

[root@localhost ~]# exportfs      -ar(如果不想重启服务,可以使用这条语句)
[root@localhost ~]# chmod   o+w   /data_server/  (给客户端权限)

效果展示:

复制代码
[root@localhost ~]# df -h(检查挂载)

发现/bendi.dir已经挂载

复制代码
[root@localhost ~]# umount    /bendi_dir  (取消/bendi_dir的挂载)

[root@localhost ~]# cd /nfs_share/xixi  (进入到刚才编辑的/nfs_share/xixi查看)

[root@localhost ~]# df -h(检查挂载)

由此可见,自动挂载已经成功!!!!!!

技巧:

复制代码
在客户端中我们能看到
[root@localhost ~]# vim /etc/auto.master(进入)
/nfs_share      /etc/auto.misc(插入的内容)

[root@localhost ~]# vim /etc/auto.misc(进入)
xixi            -fstype=nfs     192.168.5.123:/data_server(插入的内容)

这两个操作可以合并,一起后为mount    192.168.5.123:/data_server      /nfs_share/misc    
相关推荐
数智化管理手记1 小时前
精益生产中的TPM管理是什么?一文破解设备零故障的密码
服务器·网络·数据库·低代码·制造·源代码管理·精益工程
Vect__1 小时前
深刻理解进程、线程、程序
linux
w6100104662 小时前
CKAD-2026-Ingress
运维·k8s·ckad
@insist1233 小时前
网络工程师-生成树协议(STP/RSTP/MSTP)核心原理与应用
服务器·开发语言·网络工程师·软考·软件水平考试
末日汐3 小时前
传输层协议UDP
linux·网络·udp
zzzsde5 小时前
【Linux】库的制作和使用(3)ELF&&动态链接
linux·运维·服务器
CQU_JIAKE5 小时前
4.3【A]
linux·运维·服务器
AI周红伟5 小时前
OpenClaw是什么?OpenClaw能做什么?OpenClaw详细介绍及保姆级部署教程-周红伟
大数据·运维·服务器·人工智能·微信·openclaw
Elastic 中国社区官方博客5 小时前
当 TSDS 遇到 ILM:设计不会拒绝延迟数据的时间序列数据流
大数据·运维·数据库·elasticsearch·搜索引擎·logstash
qing222222225 小时前
Linux中修改mysql数据表
linux·运维·mysql