Linux下的NFS搭建配置

简介: Linux下的NFS搭建配置

@TOC

一、NFS介绍

1.NFS简介

NFS:网络文件系统,由Sun公司开发,通过网络,NFS支持在不同的文件系统之间共享文件.用户不必关心计算机的型号,是由Linux、unix及类似操作系统之间使用的互联网标准协议,可作为他们的本地网络文件系统。

2.NFS特点

①节约使用的磁盘空间:客户端经常使用的数据可以集中存放在一台机器上,并使用NFS发布,那么网络内部所有计算机可以通过网络访问,不必单独存储.
②节约硬件资源:NFS还可以共享软驱,CDROM和ZIP等的存储设备,减少整个网络上的可移动设备的数量.
③用户主目录设定
对于特殊用户,如管理员等,为了管理的需要,可能会经常登录到网络中所有的计算机,若每个客户端,均保存这个用户的主目录很繁琐,而且不能保证数据的一致性.实际上,经过NFS服务的设定,然后在客户端指定这个用户的主目录位置,并自动挂载,就可以在任何计算机上使用用户主目录的文件.

二、环境介绍

操作系统为RHEL8.0
服务端:control ————192.168.200.150
客户端:node1————192.168.200.135

三、服务端配置

1.创建共享目录

[root@control ~]# mkdir -p /share/data
[root@control ~]# ll -ld /share/data/
drwxr-xr-x 2 root root 6 Jul 15 21:31 /share/data/

2.检查NFS包是否安装

root@control ~]# yum list installed |grep nfs
libnfsidmap.x86_64                               1:2.3.3-14.el8                                       @anaconda    
nfs-utils.x86_64                                 1:2.3.3-14.el8                                       @anaconda    
sssd-nfs-idmap.x86_64                            2.0.0-43.el8                                         @anaconda

3.安装nfs相关包

 yum install nfs-utils rpcbind -y

4.编辑配置文件

[root@control ~]# vim /etc/exports
[root@control ~]# cat /etc/exports
/share/data 192.168.200.0/24(rw)

5.重启服务且放行防火墙

[root@control ~]# systemctl restart nfs-server
[root@control ~]# firewall-cmd --permanent --add-service=mountd 
success
[root@control ~]# firewall-cmd --permanent --add-service=nfs
success
[root@control ~]# firewall-cmd --permanent --add-service=rpc-bind 
success
[root@control ~]# firewall-cmd --reload 
success
[root@control ~]#

四、客户端配置

1.检查服务端共享目录是否存在

[root@control ~]# showmount -e 192.168.200.150
Export list for 192.168.200.150:
/share/data 192.168.200.0/24

2.安装自动挂载程序

[root@node1 ~]# yum -y install autofs
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository AppStream is listed more than once in the configuration
Repository BaseOS is listed more than once in the configuration
Repository AppStream is listed more than once in the configuration
Repository BaseOS is listed more than once in the configuration
AppStream                                                                                                      3.1 MB/s | 3.2 kB     00:00    
BaseOS                                                                                                         2.7 MB/s | 2.7 kB     00:00    
ansiable                                                                                                       0.0  B/s |   0  B     00:00    
Zabbix                                                                                                         330  B/s | 2.9 kB     00:09    
Zabbix                                                                                                         493 kB/s | 152 kB     00:00    
Failed to synchronize cache for repo 'ansiable', ignoring this repo.
Dependencies resolved.
===============================================================================================================================================
 Package                         Arch                            Version                                 Repository                       Size
===============================================================================================================================================
Installing:
 autofs                          x86_64                          1:5.1.4-29.el8                          BaseOS                          755 k

Transaction Summary
===============================================================================================================================================
Install  1 Package

Total size: 755 k
Installed size: 3.5 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                       1/1 
  Installing       : autofs-1:5.1.4-29.el8.x86_64                                                                                          1/1 
  Running scriptlet: autofs-1:5.1.4-29.el8.x86_64                                                                                          1/1 
  Verifying        : autofs-1:5.1.4-29.el8.x86_64                                                                                          1/1 
Installed products updated.

Installed:
  autofs-1:5.1.4-29.el8.x86_64                                                                                                                 

Complete!

2.启动服务

[root@node1 ~]# systemctl enable --now autofs
Created symlink /etc/systemd/system/multi-user.target.wants/autofs.service → /usr/lib/systemd/system/autofs.service.

3.编辑配置文件

[root@node1 ~]# grep -E -v '^#|^$' /etc/auto.master
/misc    /etc/auto.misc
/share /etc/auto.nfs
/net    -hosts
+dir:/etc/auto.master.d
+auto.master
[root@node1 ~]# vim /etc/auto.nfs
[root@node1 ~]# cat /etc/auto.nfs 
dpt -rw 192.168.200.150:/share/data
[root@node1 ~]#

五、检查测试

[root@node1 ~]# cd /share
[root@node1 share]# cd dpt
[root@node1 dpt]#
[root@node1 dpt]# df -h
Filesystem                   Size  Used Avail Use% Mounted on
devtmpfs                     970M     0  970M   0% /dev
tmpfs                        984M     0  984M   0% /dev/shm
tmpfs                        984M   22M  962M   3% /run
tmpfs                        984M     0  984M   0% /sys/fs/cgroup
/dev/nvme0n1p3                18G  4.6G   13G  27% /
/dev/nvme0n1p1               495M  140M  356M  29% /boot
//192.168.200.150/share       13G  8.5G  4.1G  68% /media
tmpfs                        197M  4.0K  197M   1% /run/user/0
/dev/sr0                     6.7G  6.7G     0 100% /mnt/cdrom
192.168.200.150:/share/data   13G  8.5G  4.1G  68% /share/dpt
相关文章
|
5天前
|
Oracle Java 关系型数据库
Linux环境安装配置JDK11
Linux环境安装配置JDK11
31 0
|
7天前
|
Ubuntu 安全 Linux
Linux(34)Rockchip RK3568 Ubuntu22.04和Debian 10上配置远程桌面工具
Linux(34)Rockchip RK3568 Ubuntu22.04和Debian 10上配置远程桌面工具
40 0
|
11天前
|
监控 关系型数据库 MySQL
Alibaba Cloud Linux基础入门(1)——配置zabbix
该文档是关于在Alibaba Cloud Linux上配置Zabbix的教程。首先,通过添加Zabbix仓库并安装相关软件包(如zabbix-server,web前端和agent)。然后,安装并启动MySQL数据库,执行`mysql_secure_installation`进行配置。接着,创建名为zabbix的数据库和用户,并导入Zabbix默认数据。最后,设置Zabbix服务开机自启动,并通过浏览器访问http://服务器IP/zabbix完成Web端配置,使用Admin/zabbix登录。
|
1天前
|
存储 关系型数据库 MySQL
linux安装MySQL8.0,密码修改权限配置等常规操作详解
linux安装MySQL8.0,密码修改权限配置等常规操作详解
|
2天前
|
Linux 网络安全 Docker
【Linux】-docker配置容器并打包成镜像
【Linux】-docker配置容器并打包成镜像
|
2天前
|
网络协议 Linux 开发工具
|
4天前
|
监控 关系型数据库 MySQL
|
6天前
|
Ubuntu Linux
Linux(Ubuntu)系统临时IP以及静态IP配置(关闭、启动网卡等操作)
请注意,以上步骤是在临时基础上进行配置的。如果要永久保存静态IP地址,通常还需要修改 `/etc/network/interfaces`文件,以便在系统重启后保持配置。同时,确保备份相关配置文件以防止出现问题。
23 1
|
7天前
|
Java Linux 数据安全/隐私保护
【Linux】如何修改系统文件并保存(配置jdk1.7环境变量)
【Linux】如何修改系统文件并保存(配置jdk1.7环境变量)
12 0
|
7天前
|
Linux 网络安全
Centos6.5安装并配置NFS服务
该内容描述了在Linux系统中设置NFS服务的步骤。首先挂载yum源,然后安装NFS服务,并编辑配置文件。接着,重启rpcbind和NFS服务,可能需要重复此过程以解决初始可能出现的问题。此外,关闭防火墙策略,并再次重启服务。最终,根目录被共享,特定IP网段被允许访问。
18 0

热门文章

最新文章