Centos系统下载大全 | Redhat系统下载大全 | Windows2012系统下载大全 | Windows2008系统下载大全| CMS教程 | 网站地图 51运维网-专注Linux/Unix系统安全运维!
当前位置:51运维网 > 架构 > Tomcat > 正文

Tomcat配置

时间:2015-01-05 23:45 来源:未知 作者:admin 阅读:

1、Tomcat内存参数调整。

1
2
3
4
5
6
7
8
9
10
[root@localhost ~]# vim /usr/local/tomcat/bin/catalina.sh 
JAVA_OPTS="$JAVA_OPTS -server -Xmn1024M -Xms2096M -Xmx2096M \
-Djava.net.preferIPv4Stack=true -Djava.awt.headless=true \
-Dorg.apache.catalina.connector.RECYCLE_FACADES=false -XX:PermSize=512M \
-XX:MaxPermSize=512M  -XX:+UseConcMarkSweepGC -XX:+UseParNewGC \
-XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection \
-XX:CMSFullGCsBeforeCompaction=0 -XX:+CMSClassUnloadingEnabled \
-XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly  \
-XX:SurvivorRatio=65536 -XX:MaxTenuringThreshold=0 -XX:CMSInitiatingOccupancyFraction=81 \
-XX:SoftRefLRUPolicyMSPerMB=0 -Xloggc:gc.log -XX:+PrintGCDetails

2、安装tomcat-native以提升tomcat性能

        apr下载地址:http://apache.org/

1
2
3
4
5
6
7
8
9
10
11
12
[root@localhost~]#tar -zxvf apr-1.5.1.tar.gz
[root@localhost~]#cd apr-1.5.1
[root@localhostapr-1.5.1]#./configure --prefix=/usr/local/apr   #安装apr可移植运行库
[root@localhostapr-1.5.1]# make
[root@localhostapr-1.5.1]# make install
[root@localhost~]# cd /usr/local/tomcat/bin/
[root@localhostbin]# tar xf tomcat-native.tar.gz
[root@localhostbin]# cd tomcat-native-1.1.29-src/jni/native/
[root@localhostnative]# ./configure --with-apr=/usr/local/apr --with-java-home=/usr/local/java
[root@localhostnative]# make && make install
[root@localhost ~]# vim /etc/profile  #声明环境变量
LD_LIBRARY_PATH=/usr/local/apr/lib

 

3、配置多实例Tomcat。

    Tomcat下载地址:http://tomcat.apache.org/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
[root@localhost~]# tar xf apache-tomcat-7.0.47.tar.gz -C /usr/local   #解压tomcat到/usr/local目录
[root@localhost~]# cp -r /usr/local/apache-tomcat-7.0.47/ /usr/local/apache-tomcat-7.0.47-2  #配置Tomcat多实例
[root@localhost~]# mv /usr/local/apache-tomcat-7.0.47/ /usr/local/apache-tomcat-7.0.47-1
[root@localhost~]# ln -sv /usr/local/apache-tomcat-7.0.47-1/ /usr/local/tomcat1  #创建软连接,方便管理
[root@localhost~]# ln -sv /usr/local/apache-tomcat-7.0.47-2/ /usr/local/tomcat2
[root@localhost ~]# vim /etc/profile.d/custom.sh   #声明环境变量
CATALINA_HOME_1=/usr/local/tomcat1
CATALINA_HOME_2=/usr/local/tomcat2
JAVA_HOME=/usr/local/java
LD_LIBRARY_PATH=/usr/local/apr/lib
export CATALINA_HOME_1  CATALINA_HOME_2  JAVA_HOME  LD_LIBRARY_PATH
export PATH=$PATH:$JAVA_HOME/bin
[root@localhost ~]# . /etc/profile.d/custom.sh  #执行自定义变量脚本,使之生效
[root@localhost~]# vim /usr/local/tomcat1/bin/startup.sh #修改tomcat的启动和关闭脚本,分别指定tomcat实例家目录
export CATALINA_HOME=$CATALINA_HOME_1
[root@localhost ~]# vim/usr/local/tomcat1/bin/shutdown.sh
exportCATALINA_HOME=$CATALINA_HOME_1
[root@localhost ~]# vim/usr/local/tomcat2/bin/startup.sh
exportCATALINA_HOME=$CATALINA_HOME_2
[root@localhost ~]# vim /usr/local/tomcat2/bin/shutdown.sh
exportCATALINA_HOME=$CATALINA_HOME_2
[root@localhost ~]# vim /etc/init.d/tomcat1
#!/bin/sh
# Tomcat init script for Linux.
#
# chkconfig: 2345 96 14
# description: The Apache Tomcat servlet/JSP container.
JAVA_HOME=/usr/local/java
CATALINA_HOME=/usr/local/tomcat1
LD_LIBRARY_PATH=/usr/local/apr/lib
export JAVA_HOME CATALINA_HOME LD_LIBRARY_PATH
exec $CATALINA_HOME/bin/catalina.sh $*
[root@localhost ~]# vim /etc/init.d/tomcat2
#!/bin/sh
# Tomcat init script for Linux.
#
# chkconfig: 2345 96 14
# description: The Apache Tomcat servlet/JSP container.
JAVA_HOME=/usr/local/java
CATALINA_HOME=/usr/local/tomcat2
LD_LIBRARY_PATH=/usr/local/apr/lib
export JAVA_HOME CATALINA_HOME LD_LIBRARY_PATH
exec $CATALINA_HOME/bin/catalina.sh $*
[root@localhost~]# vim /usr/local/tomcat2/conf/server.xml   #修改tomcat2默认端口号
              …………
              <Server port="8006"shutdown="SHUTDOWN">  
                     …………
                     <Connectorport="8081" protocol="HTTP/1.1"
                            …………
                            <Connectorport="8010" protocol="AJP/1.3" redirectPort="8443"/>

感谢您对【51运维网 http://www.51ou.com/】的支持,我们为您免费提供《 Tomcat配置》技术文章,《 Tomcat配置》详细使用和说明,有时《 Tomcat配置》可能不完善、敬请谅解!如果《 Tomcat配置》有错误请给我们留言,我们将尽快修复文章错误,如果您觉得本站不错,请分享给周围的朋友!谢谢!

顶一下
(0)
0%
踩一下
(0)
0%
上一篇: centos中如何查看tomcat的版本
下一篇:没有了
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
验证码:点击我更换图片