在linux上创建nfs遇到的问题。


我们部署程序时,图片服务器是单独的一台服务器,有自己独立的域名。而应用部署在另一台服务器上,我们使用一些附件上传工具,比如ajaxfileupload上传附件时是无法跨域访问的。之前想的方案是,先上传到应用所在的服务器,然后使用java的ftp组件上传到图片服务器上(当然了,图片服务器上安装了ftp服务端)。可是后来发现ftp上传比较慢而且不稳定,决定换成NFS来解决这个问题,当然了这个方案到底是好还是不好还有待检验,这里不做讨论。之前没有弄过这个玩意,这里记录下遇到的问题。

问题1:操作系统版本的问题。

由于我的操作系统没有安装NFS,所以首先得安装,这里要注意在CentOS不同版本中,比如CentOS5.X下需要使用命令:yum -y install nfs-utils portmap。我们使用的操作系统是CentOS6.5,我们这里需要安装的命令是:yum -y install nfs-utils rpcbind(关于yum命令,大家可以查查资料,总之其思路和maven的设计思路挺类似)。

问题2:修改/etc/exports文件时,要注意格式,比如允许连接的客户端地址与权限中间多了一个空格,应该是类似于:/usr/local/test/ 192.168.1.226(rw,no_root_squash,no_all_squash,sync),而不是:/usr/local/test/ 192.168.0.120 (rw,no_root_squash,no_all_squash,sync),否则在启动NFS时就会报下边错误:exportfs: No options for /usr/local/data/ 192.168.0.120: suggest 192.168.0.120(sync) to avoid warning
exportfs: No host name given with /usr/local/data (rw,no_root_squash,no_all_squash,sync), suggest *(rw,no_root_squash,no_all_squash,sync) to avoid warning
/tomcat/webfile 10.163.224.132 (rw,sync,no_root_squash)

问题3:exportfs -r,这个一定要执行,否则不生效;

问题4:在客户端也一定要注意安装NFS,否则光安装服务端是不能访问的。

问题5:service nfs start如果出现以下问题,可以不用理会:

Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS mountd: rpc.mountd: svc_tli_create: could not open connection for udp6
rpc.mountd: svc_tli_create: could not open connection for tcp6
rpc.mountd: svc_tli_create: could not open connection for udp6
rpc.mountd: svc_tli_create: could not open connection for tcp6
rpc.mountd: svc_tli_create: could not open connection for udp6
rpc.mountd: svc_tli_create: could not open connection for tcp6
[ OK ]
Starting NFS daemon: rpc.nfsd: address family inet6 not supported by protocol TCP
[ OK ]
Starting RPC idmapd: [ OK ]

以上就是整个过程,其实也没有啥技术含量,就是对于不熟悉linux的人有点帮助。

相关内容