欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

centos7.8 NFS搭建

程序员文章站 2022-03-11 22:51:49
...

查看系统版本

[[email protected] ~]# cat /etc/redhat-release 
CentOS Linux release 7.8.2003 (Core)
[[email protected] ~]

yum安装wget用语后续下载阿里yum源

[[email protected] ~]# yum -y install wget
Running transaction
  正在安装    : wget-1.14-18.el7_6.1.x86_64                                                                                                                                                                                                                                                                                              1/1 
  验证中      : wget-1.14-18.el7_6.1.x86_64                                                                                                                                                                                                                                                                                              1/1 

已安装:
  wget.x86_64 0:1.14-18.el7_6.1                                                                                                                                                                                                                                                                                                              

完毕!
[[email protected] ~]# 

更换yum源,并生成缓存

[[email protected] ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
--2020-08-20 09:55:56--  https://mirrors.aliyun.com/repo/Centos-7.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 115.231.228.168, 115.223.16.236, 115.223.16.239, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|115.231.228.168|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2523 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”

100%[===================================================================================================================================================================================================================================================================================================>] 2,523       --.-K/s 用时 0s      

2020-08-20 09:55:57 (548 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2523/2523])

[[email protected] ~]# yum makecache
(过程省略)
元数据缓存已建立
[[email protected] ~]#

进入正题
关闭防火墙,禁止开机启动

[[email protected] ~]# systemctl stop firewalld.service
[[email protected] ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[[email protected] ~]# 

查看是否安装nfs、rpcbind(若有安装,则会显示内容)

[[email protected] ~]# rpm -qa |grep nfs
[[email protected] ~]# rpm -qa |grep rpcbind
[[email protected] ~]# 

安装NFS

[[email protected] ~]# yum -y install nfs-utils rpcbind
已安装:
  nfs-utils.x86_64 1:1.3.0-0.66.el7_8                                                                                                                                      rpcbind.x86_64 0:0.2.0-49.el7                                                                                                                                     

作为依赖被安装:
gssproxy.x86_64 0:0.7.0-28.el7           keyutils.x86_64 0:1.5.8-3.el7          libbasicobjects.x86_64 0:0.1.1-32.el7        libcollection.x86_64 0:0.7.0-32.el7       libevent.x86_64 0:2.0.21-4.el7       libini_config.x86_64 0:1.3.1-32.el7       libnfsidmap.x86_64 0:0.25-19.el7       libpath_utils.x86_64 0:0.2.1-32.el7      
libref_array.x86_64 0:0.1.5-32.el7       libtirpc.x86_64 0:0.2.4-0.16.el7       
libverto-libevent.x86_64 0:0.2.5-4.el7       quota.x86_64 1:4.01-19.el7                quota-nls.noarch 1:4.01-19.el7       tcp_wrappers.x86_64 0:7.6-77.el7 
[[email protected] ~]# 

启动NFS

[[email protected] ~]# systemctl start rpcbind
[[email protected] ~]# systemctl start nfs

新建NFS存储目录data,设置共享目录权限

[[email protected] ~]# ls
anaconda-ks.cfg
[[email protected] ~]# mkdir data
[[email protected] ~]# ls
anaconda-ks.cfg  data
[[email protected] ~]# vi /etc/exports
插入加入以下内容
/root/data/ 192.168.1.2/32(insecure,rw,sync,no_root_squash) 192.168.10.8(insecure,rw,sync,no_root_squash)

fsid=0:只能共享一个目录,此目录将成为NFS服务器的根目录。
rw:目录读写
sync:传输效率低,可保证数据一致性
async:传输效率高

重新加载配置、重启NFS服务器

[[email protected] ~]# exportfs -rv
[[email protected] ~]# systemctl restart nfs.service

至此,NFS搭建完成

相关标签: centos NFS