[开发]Resin 4.0.15重启时常见问题

郑昀 201102

现象:

下面是偶然出现的Resin错误日志,郑昀的结论是不必过于担心下面这个错误,但最好能修改配置:

[2011/02/24 22:11:20.593] {} HmtpServlet[WebApp[production/webapp/admin.resin/ROOT]] requires an active com.caucho.security.Authenticator because HMTP messaging requires authenticated login for security.  In the resin.xml, add an <sec:AdminAuthenticator>

[2011/02/24 22:12:29.198] {main} Unable to find native library 'resin_os' for com.caucho.bootjni.JniProcess. Resin expects to find this library in:

(Unix) /application/webserver/resin-4.0.15/libexec64/libresin_os.so

                                 On Unix, run ./configure; make; make install.

                                 The JVM exception was: java.lang.UnsatisfiedLinkError: no resin_os in java.library.path

 

背景描述:

如果重启了resin,不管是人为的还是自动的,那么resin的引导程序就用上“com.caucho.bootjni”这个包,它是resin的引导类(bootstrap package)。

但由于resin版本升级到4.0之后,重启时,如果会根据自身resin.xml的如下配置:

<server-default>

<resin:if  test ="${resin.userName == 'root'}" >
<user-name>www-data</user-name>
<group-name>www-data</group-name>
</resin:if>

</server-default>

做判断,如果当前启动Resin的用户是root,那么就会使用user-name节点中指定的www-data用户身份启动Resin(也因此有些工程师自己测试时启动不了Resin,就是因为www-data用户不存在)。

 

线上情景:

当然,郑昀说我们线上的resin.xml配置文件中已经把这段话注释了:

<server-default>

<!--

- If starting Resin as root on Unix, specify the user name

- and group name for the web server user.

<user-name>www-data</user-name>

<group-name>www-data</group-name>

-->

</server-default>

所以,如果不是root帐号登录操作resin重启,比如假设是用一个webmaster帐号(没有root privileges权限)操作,那么

Resin启动时必须绑定80端口,而Unix仅仅允许root帐号绑定1024以下的端口号(所以8080端口就不存在此问题),

此时它会采用root身份,一旦绑定所有端口,就立刻丢弃root特权(privileges),

那么Resin接下来可能因为身份的问题无法加载libresin_os.so,

于是很有可能因此就报告了郑昀上面贴的错误:“Unable to find native library 'resin_os' for com.caucho.bootjni.JniProcess.”。

 

郑昀的建议:

1、 可以忽略此类错误。

2、 打开resin.xml里的开关,改用户名为resin,然后增加这么一个用户useradd resin:

<!--
      - If starting Resin as root on Unix, specify the user name
      - and group name for the web server user.
      -->
<resin:if test="${resin.userName == 'root'}">
<user-name>resin</user-name>
<group-name>resin</group-name>
</resin:if>

3、或者直接复制一个libresin_os.so文件到 /usr/lib64/ 下,大家都能加载这个so。

 

参考资料:

1、

官方文档《Migrating from Resin 3.0 to Resin 4.0》:

Unix allows only root to bind to ports below 1024. If you use Resin as your webserver (recommended) and bind to port 80, you'll need to start Resin as root. In Resin 4.0, the Resin process can drop privileges as soon as it's bound to all its ports. You can configure the user that Resin uses in the <server> or <server-default> sections:

<server-default>

...

<resin:if test="${resin.userName == 'root'}">

<user-name>www-data</user-name>

<group-name>www-data</group-name>

</resin:if>

2、

Resin 4.0.14曾经有一个bug,就是你虽然设置了user-name字段,但是resin仍然在root身份下运行,而不是你写的用户名

但在我们线上这个版本resin 4.0.15已经修复了这个BUG

01-25-11 16:03 ferg Fixed in Version  => 4.0.15

 

我的相关文章:

1、[开发]Resin 4.0.15配置优化的一个建议

posted @ 2011-02-25 14:53  旁观者  阅读(11460)  评论(1编辑  收藏  举报