CAUCHO RESIN4编译安装


关于CAUCHO RESIN
resin是caucho公司的产品,纯JAVA开发,轻量级JAVA Servlet容器,稳定性和并发性比较好

其中pro版本为版本收费版
免费版本resin 3.x 和 resin 4.x,两个版本的配置变化比较大,在resin 3.x中可以使用同一个watchdog管理多个实例,而4.x版本中,每个watchdog只能管理一个实例

CentOS7下部署resin4.x

1. 升级和初始化系统

[root@app100 /root]# yum -y update
[root@app100 /root]# yum -y install gcc gcc-c++ zlib zlib-devel openssl openssl-devel vim-enhanced wget lsof sysstat ntpdate

 

2. 设置主机名, 时区

[root@app100 /root]# echo app100 > /etc/hostname
[root@app100 /root]# timedatectl set-timezone "Asia/Shanghai"
[root@app100 /root]# echo '127.0.0.1   app100' >> /etc/hosts

3 安装java环境
3.1 下载jdk

[root@app100 /root]# wget -c --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.tar.gz

3.2 配置java环境变量

[root@app100 /root]# tar xf jdk-8u121-linux-x64.tar.gz -C /usr/local/
[root@app100 /root]# ln -s /usr/local/jdk1.8.0_121/ /usr/local/jdk1.8

[root@app100 /root]# vim /etc/profile.d/jdk.sh #添加以下内容
export JAVA_HOME=/usr/local/jdk1.8
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export LD_LIBRARY_PATH=$JAVA_HOME/lib

3.3 使环境变量生效并验证

[root@app100 /root]# source /etc/profile
[root@app100 /root]# java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

4 安装Resin
4.1 下载Resin

[root@app100 /root]# wget http://caucho.com/download/resin-4.0.50.tar.gz

4.2 编译安装

[root@app100 /root]# tar xf resin-4.0.50.tar.gz 
[root@app100 /root]# cd resin-4.0.50/
[root@app100 /root/resin-4.0.50]# sed -i '/65521/s/int/long/' modules/c/src/common/stream.c
[root@app100 /root/resin-4.0.50]# sed -i 's/$(plugin_ld_shlib)/${plugin_ld_shlib}/g' configure
[root@app100 /root/resin-4.0.50]# sed -i '12165s/${APACHE_INC}/"${APACHE_INC}"/' configure
[root@app100 /root/resin-4.0.50]# ./configure --prefix=/usr/local/resin --enable-64bit
[root@app100 /root/resin-4.0.50]# make
[root@app100 /root/resin-4.0.50]# make install

[root@app100 /root/resin-4.0.50]# cd /usr/local/resin/
[root@app100 /usr/local/resin]# mkdir resin-data watchdog-data
[root@app100 /usr/local/resin]# chown www.www doc/ endorsed/ log/ webapps/ resin-data/ watchdog-data/ -R

#创建相应目录
[root@app100 /usr/local/resin]# mkdir /usr/local/resin_logs
[root@app100 /usr/local/resin]# mkdir /data/webapps
[root@app100 /usr/local/resin]# chown www.www /usr/local/resin_logs /data/webapps -R

5 配置应用

[root@app100 /usr/local/resin]# mkdir conf/vhost
[root@app100 /usr/local/resin]# vim conf/vhost/daemon_8041.xml
<resin xmlns="http://caucho.com/ns/resin"
       xmlns:resin="urn:java:com.caucho.resin">

  <!--加载系统jar包-->
  <class-loader>
     <tree-loader path="${resin.home}/ext-lib"/>
     <tree-loader path="${resin.root}/ext-lib"/>
     <tree-loader path="${resin.home}/lib"/>
     <tree-loader path="${resin.root}/lib"/>
  </class-loader>
  <!--resin manager配置-->
  <resin:AdminAuthenticator xmlns="http://caucho.com/ns/resin" xmlns:resin="urn:java:com.caucho.resin">
      <user name="admin" password="{SSHA}p+uqTbaAOwZNMAGHi7ajZfNOhsN/kihk"/> <!--password is Resin@123.567& -->
  </resin:AdminAuthenticator>

  <!--jvm日志配置-->
  <log name="" level="info" path="stdout:"
               timestamp="[%Y-%m-%d %H:%M:%S.%s] {%{thread}}"/>
  <logger name="com.caucho" level="info"/>
  <logger name="com.caucho.java" level="config"/>
  <logger name="com.caucho.loader" level="config"/>
  <log name="" level='all' path='/usr/local/resin_logs/daemon/${server.id}_stdout.log'
                           format=" ${log.level} ${log.loggerName} ${log.message}"
                           timestamp="[%Y-%m-%d %H:%M:%S.%s]"
                           rollover-period='1D'
                           rollover-count="7"/>
  <!--经常更新文件的时间间隔,单位为秒, -1不为检查-->
  <dependency-check-interval>-1</dependency-check-interval>
  <cluster id="daemon01">
    <server-default>
      <jvm-arg>-d64</jvm-arg>
      <jvm-arg>-Xmx512m</jvm-arg>  <!--jvm最大内存, 一般配置最大量小值相等, 理论上能够降低GC时间-->
      <jvm-arg>-Xms512m</jvm-arg>  <!--jvm最小内存, 也是启动resin后的默认内存分配值-->
      <jvm-arg>-Xmn128m</jvm-arg>   <!--jvm年轻代配置, 一般配置成最大值的1/4~1/3-->
      <jvm-arg>-Xss256k</jvm-arg>   <!--jvm stack配置, 256k基本够用-->
      <jvm-arg>-Xdebug</jvm-arg>
      <jvm-arg>-verbosegc</jvm-arg>
      <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>

      <jvm-arg>-XX:+PrintGCTimeStamps</jvm-arg>
      <jvm-arg>-XX:+PrintGCDateStamps</jvm-arg>
      <jvm-arg>-XX:+PrintGCDetails</jvm-arg>
      <jvm-arg>-Xloggc:${resin.home}/log/gc-${server.id}.log</jvm-arg>
      <jvm-arg>-XX:+HeapDumpOnOutOfMemoryError</jvm-arg>
      <jvm-arg>-XX:HeapDumpPath=${resin.home}/log/oom-${server.id}.log</jvm-arg>

      <memory-free-min>1M</memory-free-min> <!--强制resin强制重启时的最小空闲内存-->

      <!--网络超时时间-->
      <socket-timeout>5s</socket-timeout>
      <keepalive-max>1024</keepalive-max>
      <keepalive-timeout>5s</keepalive-timeout>

      <!--线程池-->
      <thread-max>2048</thread-max>
      <thread-idle-min>10</thread-idle-min>
      <thread-idle-max>20</thread-idle-max>
      <port-default>
        <port-thread-max>4096</port-thread-max>
        <accept-thread-max>4096</accept-thread-max>
        <accept-thread-min>200</accept-thread-min>
      </port-default>

      <!--实例运行使用的系统用户-->
      <user-name>www</user-name>
      <group-name>www</group-name>

      <!--watchdog配置-->
      <watchdog-jvm-arg>-Dcom.sun.management.jmxremote</watchdog-jvm-arg>
      <watchdog-port>16041</watchdog-port>

      <!--jmx监控配置-->
      <jvm-arg>-Dcom.sun.management.jmxremote.port=19041</jvm-arg>   
      <jvm-arg>-Dcom.sun.management.jmxremote.host=172.16.123.100</jvm-arg>   
      <jvm-arg>-Djava.rmi.server.hostname=172.16.123.100</jvm-arg>   
      <jvm-arg>-Dcom.sun.management.jmxremote.ssl=false</jvm-arg>   
      <jvm-arg>-Dcom.sun.management.jmxremote.authenticate=true</jvm-arg>   
      <jvm-arg>-Dcom.sun.management.jmxremote.access.file=${resin.home}/conf/jmxremote.access</jvm-arg>
      <jvm-arg>-Dcom.sun.management.jmxremote.password.file=${resin.home}/conf/jmxremote.password</jvm-arg>
    </server-default>
    <resin:import path="${resin.home}/conf/app-default.xml"/>
    <server id="daemon01" address="172.16.123.100" port="17041">
        <http id=""   address="172.16.123.100" port="18041"/>
    </server>
    <server-header>eas</server-header>
    <host-default>
      <!--访问日志, rollover-period为轮询时间-->
      <access-log path="/usr/local/resin_logs/daemon/${server.id}_access.log"
                  format='"%{X-Real-IP}i" %h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'
                  rollover-period="1D"
                  rollover-count="7"/>
      <web-app-deploy path="webapps"/>
    </host-default>
    <host id="" root-directory=".">
      <!--设置默认字符集-->
      <character-encoding>UTF-8</character-encoding>
      <!--虚拟主机目录-->
      <web-app id="/" root-directory="/data/webapps/daemon"/>
      <web-app id="/resin-admin" root-directory="${resin.root}/doc/admin">
        <prologue>
          <resin:set var="resin_admin_external" value="true"/>
          <resin:set var="resin_admin_insecure" value="true"/>
        </prologue>
      </web-app>
    </host>
  </cluster>
</resin>

6 配置JMX

[root@app100 /usr/local/resin]# cp $JAVA_HOME/jre/lib/management/jmxremote.access conf/jmxremote.access
[root@app100 /usr/local/resin]# cp $JAVA_HOME/jre/lib/management/jmxremote.password.template conf/jmxremote.password
[root@app100 /usr/local/resin]# vim conf/jmxremote.password
monitorRole  QED&
controlRole   R&D&
[root@app100 /usr/local/resin]# chmod 600 conf/jmxremote.password
[root@app100 /usr/local/resin]# chown www.www conf/jmxremote.password

7 启动resin

[root@app100 /usr/local/resin]# su - www
[www@app100 /home/www]$ /usr/local/resin/bin/resinctl -conf /usr/local/resin/conf/vhost/daemo_8041.xml start

8 解决乱码问题

[root@app100 /usr/local/resin/bin]# cp resinctl resinctl8
[root@app100 /usr/local/resin/bin]# vim resinctl8
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
export JAVA_HOME=/usr/local/jdk1.8
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export LD_LIBRARY_PATH=.:$JAVA_HOME/jdk/lib

9 端口使用规范建议
Resin使用三个端口, 分别为watchdog端口/server口/http口, 使用表格统一规范不同应用的使用端口

-----------------------------------------------
|应用名称  |  watchdog | server | http |  备注   |
-----------------------------------------------
|  app   |   6041    |  7041  | 8041 | app应用 |
-----------------------------------------------
|  web   |   6042    |  7042  | 8042 | web接口 |
-----------------------------------------------

10 Resin4多实例

Resin4多实例与Resin3多实例配置还是有差别的,Resin3中只需在cluster里面配置两个server即可, 而Resin4一个cluster只能配置一个server,所以Resin4配置多实例里,建议分开不同的配置文件,例如app01.xml和app02.xml,然后把配置文件中的id值改写文件名的前缀,以及端口按加100,这样就可以在一台机器跑两个实例了;

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇