cannot restore segment prot after reloc: Permission denied
最近把一个java项目从windows平台部署到linux下,安装测试时遇见了cannot restore segment prot after reloc: Permission denied 这个问题。
最近用到gearman。由于C语言的server一直编译不过去(貌似是boost的问题)。所以想到用java版本的server。但是没想到又遇到了一些问题。
首先运行命令:
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy9453')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy9453>java -jar java-gearman-service-0.5.jar结果出现如下提示:
java/nio/channels/CompletionHandler
java-gearman-service-0.5
usage:
java [jvm options] -jar java-gearman-service-0.5.jar [server options]
Options:
-p PORT --port=PORT Defines what port number the server will listen on (Default: 4730)
-l LEVEL --logger=LEVEL Specifies the logging level (Default: 0)
-v --version Display the version of java gearman service and exit
-? --help Print this help menu and exit
java/nio/channels/CompletionHandler
java-gearman-service-0.5
usage:java [jvm options] -jar java-gearman-service-0.5.jar [server options]
Options: -p PORT --port=PORT Defines what port number the server will listen on (Default: 4730) -l LEVEL --logger=LEVEL Specifies the logging level (Default: 0) -v --version Display the version of java gearman service and exit -? --help Print this help menu and exit
然后到网上找了一下问题,发现是SELinux的问题,那么就得解决它了。
方法一:
找到/etc/sysconfig/selinux,编辑SELINUX属性默认为(SELINUX=enforcing)改成SELINUX=disabled。如果已经是disabled就不用改了,也可以注释SELINUX=enforcing,新添加一行SELINUX=disabled。保存退出。然后继续调试,如果还是出现这样的问题就用方法二。
方法二:
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy3699')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy3699>chcon -t texrel_shlib_t如: chcon -t texrel_shlib_t /路径/名字.so
方法三:
解决问题的步骤如下:
首先编辑配置文件:/etc/selinux/config
找到如下内容:
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy5862')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy5862># This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
# SELINUX=enforcing
将# SELINUX=enforcing的注释去掉,并在下边增加这样一行:SELINUX=disabled
保存退出,结果还是报相同的错误。然后运行如下命令:
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy3375')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy3375>chcon -t texrel_shlib_t /usr/local/jdk1.7.0_01/jre/lib/i386/server/libjvm.so
注意,错误提示中提示哪个文件出错就在后边写上哪个文件。
我自己的问题是
修改/etc/profile文件最后一行加入
JAVA_HOME=jdk路径
CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
export PATH JAVA_HOME CLASSPATH
解决的办法是在root用户下,修改/etc/selinux/config 文件,
<table width="620" align="center" border="0" cellpadding="1" cellspacing="1" style="background:#FB7"> <tr> <td width="464" height="27" bgcolor="#FFE7CE"> 代码如下</td> <td width="109" align="center" bgcolor="#FFE7CE" style="cursor:pointer;" onclick="doCopy('copy2982')">复制代码</td> </tr> <tr> <td height="auto" colspan="2" valign="top" bgcolor="#FFFFFF" style="padding:10px;" class="copyclass" id=copy2982>把SELINUX=enforcing 改成 SELINUX=disabled。
然后,保存关闭,重启机器就可以了。
加上这个就能解决这个问题了,我先用方法一结果不奏效然后再GG搜索了下,在SELinux被disable的情况下然后执行这个命令,肯定能解决这个问题。
您可能感兴趣的文章:
cannot restore segment prot after reloc: Permission denied
php报错Permission denied的解决一法
centos 5.2 安装smb 无法访问的问题
su: /bin/bash: Permission denied错误的解决方法
php include提示failed to open stream: Permission denied in错误
php提示 Warning: touch() [function.touch]: Utime failed: Permission denied in错误
php操作文件提示没有权限怎么办
startOSW.sh: ./OSWatcher.sh: /bin/ksh: bad interpreter: Permission denied的解决方法
shell 判断进程是否存在的脚本
mysql 修改目录后mysqld启动报错