使用场景
1台Nginx+多台Tomcat组成集群。文件上传方案:在Nginx上建立共享文件夹。
安装
环境:CentOS 7
主机:192.10.200.120
分机:192.10.200.118
安装命令:
如果安装nfs-utils rpcbind时,报下面错误:
则需要先运行
yum update lvm2
yum -y install nfs-utils rpcbind #安装
mkdir /mnt/webshare #创建共享目录
vi /etc/exports #配置共享目录,新增一行
/mnt/webshare/ 192.10.200.*(rw,no_root_squash,no_all_squash,sync)
systemctl restart rpcbind
systemctl start nfs-server
systemctl start nfs-lock
systemctl start nfs-idmap
exportfs -r #使配置生效exportfs -a
systemctl enable rpcbind.service #开机启动rpcbind.service
systemctl enable nfs-server.service #开机启动
systemctl start rpcbind.service #启动rpcbind 或 service rpcbind start,客户端不用
systemctl start nfs-server.service #启动nfs-server
rpcinfo -p #确认NFS服务器启动成功
exportfs #可以查到已经共享的目录
vi /etc/exports #解决写权限的问题,加sync
/mnt/webshare 192.10.200.120(rw,sync,now_root_squash)
exportfs -fv #重新读取NFS配置文件
exportfs -v #查看配置
客户端挂载
yum update lvm2
yum -y install nfs-utils rpcbind
systemctl restart rpcbind
systemctl start nfs-server
systemctl start nfs-lock
systemctl start nfs-idmap
systemctl enable rpcbind
systemctl enable nfs-server
systemctl enable rpcbind.service #开机启动 chkconfig nfs on / chkconfig rpcbind on
systemctl start rpcbind.service #启动rpcbind
showmount -e 192.10.200.120 #查看服务端有没有目录共享
mkdir -p /mnt/webshare #挂载到自己一个目录下
mount -t nfs -o nolock 192.10.200.120:/mnt/webshare /mnt/webshare
df -h #查看是否挂载成功?
vi /etc/fstab #开机自动挂载,加以下内容
nfs 192.10.200.120:/ /webshare nfs4 ro,hard,intr,proto=tcp,port=2049,noauto 0 0
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。