码迷,mamicode.com
首页 > 其他好文 > 详细

开启tomcat的apr模式,并利用redis做tomcat7的session的共享。

时间:2017-09-11 19:54:45      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:nas   rms   ogg   client   cli   redis数据库   e2fs   libstdc++   libc   

更新系统组件

yum -y install  readline*  xmlto kernel-devel yum* screen vim* psmisc wget lrzsz pcre-devel libtidy libtidy-devel iptraf sysstat libevent libevent-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker tar rrdtool ntp* dos2unix setup* net-snmp-utils net-snmp-devel ruby ruby-devel php-snmp cmake net-snmp-perl net-snmp net-snmp-libs wget elinks make autoconf213 m4 gcc gcc-c++ automake autoconf fontconfig fontconfig-devel libjpeg libjpeg* libjpeg-devel libpng libpng-devel freetype freetype* freetype-devel libxml2 libxml2-devel libdhash libdhash-devel  libxslt* zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2* libc-client libc-client-devel libicu-devel ncurses ncurses-devel xmlrpc-c xmlrpc-c-devel curl curl-devel e2fsprogs e2fsprogs-devel  krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel openldap-clients openldap-servers gd gd-devel pam* gettext gettext-devel  keyutils  compat* mpfr cpp libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libXpm*  php-gd ncurses* libtool*  patch unzip bison-devel bison libcom_err-devel libsepol-devel gtk* libselinux-devel libtiff libtiff*  php-common policycoreutils telnet t1lib t1lib* nasm nasm*

修改java_home

vim /etc/profile
export JAVA_HOME=/data/java export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar export JAVA_HOME JAVA_BIN PATH CLASSPATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib export LD_LIBRARY_PATH

安装openssl

yum install -y zlib
tar zxf openssl-1.0.2h.tar.gz
cd openssl-1.0.2h
./config shared zlib
make
make install

安装apr-iconv

tar -xvf apr-iconv-1.2.1.tar.gz
cd apr-iconv-1.2.1
./configure --prefix=/usr/local/apr-iconv --with-apr=/usr/local/apr
make
make install

安装apr-util

tar zxvf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util  --with-apr=/usr/local/apr  
make
make install
cd /root

增加tomcat项目

tar zxvf apache-tomcat-7.0.61.tar.gz
mv apache-tomcat-7.0.61 你项目的路径和名字

cd /你项目的路径和名字/bin

tar zxvf tomcat-native.tar.gz
cd tomcat-native-1.1.33-src/jni/native/
./configure --with-apr=/usr/local/apr
make
make install

参考定义java回收

vim 你项目的路径和名字/bin/catalina.sh 
JAVA_OPTS="-server -Xms2048m -Xmx2048m -XX:PermSize=256M -XX:MaxPermSize=512m  -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC  -XX:MaxGCPauseMillis=50 -XX:GCPauseIntervalMillis=200"

参考定义不用端口直接访问tomcat

在<Host name="localhost"  appBase="webapps"
unpackWARs="true" autoDeploy="true">下面增加
<Context path=""  docBase="你项目的路径和名字" />

1.配置Tomcat的conf目录下的context.xml文件:

1> 单点Reids配置

vim context.xml
<Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" /> <Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager" host="IP" port="端口" database="用的你个redis数据库,默认16个,自己指定" maxInactiveInterval="60"/>

2> Sentinel集群配置:

<!-- Sentinel 配置 -->
<Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" /> 
<Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager" 
maxInactiveInterval="60"
sentinelMaster="mymaster"
sentinels="127.0.0.1:26379,127.0.0.1:26380,127.0.0.1:26381,127.0.0.1:26382"
/>

复制commons-logging-1.2.jar commons-pool2-2.4.1.jar jedis-2.5.2.jar tomcat-redis-session-manage-tomcat7.jar到你tomcat的lib目录下

启动tomcat,看日志提示 Will expire sessions after 1800 seconds

开启tomcat的apr模式,并利用redis做tomcat7的session的共享。

标签:nas   rms   ogg   client   cli   redis数据库   e2fs   libstdc++   libc   

原文地址:http://www.cnblogs.com/love19791125/p/7506224.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!