两个linux nfs文件共享,NFS实现linux之间的文件共享

NFS(网络文件系统)服务可以将远程 Linux 系统上的文件共享资源挂载到本地主机的目录上,从而使得本地主机(Linux 客户端)基于 TCP/IP 协议,像使用本地主机上的资源那样读写远程 Linux 系统上的共享文件。

1. 安装NFS服务端软件包

[root@linuxprobe ~]# yum install nfs-utils

Loaded plugins: langpacks, product-id, subscription-manager

(1/2): rhel7/group_gz | 134 kB 00:00

(2/2): rhel7/primary_db | 3.4 MB 00:00

Package 1:nfs-utils-1.3.0-0.el7.x86_64 already installed and latest version

Nothing to do

2.创建NFS服务端共享文件夹

[root@linuxprobe ~]# mkdir /nfsfile

[root@linuxprobe ~]# chmod -Rf 777 /nfsfile

[root@linuxprobe ~]# echo "welcome to linuxprobe.com" > /nfsfile/readme

3.配置NFS服务端

209638d9a62a

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

/nfsfile 192.168.10.*(rw,sync,root_squash)

4. 重启NFS服务端相关服务

[root@linuxprobe ~]# systemctl restart rpcbind

[root@linuxprobe ~]# systemctl enable rpcbind

[root@linuxprobe ~]# systemctl start nfs-server

[root@linuxprobe ~]# systemctl enable nfs-server

ln -s '/usr/lib/systemd/system/nfs-server.service' '/etc/systemd/system/nfs.

target.wants/nfs-server.service'

5. NFS客户端查看挂载信息

[root@linuxprobe ~]# showmount -e 192.168.0.31

Export list for 192.168.0.31:

/nfsfile 192.168.0.*

6.NFS客户端执行挂载并设置为永久生效

[root@linuxprobe ~]# mkdir /nfsfile

[root@linuxprobe ~]# mount -t nfs 192.168.10.10:/nfsfile /nfsfile

[root@linuxprobe ~]# vim /etc/fstab

# #

/etc/fstab

# Created by anaconda on Wed May 4 19:26:23 2017

# #

Accessible filesystems, by reference, are maintained under '/dev/disk'

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

/dev/mapper/rhel-root / xfs defaults 1 1

UUID=812b1f7c-8b5b-43da-8c06-b9999e0fe48b /boot xfs defaults 1 2

/dev/mapper /rhel-swap swap swap defaults 0 0

/dev/cdrom /media/cdrom iso9660 defaults 0 0

#下面一行是配置信息

192.168.10.10:/nfsfile /nfsfile nfs defaults 0 0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值