在CentOS 7 中配置NFS服务器

目录

1、克隆两个虚拟机

[2、安装 NFS 服务](#2、安装 NFS 服务)

[3、NFS 服务使用](#3、NFS 服务使用)


1、克隆两个虚拟机

复制代码
nfs-server

nfs-client(修改ip地址)

[root@xnode1 ~]# cd /etc/sysconfig/network-scripts/

[root@xnode1 network-scripts]# vi ifcfg-eno16777736

#修改内容如下

BOOTPROTO=static

ONBOOT=yes

IPADDR=192.168.224.4(网络nat网段)

NETMASK=255.255.255.0

GATEWAY=192.168.224.2

DNS1=8.8.8.8

root@xnode1 network-scripts\]#cd(退出) \[root@xnodel\~\]#systemctl restart network

CRT连接(root密码:000000)

(2)主机名配置及解释

复制代码
[root@demo ~]# hostnamectl set-hostname nfs-server
[root@demo ~]# bash
[root@nfs-server ~]# vi /etc/hosts

#增加

192.168.224.3 nfs-server

192.168.224.4 nfs-client

复制代码
[root@demo ~]# hostnamectl set-hostname nfs-client
[root@demo ~]# bash
[root@nfs-client ~]# vi /etc/hosts

#增加

192.168.224.3 nfs-server

192.168.224.4 nfs-client

2、安装 NFS 服务

复制代码
[root@nfs-server ~]# yum -y install nfs-utils rpcbind
[root@nfs-client ~]#  yum -y install nfs-utils rpcbind

3、NFS 服务使用

复制代码
[root@nfs-server ~]# mkdir /mnt/test
[root@nfs-server ~]# vi /etc/exports

#增加

/mnt/test 192.168.224.0/24(rw,no_root_squash,no_all_squash,sync,anonuid=501,anongid=501)

复制代码
[root@nfs-server ~]# exportfs -r

nfs-server 端启动 NFS 服务,命令如下:

复制代码
[root@nfs-server ~]# systemctl start rpcbind 
[root@nfs-server ~]# systemctl start nfs

nfs-server 端查看可挂载目录,命令如下:

复制代码
[root@nfs-server ~]# showmount -e 192.168.224.3

转到 nfs-client 端,在客户端挂载前,先要将服务器的 SELinux 服务和防火墙服务关闭, 命令如下:

复制代码
[root@nfs-client ~]# setenforce 0 [root@nfs-client ~]# systemctl stop firewalld

在 nfs-client 节点,进行 NFS 共享目录的挂载,命令如下:

复制代码
[root@nfs-client ~]# mount -t nfs 192.168.224.3:/mnt/test /mnt/

查看挂载情况

复制代码
[root@nfs-client ~]# df -h

4.验证 NFS 共享存储

复制代码
[root@nfs-client ~]# cd /mnt/

[root@nfs-client mnt]# ll

total 0

[root@nfs-client mnt]# touch abc.txt

[root@nfs-client mnt]# md5sum abc.txt d41d8cd98f00b204e9800998ecf8427e abc.txt

[root@nfs-server ~]# cd /mnt/test/

[root@nfs-server test]# ll

total 0

-rw-r--r--. 1 root root 0 Oct 30 07:18 abc.txt

[root@nfs-server test]# md5sum abc.txt d41d8cd98f00b204e9800998ecf8427e abc.txt
相关推荐
古希腊数通小白(ip在学)2 小时前
stp拓扑变化分类
运维·服务器·网络·智能路由器
Muxiyale3 小时前
使用spring发送邮件,部署ECS服务器
java·服务器·spring
12点一刻4 小时前
搭建自动化工作流:探寻解放双手的有效方案(2)
运维·人工智能·自动化·deepseek
未来之窗软件服务4 小时前
东方仙盟AI数据中间件使用教程:开启数据交互与自动化应用新时代——仙盟创梦IDE
运维·人工智能·自动化·仙盟创梦ide·东方仙盟·阿雪技术观
FreeBuf_5 小时前
微软365 PDF导出功能存在本地文件包含漏洞,可泄露敏感服务器数据
服务器·microsoft·pdf
lixzest5 小时前
C++ Lambda 表达式详解
服务器·开发语言·c++·算法
o不ok!5 小时前
Linux面试问题-软件测试
linux·运维·服务器
小小不董7 小时前
深入理解oracle ADG和RAC
linux·服务器·数据库·oracle·dba
狄加山6758 小时前
Cadence模块复用
服务器·硬件架构·硬件工程·信号处理·智能硬件