在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
相关推荐
热爱嵌入式的小许2 小时前
Linux基础项目开发1:量产工具——显示系统
linux·运维·服务器·韦东山量产工具
韩楚风6 小时前
【linux 多进程并发】linux进程状态与生命周期各阶段转换,进程状态查看分析,助力高性能优化
linux·服务器·性能优化·架构·gnu
陈苏同学6 小时前
4. 将pycharm本地项目同步到(Linux)服务器上——深度学习·科研实践·从0到1
linux·服务器·ide·人工智能·python·深度学习·pycharm
Pythonliu77 小时前
茴香豆 + Qwen-7B-Chat-Int8
linux·运维·服务器
你疯了抱抱我7 小时前
【RockyLinux 9.4】安装 NVIDIA 驱动,改变分辨率,避坑版本。(CentOS 系列也能用)
linux·运维·centos
我是哈哈hh7 小时前
专题十_穷举vs暴搜vs深搜vs回溯vs剪枝_二叉树的深度优先搜索_算法专题详细总结
服务器·数据结构·c++·算法·机器学习·深度优先·剪枝
郭二哈7 小时前
C++——模板进阶、继承
java·服务器·c++
挥剑决浮云 -7 小时前
Linux 之 安装软件、GCC编译器、Linux 操作系统基础
linux·服务器·c语言·c++·经验分享·笔记
立秋67898 小时前
Python的defaultdict详解
服务器·windows·python
Lansonli8 小时前
云原生(四十一) | 阿里云ECS服务器介绍
服务器·阿里云·云原生