更新系统组件
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/profileexport 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
时间: 2024-10-10 22:29:02