cse复习 文件共享 nfs服务
实验一 二 服务端建立nfs服务 客户端挂载该服务
服务端
[root@server ~]# dnf install nfs-utils -y
正在更新 Subscription Management 软件仓库。[root@server ~]# mkdir /nfs_server[root@server ~]# setenforce 0
[root@server ~]# getenforce
Permissive
[root@server ~]# systemctl status firewalld
○ firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; preset: enabled)Active: inactive (dead)Docs: man:firewalld(1)[root@server ~]# vim /etc/exports[root@server ~]# exportfs -rv
exporting 192.168.25.200:/nfs_server
[root@server ~]# ^C[root@server ~]#
[root@server ~]# chmod 777 /nfs_server
[root@server ~]#
客户端
[root@client yum.repos.d]# dnf install nfs-utils -y
正在更新 Subscription Management 软件仓库。[root@client yum.repos.d]# showmount -e 192.168.25.150
Export list for 192.168.25.150:
/nfs_server 192.168.25.200
[root@client yum.repos.d]#[root@client yum.repos.d]# showmount -e 192.168.25.150
Export list for 192.168.25.150:
/nfs_server 192.168.25.200
[root@client yum.repos.d]# mkdir /nfs_client
mkdir: 无法创建目录 “/nfs_client”: 文件已存在
[root@client yum.repos.d]# mount 192.168.25.150:/nfs_server /nfs_client
[root@client yum.repos.d]# cd /nfs_client/
[root@client nfs_client]# touch 1
touch: 无法创建 '1': 权限不够
# 写不进去 是因为在服务器上被映射为了nobody 属于其他人权限组 该组没有写权限 所以 在服务端修改目录权限 即可
[root@client nfs_client]# touch 1
[root@client nfs_client]#实验4,实现自动挂载并实现不操作 5秒后自动取消挂载
[root@client nfs_client]# yum install autofs -y
正在更新 Subscription Management 软件仓库。已升级:autofs-1:5.1.7-65.el9.x86_64完毕![root@client nfs_client]# vim /etc/autofs.conf[root@client nfs_client]# systemctl enable --now autofs
Created symlink /etc/systemd/system/multi-user.target.wants/autofs.service → /usr/lib/systemd/system/autofs.service.[root@client nfs_client]# cd /net/192.168.25.150[root@client 192.168.25.150]# ls
nfs_server
[root@client 192.168.25.150]# cd /net/192.168.25.150/nfs_server/
[root@client nfs_server]# ls
1
实验五,指定自动挂载的目录
[root@client nfs_server]# vim /etc/auto.master
[root@client nfs_server]# cat /etc/auto.master | head -15
#
# 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/nfs_auto /etc/auto.nfs_auto[root@client nfs_auto]# vim /etc/auto.nfs_auto
[root@client nfs_auto]# systemctl restart autofs.service[root@client nfs_auto]# cat /etc/auto.nfs_auto
fromserver 192.168.25.150:/nfs_server
[root@client nfs_auto]# tree /nfs_auto
/nfs_auto0 directories, 0 files
[root@client nfs_auto]# cd /nfs_auto/fromserver
[root@client fromserver]# ls
1
[root@client fromserver]# ll
总用量 0
-rw-r--r--. 1 nobody nobody 0 10月 31 20:47 1