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

我们部署程序时,图片server是单独的一台server,有自己独立的域名。而应用部署在还有一台server上,我们使用一些附件上传工具。比方ajaxfileupload上传附件时是无法跨域訪问的。

之前想的方案是,先上传到应用所在的server。然后使用java的ftp组件上传到图片server上(当然了,图片server上安装了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文件时,要注意格式,比方同意连接的client地址与权限中间多了一个空格,应该是类似于:/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:在client也一定要注意安装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的人有点帮助。

原文地址:https://www.cnblogs.com/bhlsheji/p/5054606.html