linux不同机器间共享目录,目录绑定-基于NFS

我现在有2台机器,192.168.0.101和192.168.0.102

192.168.0.101作为服务端,192.168.0.102作为客户端,/home/allen/packages/share为共享目录。

然后共享目录建立好了后, 我会在客户端的共享目录中创建一个文件,然在服务端去查看是否有该文件的存在

一  在客户端和服务端分别安装ntfs和rpcbind

1. 安装ntfs-utils

yum -y install ntfs-utils

2.安装rpcbind

yum install rpcbind

3. 查看安装状态

[root@localhost share]# rpm -qa| grep nfs
libnfsidmap-0.25-19.el7.x86_64
nfs4-acl-tools-0.3.3-17.el7.x86_64
nfs-utils-1.3.0-0.68.el7.x86_64
[root@localhost share]# rpm -qa | grep rpcbind
rpcbind-0.2.0-49.el7.x86_64
[root@localhost share]# 

4. 在服务器端和客户端都建好共享目录

mkdir /home/allen/packages/share

二 在服务端配置共享文件

1. 在服务器端配置共享信息

vi /etc/exports

/home/allen/packages/share 192.168.0.102(rw,sync,no_root_squash)

第一部分是你的共享目录 /home/allen/packages/share

扫描二维码关注公众号,回复: 12165366 查看本文章

第二部分是客户端的ip地址192.168.0.102

第三部分是对该共享目录的权限

2. 使上面的配置文件马上生效

exportfs -r

三 在客户端和服务器端分别启动下面的服务

1. 启动服务

systemctl start rpcbind
systemctl start nfs

[root@localhost ~]# systemctl start rpcbind
[root@localhost ~]# systemctl start nfs

2.查看启动状态

[root@localhost ~]# systemctl status nfs
● nfs-server.service - NFS server and services
   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)
   Active: active (exited) since Sun 2021-01-17 05:50:23 PST; 2s ago
  Process: 2457 ExecStartPost=/bin/sh -c if systemctl -q is-active gssproxy; then systemctl reload gssproxy ; fi (code=exited, status=0/SUCCESS)
  Process: 2441 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
  Process: 2440 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
 Main PID: 2441 (code=exited, status=0/SUCCESS)
    Tasks: 0
   CGroup: /system.slice/nfs-server.service

Jan 17 05:50:23 localhost.localdomain systemd[1]: Starting NFS server and services...
Jan 17 05:50:23 localhost.localdomain systemd[1]: Started NFS server and services.
[allen@localhost ~]$ systemctl status rpcbind
● rpcbind.service - RPC bind service
   Loaded: loaded (/usr/lib/systemd/system/rpcbind.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2021-01-17 05:48:52 PST; 21min ago
  Process: 546 ExecStart=/sbin/rpcbind -w $RPCBIND_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 554 (rpcbind)
    Tasks: 1
   CGroup: /system.slice/rpcbind.service
           └─554 /sbin/rpcbind -w

四 在客户端进行挂在操作

1. 客户端测试挂在的目录

[root@localhost share]# showmount -e 192.168.0.101 
Export list for 192.168.0.101:
/home/allen/packages/share 192.168.0.102

2. 客户端实行挂载

[root@localhost share]# mount -t nfs 192.168.0.101:/home/allen/packages/share /home/allen/packages/share
[root@localhost share]# mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)

五 测试挂在情况

1. 在客户端新建文件

[root@localhost share]# vi hellowork.txt
[root@localhost share]# 

2. 在服务的进行查看

[root@localhost ~]# cd /home/allen/packages/share
[root@localhost share]# ls
hellowork.txt

猜你喜欢

转载自blog.csdn.net/pengweismile/article/details/112758723
今日推荐