########## # Server # ########## # URL: https://blog.csdn.net/qq_31278903/article/details/82944545 # 安装NFS server软件 apt install -y nfs-kernel-server # 创建共享目录并将目录的权限改为777 mkdir -p /data/nfs chmod 755 /data/nfs # 配制文件vi /etc/exports #echo '/data/nfs *(insecure,rw,sync,no_root_squash)' >> /etc/exports #echo '/data/nfs *(insecure,rw,sync,no_all_squash)' >> /etc/exports echo '/data/nfs 8.92.9.0/24(insecure,rw,sync,no_all_squash)' >> /etc/exports cat /etc/exports # 开启nfs服务 /etc/init.d/nfs-kernel-server restart # 重启rpcbind /etc/init.d/rpcbind restart # 开启自启动 systemctl enable rpcbind nfs-kernel-server # 防火墙(ubuntu) ufw disable # 防火墙(euleros) systemctl disable firewalld systemctl stop firewalld ########## # Client # ########## # 安装nfs-common(ubuntu) apt install -y nfs-common # 安装nfs-utils(euleros) yum install -y nfs-utils # 查看服务端已共享的目录 showmount -e 8.92.9.30 # 远程mount #mount 8.92.9.30:/data /nfs mkdir -p /nfs chmod 755 /nfs mount -t nfs -o vers=3,nolock 8.92.9.30:/data/nfs /nfs # 开机挂载(euleros) if [ -f /etc/rc.d/rc.local ]; then filename=/etc/rc.d/rc.local chmod 755 ${filename} else filename=/etc/rc.local fi grep '8.92.9.30:/data/nfs' ${filename} if [ $? -ne 0 ]; then echo "" >> ${filename} echo "# NFS" >> ${filename} echo "mount -t nfs -o vers=3,nolock 8.92.9.30:/data/nfs /nfs" >> ${filename} fi cat ${filename}