Apache与tomcat的整合及负载均衡(doc8页).docx

上传人:scccc 文档编号:12430972 上传时间:2021-12-03 格式:DOCX 页数:6 大小:35.21KB
返回 下载 相关 举报
Apache与tomcat的整合及负载均衡(doc8页).docx_第1页
第1页 / 共6页
Apache与tomcat的整合及负载均衡(doc8页).docx_第2页
第2页 / 共6页
Apache与tomcat的整合及负载均衡(doc8页).docx_第3页
第3页 / 共6页
Apache与tomcat的整合及负载均衡(doc8页).docx_第4页
第4页 / 共6页
Apache与tomcat的整合及负载均衡(doc8页).docx_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《Apache与tomcat的整合及负载均衡(doc8页).docx》由会员分享,可在线阅读,更多相关《Apache与tomcat的整合及负载均衡(doc8页).docx(6页珍藏版)》请在三一文库上搜索。

1、Apache 与 tomcat 的整合及负载均衡系统环境: Windows Server 2008 R2 SP1虚拟机软件: Hyper-V 管理器 6.1.7601.17514虚拟机环境: Red Hat Enterprise Linux Server release 5.4 (Tikanga) X64安装软件版本: JDK:1.6.0_19 Tomcat:6.0.20 Apache:2.2.19 JK: 1.2.10 实施步骤:一、安装软件。 。 。1 tar -xzvf jdk1.6.0_19.tar.gz2 tar xvfz tomcat.tar.gz3 tar zxvf httpd-

2、2.2.19.tar.gz4 cd httpd-2.2.195 ./configure -prefix=/usr/local/apache2 -enable-so -enable-mods-shared=most-with-mpm=worker6 make7 make install8 tar zxvf jakarta-tomcat-connectors-1.2.10-src.tar.gz9 cd jakarta-tomcat-connectors-1.2.10-src/jk/native/10 ./buildconf.sh11 ./configure -with-apxs=/usr/loca

3、l/apache2 /bin/apxs12 make13 make install二、配置整合及负载均衡1 cp /usr/local/jakarta-tomcat-connectors-1.2.10-src/jk/native/apache-2.0/mod_jk.so /usr/local/apache2 /modules2 配置环境变量vi /etc/profile在文本末尾加入以下内容JAVA_HOME=JD故装路径CATALINA_HOME=tomcat 安装路径CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$CA

4、TALINA_HOME/lib/servlet-api.jarPATH=$JAVA_HOME/bin:$PATHexport JAVA_HOME CATALINA_HOME CLASSPATH PATH3 应用初始的环境变量source /etc/profile4 修改 apache 的 httpd.confvi /usr/local/apache2 /conf/httpd.conf修改以下几处IP addresses as 国hown below t all bound IP addresses,填上你安装处配匕的地址# Change this to Listen on specific#

5、prevent Apache from glomning onto#Listen 34. 56,78:80Listen 110. L 1. 2:80 一# Docunent Root: The direct ory out of which you will serve your# documentBy default, all requests are taken front this directory, but# symbolic links and aliases may be used to point to other locations.#D ocujuent Root '

6、;g " 1 口 c al/1 me at / web 即 p 艺/ROO T"> 前矍点 fS 野认 1 °m c 3七网页H# Each directory to which Apache has access can be configured with respect# to which services and features are allowed and/or disabled in that# directory (and its subdirectories).# Firsts we configure the "dsfsuit

7、to be a very restrictive set of# features.#<Directory />Options FollowSymLinksAllowOverride llone# Deny from all6工1七5" 一4推荐将加叩from。:L前加上#</Direct ory># Directorylndex: sets the file that Apache will serve if a directory # is request ed.#添加这个网页类型# IfModule dir_nodule>Directorylnde

8、z indeK.html</IfIodule>并且在末尾力口上:Include /usr/local/apache2 /conf/mod_jk.conf5 添加及设置mod_jk.confvi /usr/local/apache2 /mod_jk.conf增加以下内容#力口载 mod_jk ModuleLoadModule jk_module modules/mod_jk.so#指定 workers.properties 文件路径JkWorkersFile conf/workers.propertiesJkLogFile logs/mod_jk.logJkLogLevel info

9、#指定那些请求交给tomcat 处理 ,"controller" 为在 workers.propertise 里指定的负载分配控制制器JkMount /* lb6 添加及设置workers.propertiesvi /usr/local/apache2 /conf/workers.properties添加以下内容worker.list = lb,tomcat1,tomcat2#server 列表#=tomcat1=worker.tomcat1.port=8009#ajp13 端口号,在 tomcat 下 server.xml 配置 ,默认 8009worker.tomcat

10、1.host=10.1.1.2#tomcat 的主机地址,如不为本机,请填写 ip 地址worker.tomcat1.type=ajp13worker.tomcat1.lbfactor = 1#server 的加权比重,值越高,分得的请求越多#=tomcat2=worker.tomcat2.port=8009#ajp13 端口号,在tomcat 下 server.xml 配置 ,默认8009worker.tomcat2.host=10.1.1.3#tomcat 的主机地址,如不为本机,请填写 ip 地址worker.tomcat2.type=ajp13worker.tomcat2.lbfact

11、or = 1#server 的加权比重,值越高,分得的请求越多#=controller, 负载均衡控制器 =worker.lb.type=lbworker.lb.balanced_workers=tomcat1,tomcat2#指定分担请求的tomcatworker.lb.sticky_session=17、将 JS以件放入 /usr/local/tomcat/webapps/ROOT8 启动 apache 和 tomcat8 打开浏览器输入就是这么简单。三、将 apache 和 tomcat 加入启动和系统服务选项1 Apache 加入启动项里面:echo '/usr/local/a

12、pache2 /bin/apachectl start ' >> /etc/rc.local2 Apache 加入到系统服务里面:cp /安装目录下/apache/bin/apachectl /etc/rc.d/init.d/httpd修改 httpd在文件头部加入如下内容:# Comments to support chkconfig on RedHat Linux# chkconfig: 2345 90 90# description:http server#保存在打入chkconfig -add httpdchkconfig -level 345 httpd on3

13、tomcat 加入启动和系统服务选项安装 jsvc#cd /usr/local/tomcat/bin#tar xvfz jsvc.tar.gz#cd jsvc-src#sh support/buildconf.sh#chmod 755 configure#./configure -w让h-java=/usr/local/java(改成你的 JDK的位置)#make注:我在 轨彳亍./configure -with-java=/usr/local/java 的谩程中, 11生"configure: error:no acceptable C compiler found in $PAT

14、H "的提示,是没有安装 C编群器,于是轨行 “yum install gcc” 安装了 gcc,之后重新轨行 ./configure -with-java=/usr/local/java 就 Ok 了修改启动文件# vi ./native/Tomcat5.sh改成如下内容 :#!/bin/sh# chkconfig: 345 87 13# description: Tomcat Daemon# processname: jsvc# pidfile: /var/run/jsvc.pid# config:# Source function library.# . /etc/rc.d/i

15、nit.d/functions# prog=tomcat# Small shell script to show how to start/stop Tomcat using jsvc# If you want to have Tomcat running on port 80 please modify the server.xml# file:# port="80" minProcessors="5" maxProcessors="75"# enableLookups="true" redirectPort=&

16、quot;8443"# acceptCount="10" debug="0" connectionTimeout="60000"/># You need a developement version of Tomcat (Apache Tomcat/ 4.1-dev)# Adapt the following lines to your configuration ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff

17、ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff k“kkkTrkkkTrkkkTrkkFTrkkFTrkk“Jhk" “ rrk“ “ kk" " "a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a

18、a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a# # Copyright 2004 The Apache Software Foundation.# Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at#

19、 http:/www.apache.org/licenses/LICENSE-2.0# Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific lan

20、guage governing permissions and# limitations under the License.ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff k“kkkTrkkkTr

21、kkkTrkkFTrkkFTrkk“Jhk" “ rrk“ “ kk" " "a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a# Small shell script to show how to start/stop Tomcat using jsvc# If you want to have Tomcat

22、 running on port 80 please modify the server.xml# file:# <!- Define a non-SSL HTTP/1.1 Connector on port 80 -># <Connector className="org.apache.catalina.connector.http.HttpConnector"# port="80" minProcessors="5" maxProcessors="75"# enableLookups=&quo

23、t;true" redirectPort="8443"# acceptCount="10" debug="0" connectionTimeout="60000"/># That is for Tomcat-5.0.x (Apache Tomcat/5.0)# Adapt the following lines to your configurationJAVA_HOME=/usr/local/jdkCATALINA_HOME=/usr/local/tomcatDAEMON_HOME=/usr/lo

24、cal/tomcat/binTOMCAT_USER=root# for multi instances adapt those lines.TMP_DIR=/var/tmpPID_FILE=/var/run/jsvc.pidCATALINA_BASE=/usr/local/tomcatCATALINA_OPTS=CLASSPATH=$JAVA_HOME/lib/tools.jar:$CATALINA_HOME/bin/commons-daemon.jar:$CATALINA_HOME/bin/bootstrap.jarcase "$1" instart)# Start To

25、mcat#$DAEMON_HOME/jsvc-src/jsvc -user $TOMCAT_USER -home $JAVA_HOME -Dcatalina.home=$CATALINA_HOME -Dcatalina.base=$CATALINA_BASE -Djava.io.tmpdir=$TMP_DIR -wait 10 -pidfile $PID_FILE -outfile $CATALINA_HOME/logs/catalina.out -errfile '&1' $CATALINA_OPTS -cp $CLASSPATH org.apache.catalin

26、a.startup.Bootstrap# To get a verbose JVM#-verbose # To get a debug of jsvc.#-debug exit $?;stop)# Stop Tomcat#$DAEMON_HOME/jsvc-src/jsvc -stop -pidfile $PID_FILE org.apache.catalina.startup.Bootstrap exit $?;*)echo "Usage tomcat.sh start/stop"exit 1;esac拷贝启动文件#cp ./native/Tomcat5.sh /etc/

27、init.d/tomcat5#chmod -c 777 /etc/init.d/tomcat5添加服务#chkconfig -add tomcat5#chkconfig -level 345 tomcat5 on完成 ,启动服务#service tomcat5 start这时重启系统,tomcat 也就会自动启动了读一本好书,就是和许多高尚的人谈话读书时,我愿在每一个美好思想的面前停留,就像在每一条真理面前停留一样。书籍是在时代的波涛中航行的思想之船,它小心翼翼地把珍贵的货物运 送给一代又一代。好的书籍是最贵重的珍宝是唯一不死的东西。书籍使人们成为宇宙的主人。书中横卧着整个过去的灵书不仅是生活

28、,而且是现在、过去和未来文化生活的源泉。书籍把我们引入最美好的社会,使我们认识各个时代的伟大智者。书籍便是这种改造灵魂的工具。人类所需要的,是富有启发性的养料。而阅读,则正是这种养料。8、不敢妄为些子事,只因曾读数行书。陶宗义我并没有什么方法,只是对于一件事情很长时间很热心地去考虑罢了。只要愿意学习,就一定能够学会一个爱书的人,他必定不致缺少一个忠实的朋友一个良好的导师一个可爱的伴侣一个优婉的安慰者。读书当将破万卷;求知不叫一疑存。读书如吃饭,善吃者长精神,不善吃者长疾瘤。读书不趁早,后来徒悔懊。 读书是易事,思索是难事,但两者缺一,便全无用处。 读书何所求?将以通事理。伟大的成绩和辛勤劳动是成正比例的,有一分劳动就有一分收获,日积月累,从少到多,奇迹就可以创造出来。敏而好学,不耻下问。不学,则不明古道,而能政治太平者未之有也。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1