nfs的服务配置

nfs共享存储

nfs服务是一项基于网络的共享存储,他可以实现server和client端进行数据共享,如果server端授予客户端读写的权限,甚至有同步,异步的权限,就会实现文件同步的共同开发,共同修改,共同创建项目等等操作。
服务端与客户端进行相关配置:
nfs配置文件:/etc/nfs.conf
Server配置:
------------------------ server --------------------------
# 创建共享目录
[root@liuyunfei-rhel-82 ~]# mkdir /nfs-share
# 将目录的权限全部放开
[root@liuyunfei-rhel-82 ~]# chmod 777 /nfs-share/
# nfs-server需要共享的目录的配置文件
[root@liuyunfei-rhel-82 ~]# vim /etc/exports
------------------------------
# ro,rw,sync,async --- 只读,可读写,同步,异步
# hostname         ------ 可以指定主机名,ip地址,或“*”
/nfs-share/ 192.168.159.133(ro,rw,sync,async) 
            hostname
            *
------------------------------
# 防火墙放行服务
[root@liuyunfei-rhel-82 ~]# firewall-cmd --set-default-zone=trusted
success
# 重启服务,开机自启动
[root@liuyunfei-rhel-82 ~]# systemctl restart nfs-server.service 
[root@liuyunfei-rhel-82 ~]# systemctl enable nfs-server.service 

Client配置:
------------------------ client --------------------------
# 客户端安装nfs的相关工具包
[root@liuyunfei-CentOS-7 ]# yum install nfs-utils -y
# 创建共享目录接收的目录,也是未来的挂载点
[root@liuyunfei-CentOS-7 ~]# mkdir /nfs-share
# 将共享过来的目录挂载到本地的目录上,如果需要永久挂载需要编辑 /etc/fstab
[root@liuyunfei-CentOS-7 ~]# mount -t nfs 192.168.159.132:/nfs-share   /nfs-share
# 查看来自 服务器的挂载
[root@liuyunfei-CentOS-7 ~]# showmount -e 192.168.159.132
Export list for 192.168.159.132:
/nfs-share 192.168.159.133

# 也可以使用查看文件系统的方式查看是否挂载成功,最后一行就是新的条目
[root@liuyunfei-CentOS-7 ~]# df -Th
192.168.159.137:/nfs-share nfs4       19G  4.4G   15G  24% /nfs-share
进行测试,检验配置成果:
---------------- test ------------------
# server向共享目录中写入内容:
[root@liuyunfei-rhel-82 ~]# echo "this is the 192.168.159.132 information" >  /nfs-share/server/file
# client查看内容
[root@liuyunfei-CentOS-7 ~]# cat /nfs-share/server/file 
this is the 192.168.159.132 information


# 进行域名解析的命令
# windows
nslookup www.baidu.com
# linux
[root@liuyunfei-rhel-82 ~]# dig www.baidu.com
如果想要实现开机自动挂载等功能,客户端可以修改/etc/fstab文件,里面写上有关的条目即可
[root@liuyunfei-CentOS-7 ~]# vim /etc/fstab
---------------------------------------------
# 因为nfs服务需要网络才可以正常运行,所以需要加参数“_netdev”,是等待主机网络连接正常以后再加载此条目,也可以用老版本的参数“x-systemd.requires=nfs-server.service”代替。
192.168.159.137:/nfs-share /nfs-share           nfs     defaults,_netdev 0 0
-----------------------------------------

[root@liuyunfei-CentOS-7 ~]# mkdir /nfs-share
[root@liuyunfei-CentOS-7 ~]# mount -a
[root@liuyunfei-CentOS-7 ~]# df -Th
192.168.159.137:/nfs-share nfs4       19G  4.4G   15G  24% /nfs-share
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值