centos7下NFS配置

前言
四台机器:
172.16.158.216(把216机器上的/root/filedata目录共享到217,218,218三台机器的/root/filedir目录下)
172.16.158.217
172.16.158.218
172.16.158.219

一、NFS服务安装配置
216-219四台机口全部安装nfs-utils和rpcbind

1:查看是否安装nfs-utils和rpcbind
     rpm -qa nfs-utils rpcbind

2:安装nfs-utils和rpcbind
     yum install nfs-utils rpcbind

3:查看安装目录
    which rpcbind
4:启动rpc和NFS服务 systemctl start rpcbind.service
systemctl start nfs.service

5: 设置开机自启
systemctl enable rpcbind.service
systemctl enable nfs.service
5:查看状态 systemctl status rpcbind.service systemctl status nfs.service 6:查看进程 ps -ef|egrep "rpc|nfs" 二、配置NFS服务端 配制说明: exports文件配置文件/etc/exports exports文件配置格式:NFS共享的目录 NFS客户端地址1(参数1,参数2,...) 客户端地址2(参数1,参数2,...) NFS客户端地址: 指定IP: 192.168.0.1 指定子网所有主机: 192.168.0.0/24 指定域名的主机: test.com 指定域名所有主机: *.test.com 所有主机: * 参数: ro:目录只读 rw:目录读写 sync:将数据同步写入内存缓冲区与磁盘中,效率低,但可以保证数据的一致性 async:将数据先保存在内存缓冲区中,必要时才写入磁盘 all_squash:将远程访问的所有普通用户及所属组都映射为匿名用户或用户组(nfsnobody) no_all_squash:与all_squash取反(默认设置) root_squash:将root用户及所属组都映射为匿名用户或用户组(默认设置) no_root_squash:与rootsquash取反 anonuid=xxx:将远程访问的所有用户都映射为匿名用户,并指定该用户为本地用户(UID=xxx) anongid=xxx:将远程访问的所有用户组都映射为匿名用户组账户 ################开始在216上进行共享目录的配制#################### 1:创建需要共享的目录 mkdir -p /root/filedata 2:授权 chown nfsnobody.nfsnobody /root/filedata 3:编辑配制文件 vim /etc/exports ###内容: /root/filedata 172.16.158.217(rw,sync,all_squash) /root/filedata 172.16.158.218(rw,sync,all_squash) /root/filedata 172.16.158.219(rw,sync,all_squash) 4:重新加载nfs配置 exportfs -rv 5:查看nfs服务器挂载情况 showmount -e localhost 三、配制NFS客户端 分别在:172.16.158.217,172.16.158.218,172.16.158.219进行操作

1: 查看NFS服务器的共享文件夹 showmount -e 192.168.158.216
2:创建要挂载的对应目录 mkdir -p /root/filedir 3: 把216上的/root/filedata目录挂到当前操作机器的/root/filedir目录 mount -t nfs 172.16.158.216:/root/filedata /root/filedir

4: 在217,218,219上设置开机自动挂载
vi /etc/fstab
172.16.158.216:/root/filedata /root/filedir nfs defaults,_netdev 0 0 4:查看挂载 df -h 四、测试 分别在:172.16.158.217,172.16.158.218,172.16.158.219三台机器上创建一个文件, 在172.16.158.216,172.16.158.217,172.16.158.218,172.16.158.219四台机器上都可以看到说明成功
posted @ 2021-07-06 14:33  Rick2021  阅读(409)  评论(0)    收藏  举报