Linux 搭建NFS服务器原创
金蝶云社区-薛孟洋
薛孟洋
3人赞赏了该文章 995次浏览 未经作者许可,禁止转载编辑于2021年03月09日 15:59:01

容器部署的时候需要共享存储,测试环境如果客户不给分配共享存储,可以在其中一台机器上挂载一块空间大点的硬盘,作为NFS服务器共享存储(以下为客户机器没有外网且没有光驱的操作,有外网或者有光驱步骤更少一点)

1、配置本地镜像yum源

镜像上传到 /tmp 

mount -t iso9660 -o  loop /tmp/CentOS-7-x86_64-DVD-1908.iso  /mnt 


cd  /etc/yum.repo.d/


vi bendi.repo

[bendi]

name=bendi

baseurl=file:///mnt/

gpgcheck=0

groupcheck=1

gpgkey=

file:///mnt


yum makecache

bendirepo2.png


2、安装nfs

yum -y install nfs-utils

mkdir -p /var/export/nfs

echo "/var/export/nfs  *(rw,async,no_root_squash,no_subtree_check)" >> /etc/exports #将/var/export/nfs目录共享给所有用户

exportfs -a #让配置文件生效

echo 'LOCKD_TCPPORT=32803'  >>  /etc/sysconfig/nfs

echo 'LOCKD_UDPPORT=32769' >>  /etc/sysconfig/nfs

echo 'MOUNTD_PORT=892' >>  /etc/sysconfig/nfs

echo 'RQUOTAD_PORT=875' >>  /etc/sysconfig/nfs

echo 'STATD_PORT=662' >>  /etc/sysconfig/nfs

echo 'STATD_OUTGOING_PORT=2020' >>  /etc/sysconfig/nfs


#关闭防火墙以免用户连接被防火墙拒绝

setenforce 0

systemctl stop firewalld.service

systemctl disable firewalld.service


#启用nfs服务并设置开机自启动

systemctl start  rpcbind.service

systemctl start nfs-server.service

systemctl enable rpcbind.service

systemctl enable nfs-server.service


3、客户机链接nfs服务器需要安装nfs客户端

yum install nfs-utils

systemctl start  rpcbind.service

systemctl start nfs-server.service

systemctl enable rpcbind.service

systemctl enable nfs-server.service


4、挂载nfs

mkdir /mnt/test

mount nfs-server-ip:/var/export/nfs /mnt/test  #nfs-server-ip为nfs服务器的IP地址

df -h #查看挂载是否成功

2018071115371936.jpg


赞 3