Centos7 安装配置 NFS 服务和挂载
现在有 3 台服务器 s1(主),s2(从), s3(从)需要实现文件实时同步,我们可以安装 Nfs 服务端和
客户端来实现!
一、安装 NFS 服务器所需的软件包:
yum install -y nfs-utils
二、编辑 exports 文件,添加从机
vim /etc/exports
/home/nfs/ 192.168.248.0/24(rw,sync,fsid=0)
同 192.168.248.0/24 一个网络号的主机可以挂载 NFS 服务器上的/home/nfs/目录到自己的文件
系统中
[root@zhangjie yum.repos.d]# cat /etc/exports
/soft 10.129.82.0/24(rw,sync.fsid=0)
rw 表示可读写;sync 表示同步写,fsid=0 表示将/data 找个目录包装成根目录
三、启动 nfs 服务
先为 rpcbind 和 nfs 做开机启动:(必须先启动 rpcbind 服务)
systemctl enable rpcbind.service
systemctl enable nfs-server.service
然后分别启动 rpcbind 和 nfs 服务:
systemctl start rpcbind.service
systemctl start nfs-server.service
确认 NFS 服务器启动成功:
rpcinfo -p
检查 NFS 服务器是否挂载我们想共享的目录 /home/nfs/: