Linux NFS服务器

目录

一、安装配置 NFS 服务(服务端)

1、添加hosts解析

2、安装 NFS 服务器

3、创建 NFS 存储目录

4、配置 NFS 服务

 5、设置 NFS 服务开机启动

 6、确认 NFS 服务器启动

二、挂载端安装 NFS 客户端

1、安装 NFS 软件包

2、设置 rpcbind 开机启动

3、启动 rpcbind 服务

4、查看 NFS 服务端共享

5、挂载使用 NFS 存储


环境准备

两台Linux系统,一台作为服务端(10.0.0.129),一台作为客户端(10.0.0.131)。

一、安装配置 NFS 服务(服务端)

1、添加hosts解析

[root@localhost ~]# vim /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.129      nas
10.0.0.131      zhang

2、安装 NFS 服务器

[root@localhost ~]# yum install -y nfs-utils

3、创建 NFS 存储目录

[root@localhost ~]# mkdir /data

4、配置 NFS 服务

[root@localhost ~]# vim /etc/exports

/data           10.0.0.0/24(rw,sync,no_root_squash)

 5、设置 NFS 服务开机启动

启动 rpcbind 服务,后启动NFS服务

[root@localhost ~]# systemctl enable rpcbind.service
[root@localhost ~]# systemctl enable nfs-server
[root@localhost ~]# systemctl restart rpcbind.service
[root@localhost ~]# systemctl restart nfs-server

 6、确认 NFS 服务器启动

[root@localhost ~]# exportfs -v
/data         	10.0.0.0/24(sync,wdelay,hide,no_subtree_check,sec=sys,rw,secure,no_root_squash,no_all_squash)

二、挂载端安装 NFS 客户端

1、安装 NFS 软件包

[root@localhost ~]# yum -y install nfs-utils

2、设置 rpcbind 开机启动

[root@localhost ~]# systemctl enable rpcbind.service

3、启动 rpcbind 服务

[root@localhost ~]# systemctl restart rpcbind.service

*客户端不需要启动nfs服务 

4、查看 NFS 服务端共享

检查 NFS 服务器端是否有目录共享:showmount -e nfs  服务器IP/nfs服务器主机名 

[root@localhost ~]# showmount -e nas
Export list for nas:
/data 10.0.0.0/24

5、挂载使用 NFS 存储

第一种:手动挂载

[root@localhost ~]# mkdir /data
[root@localhost ~]# mount -t nfs nas:/data /data

卸载

[root@localhost ~]# umount /data

第二种:开机自动挂载

[root@localhost ~]# vim /etc/fstab
nas:/data       /data    nfs     defaults   0 0 

[root@localhost ~]# mount -a

 查看挂载

[root@localhost ~]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
nas:/data                 17G  6.7G   11G   39% /data

查看RPC服务列表

[root@localhost ~]# rpcinfo -p
   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper

你可能感兴趣的:(服务器,linux,centos)