NFS服务

一、服务器

1.安装NFS服务

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

 2.启动NFS服务

# 查看rpc服务状态
[root@localhost ~]# systemctl status rpcbind

 启动rpc服务

[root@localhost ~]# systemctl enable --now rpcbind

nfs开机自启

[root@localhost ~]# systemctl enable --now nfs-server

启动nfs服务

[root@localhost ~]# systemctl start nfs-server

3.配置防火墙放行规则

[root@localhost ~]# firewall-cmd --add-service=nfs
success
[root@localhost ~]# firewall-cmd --add-service=mountd
success
[root@localhost ~]# firewall-cmd --add-service=rpc-bind
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# firewall-cmd --list-services
cockpit dhcpv6-client dns http https mountd nfs rpc-bind ssh

4.配置导出文件

[root@localhost ~]# mkdir /nfs
[root@localhost ~]# chmod 777 /nfs
[root@localhost ~]# touch /nfs/testfile
[root@localhost ~]# ll /nfs
total 0
-rw-r--r--. 1 root   root   0 Jul 10 13:10 testfile
[root@localhost ~]# cat /etc/exports
/nfs  *(rw)
[root@localhost ~]# systemctl restart nfs-server

5.本地测试

[root@localhost ~]# showmount -e 192.168.166.129
Export list for 192.168.166.129:
/nfs *

二、客户端

 1.安装NFS服务

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

 2.启动NFS服务

# 查看rpc服务状态
[root@localhost ~]# systemctl status rpcbind

 启动rpc服务

[root@localhost ~]# systemctl enable --now rpcbind

nfs开机自启

[root@localhost ~]# systemctl enable --now nfs-server

启动nfs服务

[root@localhost ~]# systemctl start nfs-server

3.配置防火墙放行规则

[root@localhost ~]# firewall-cmd --add-service=nfs
success
[root@localhost ~]# firewall-cmd --add-service=mountd
success
[root@localhost ~]# firewall-cmd --add-service=rpc-bind
success
[root@localhost ~]# firewall-cmd --reload
success
[root@localhost ~]# firewall-cmd --list-services
cockpit dhcpv6-client dns http https mountd nfs rpc-bind ssh

4.客户端查看导出文件

[root@localhost ~]# showmount -e 192.168.166.129
Export list for 192.168.166.129:
/nfs *
[root@localhost ~]# mkdir /haha
[root@localhost ~]# mount 192.168.166.129:/nfs /haha/
# 查看挂载
[root@localhost ~]# df -h /haha
Filesystem            Size  Used Avail Use% Mounted on
192.168.166.129:/nfs   17G  4.3G   13G  25% /haha
[root@localhost ~]# mkdir /haha/test
[root@localhost ~]# ll /haha/
total 0
-rw-r--r--. 1 nobody nobody 0 Jul 10 12:56 test
-rw-r--r--. 1 root   root   0 Jul 10 13:10 testfile

5.开机自动挂载

[root@localhost ~]# cat /etc/fstab
192.168.166.129:/nfs  /haha  nfs  defaults 0 0  # 添加本行

# 主机重启,查看文件挂载情况
[root@localhost ~]# df -h /haha/
Filesystem            Size  Used Avail Use% Mounted on
192.168.166.129:/nfs   17G  4.3G   13G  25% /haha

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值