编辑告知网站后台上传图片出错,查看日志报错如下:
http-8080-48 ERROR 2013-10-15 09:32:03 /usr/local/tomcat/webapps/EtnetChinaUI/public/images/dynamic/column/articles/27000/4bf7f10b4d6f4e4786b445ceb0da442d_155x104.jpg (Permission denied)
http-8080-48 ERROR 2013-10-15 09:32:03 /usr/local/tomcat/webapps/EtnetChinaUI/public/images/dynamic/column/articles/27000/4bf7f10b4d6f4e4786b445ceb0da442d_155x104.jpg (Permission denied)
java.io.FileNotFoundException: /usr/local/tomcat/webapps/EtnetChinaUI/public/images/dynamic/column/articles/2700/4bf7f10b4d6f4e4786b445ceb0da442d_155x104.jpg (Permission denied)
dynamic下是动态生成的目录,查看目录权限为nagios不是tomcat,故而tomcat不能写入。再看看其他web服务器,目录权限都是tomcat。几台web是共享nfs的目录,在nfs上共享出来的目录权限是tomcat。
[root@10 ~]# ll tomcat/
total 4
drwxr-xr-x 17 tomcat tomcat 4096 Dec 28 2012 images
tomcat uid为
[root@10 ~]# cat /etc/passwd|grep tomcat
tomcat:x:502:502::/home/tomcat:/bin/bash
[root@10 ~]#
其他有写入权限的web服务器tomcat uid也为502
[root@localhost ~]# cat /etc/passwd|grep tomcat
tomcat:x:502:502::/home/tomcat:/bin/bash
[root@localhost ~]#
没有写入权限的web服务器tomcat uid为
[root@localhost ~]# cat /etc/passwd|grep tomcat
tomcat:x:501:501::/home/tomcat:/bin/bash
[root@localhost ~]#
没有写入权限的web服务器nagios uid为
[root@localhost ~]# cat /etc/passwd|grep nagios
nagios:x:502:502::/home/nagios:/sbin/nologin
[root@localhost ~]#
由于该服务器(没有写入权限的服务器)tomcat uid和nfs的tomcat uid不一致,导致挂载目录的所属用户变成了非tomcat,tomcat对挂载目录没有了写入权限。
解决方法:
在问题服务器上将nagios,tomcat用户先删除再重建,重建时指定tomcat uid为502和nfs上的tomcat uid保持一致。
userdel -r tomcat
useradd -u 502 -s /bin/bash -d /home/tomcat tomcat
dynamic下是动态生成的目录,查看目录权限为nagios不是tomcat,故而tomcat不能写入。再看看其他web服务器,目录权限都是tomcat。几台web是共享nfs的目录,在nfs上共享出来的目录权限是tomcat。
[root@10 ~]# ll tomcat/
total 4
drwxr-xr-x 17 tomcat tomcat 4096 Dec 28 2012 images
tomcat uid为
[root@10 ~]# cat /etc/passwd|grep tomcat
tomcat:x:502:502::/home/tomcat:/bin/bash
[root@10 ~]#
其他有写入权限的web服务器tomcat uid也为502
[root@localhost ~]# cat /etc/passwd|grep tomcat
tomcat:x:502:502::/home/tomcat:/bin/bash
[root@localhost ~]#
没有写入权限的web服务器tomcat uid为
[root@localhost ~]# cat /etc/passwd|grep tomcat
tomcat:x:501:501::/home/tomcat:/bin/bash
[root@localhost ~]#
没有写入权限的web服务器nagios uid为
[root@localhost ~]# cat /etc/passwd|grep nagios
nagios:x:502:502::/home/nagios:/sbin/nologin
[root@localhost ~]#
由于该服务器(没有写入权限的服务器)tomcat uid和nfs的tomcat uid不一致,导致挂载目录的所属用户变成了非tomcat,tomcat对挂载目录没有了写入权限。
解决方法:
在问题服务器上将nagios,tomcat用户先删除再重建,重建时指定tomcat uid为502和nfs上的tomcat uid保持一致。
userdel -r tomcat
useradd -u 502 -s /bin/bash -d /home/tomcat tomcat
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/27181165/viewspace-775738/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/27181165/viewspace-775738/