centOS 7 安装nfs

A机器(172.29.127.214)
~验证机器是否安装nfs
[root@iZuf68axr8qcp54hhjv1utZ ~]#rpm -qa | grep nfs
[root@iZuf68axr8qcp54hhjv1utZ ~]#rpm -qa | grep rpcbind
~安装nfs
[root@iZuf68axr8qcp54hhjv1utZ ~]#yum -y install nfs-utils rpcbind
~创建同步目录
[root@iZuf68axr8qcp54hhjv1utZ ~]#mkdir -p /export/nfs
[root@iZuf68axr8qcp54hhjv1utZ ~]#chmod 666 /export/nfs/

~配置要互相同步的机器
[root@iZuf68axr8qcp54hhjv1utZ ~]# vim /etc/exports 
/export/nfs/ 172.29.127.215(rw,no_root_squash,no_all_squash,sync)

~重启nfs
[root@iZuf68axr8qcp54hhjv1utZ ~]# service nfs restart 
Redirecting to /bin/systemctl restart nfs.service

~查看配置是否生效
[root@iZuf68axr8qcp54hhjv1utZ ~]# showmount -e
Export list for iZuf68axr8qcp54hhjv1utZ:
/export/nfs 172.29.127.215
[root@iZuf68axr8qcp54hhjv1utZ ~]# 

B机器(172.29.127.215):
[root@iZuf68axr8qcp54hhjv1utZ ~]# yum -y install nfs-utils rpcbind
[root@iZuf68axr8qcp54hhjv1utZ ~]# mkdir -p /export/nfs
[root@iZuf68axr8qcp54hhjv1utZ ~]# chmod 666 /export/nfs/
~挂载A机器目录,建立映射关系
[root@iZuf68axr8qcp54hhjv1uuZ ~]# mount -t nfs 172.29.127.214:/export/nfs/  /export/nfs/
[root@iZuf68axr8qcp54hhjv1uuZ ~]# service rpcbind start
Redirecting to /bin/systemctl start rpcbind.service
[root@iZuf68axr8qcp54hhjv1uuZ ~]# 

[root@iZuf68axr8qcp54hhjv1uuZ ~]# service nfs start
Redirecting to /bin/systemctl start nfs.service
[root@iZuf68axr8qcp54hhjv1uuZ ~]# 

~验证:
B机器新建文件
[root@iZuf68axr8qcp54hhjv1uuZ nfs]# vi shaotest.txt 
[root@iZuf68axr8qcp54hhjv1uuZ nfs]# ll
-rw-r--r-- 1 root root   32 2月  28 11:07 shaotest.txt

A机器查看是否同步
[root@iZuf68axr8qcp54hhjv1utZ nfs]# ll
-rw-r--r-- 1 root root   32 2月  28 11:07 shaotest.txt

同样在A机器创建目录B也会有对应目录

  

posted @ 2023-02-28 16:17  ~清风煮酒~  阅读(101)  评论(0编辑  收藏  举报