服务器
| ip |
说明 |
| 10.0.0.110 |
note1 |
| 10.0.0.111 |
note2 |
| 10.0.0.112 |
note3 |
| 10.0.0.113 |
note4 |
| 10.0.0.114 |
note5 |
| 10.0.0.115 |
note6 |
| 10.0.0.116 |
master |
安装NFS
所有节点都要安装
yum install -y nfs-utils
dnf install -y nfs-utils
初始化服务
[master节点],初始化服务,创建共享目录并且生效配置
echo "/data1/nfs/data/ *(insecure,rw,sync,no_root_squash)" > /etc/exports
mkdir -p /data1/nfs/data
systemctl enable rpcbind
systemctl enable nfs-server
systemctl start rpcbind
systemctl start nfs-server
exportfs -r
exportfs
/data1/nfs/data为共享目录位置
配置nfs-client
[note节点] (可选)
showmount -e 10.0.3.6
mkdir -p /data1/nfs/data
mount -t nfs 10.0.3.6:/data1/nfs/data /data1/nfs/data
umount -l /data1/nfs/data
df -h
/data1/nfs/data为共享目录位置
如果报错需要关闭防火墙[systemctl stop firewalld && systemctl disable firewalld]或者开放对应端口
开机启动脚本
[note节点] (可选)
vi /etc/rc.local
su - root -c 'mount -t nfs 10.0.3.6:/data1/nfs/data /data1/nfs/data'
chmod +x /etc/rc.local
个性化开机脚本
[note节点] (可选)
mkdir -p /data0/cmd
tee /data0/cmd/nfs-init.sh <<-'EOF'
su - root -c 'mount -t nfs 10.0.3.6:/data1/nfs/data /data1/nfs/data'
EOF
tee /data0/cmd/startup.sh <<-'EOF'
/data0/cmd/nfs-init.sh
EOF
chmod +x /data0/cmd/*
echo "# init start.sh" >> /etc/rc.local
echo "su - root -c '/data0/cmd/startup.sh'" >> /etc/rc.local
chmod +x /etc/rc.local && chmod +x /etc/rc.d/rc.local