NFS相关实验


【配置 NFS 服务器和客户端挂载】
1、准备两台虚拟机,安装启动NFS服务器,防火墙放行,两个都需要做
[root@localhost ~]# dnf install nfs-utils -y
[root@localhost ~]# systemctl start nfs-server
[root@localhost ~]# systemctl enable nfs-server
[root@localhost ~]# firewall-cmd --permanent --add-service=nfs
[root@localhost ~]# firewall-cmd --permanent --add-service=mountd
[root@localhost ~]# firewall-cmd --permanent --add-service=rpc-bind
[root@localhost ~]# firewall-cmd --reload

2、配置导出目录
[root@localhost ~]# mkdir /data
[root@localhost ~]# chmod 777 /data/
[root@localhost ~]# touch /data/testfile
[root@localhost ~]# cat /etc/exports
/data 192.168.159.131(rw)
[root@localhost ~]# exportfs -r

3、在客户端查看导出目录
[root@localhost ~]# showmount -e 192.168.159.129
Export list for 192.168.159.129:
/data 192.168.159.131
[root@localhost ~]# mkdir /haha
[root@localhost ~]# mount 192.168.159.129:/data /haha
[root@localhost ~]# df - h /haha
Filesystem Size Used Avail Use% Mounted on
192.168.159.129: /data 45G 4.5G 41G 11% /haha
[root@localhost ~]# cd /haha
[root@localhost haha]# touch testfile1
[root@localhost haha]#ll
total 0
rw- r - r - . 1 nobody nobody 0 Mar 17 17: 05 testfile1
rw- r - r - . 1 root root 0 Mar 17 16: 40 testfile

4、开机自动挂载
[root@localhost ~]# vim /etc/fstab
192.168.115.128: /data /nfsclient/client- data nfs defaults 0 0
保存配置后,重启主机
[root@localhost ~]# df - h /data
Filesystem Size Used Avail Use% Mounted on
192.168.159.129: /data 45G 4.5G 41G 11% /data


【autofs自动挂载】

1、客户端配置autofs
[root@localhost ~]#  yum install autofs -y
[root@localhost ~]# cat /etc/auto.master
/haha   /etc/auto.nfs
/misc    /etc/auto.misc

2、本地端目录 具体挂载配置文件
[root@localhost ~]# cat /etc/auto.nfs
data    192.168.159.129:/data


4、触发自动挂载
[root@localhost ~]# systemctl restart autofs
[root@localhost ~]# cd /haha
[root@localhost haha]# ll
total 0
[root@localhost haha]# cd /haha/data           (进入则成功)
[root@localhost data]# ll
total 0
-rw-r--r--. 1 nobody nobody 0 Jul 10 15:08 hahah1
-rw-r--r--. 1 nobody nobody 0 Jul 10 15:00 testfile
[root@localhost ~]# df -h /haha/        
Filesystem      Size  Used Avail Use% Mounted on
/etc/auto.nfs      0     0     0    - /haha                (出现则成功)


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值