1
2
3
4
5
6
7
8
|
[root@lw-01 opt] # tar zxvf tomcat-connectors-1.2.40-src.tar.gz
进入tomcat-connectors的native目录: [root@lw-01 opt] # cd tomcat-connectors-1.2.40-src/native/
进行编译参数设置: [root@lw-01 native] # ./buildconf.sh
[root@lw-01 native] # ./configure --with-apxs=/usr/local/apache2/bin/apxs\ --with-java-home=$JAVA_HOME --with-java-platform=2\ --enable-jni
[root@lw-01 native] # make && make install
|
1
2
|
[root@lw-02 opt] # ls
apache-tomcat-8.0.14-1 apache-tomcat-8.0.14-2 |
1
2
3
4
5
6
|
[root@lw-02 conf] # pwd
/opt/apache-tomcat-8 .0.14-2 /conf
[root@lw-02 conf] # cat server.xml | grep port | grep -v "\!"
<Server port= "8007" shutdown = "SHUTDOWN" > // 默认是8006改为8007
<Connector port= "8081" protocol= "HTTP/1.1" // 默认是8080改为8081
<Connector port= "8010" protocol= "AJP/1.3" redirectPort= "8443" /> // 默认是8009改为8010
|
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
|
<Cluster className= "org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions= "8" >
<Manager className= "org.apache.catalina.ha.session.DeltaManager" expireSessionsOnShutdown= "false" notifyListenersOnReplication= "true" />
<Channel className= "org.apache.catalina.tribes.group.GroupChannel" >
<Membership className= "org.apache.catalina.tribes.membership.McastService" address= "228.0.0.4" port= "45564" frequency= "500" dropTime= "3000" />
<Receiver className= "org.apache.catalina.tribes.transport.nio.NioReceiver" address= "auto" port= "4000" autoBind= "100" selectorTimeout= "5000" maxThreads= "6" />
<Sender className= "org.apache.catalina.tribes.transport.ReplicationTransmitter" >
<Transport className= "org.apache.catalina.tribes.transport.nio.PooledParallelSender" />
< /Sender >
<Interceptor className= "org.apache.catalina.tribes.group.interceptors.TcpFailureDetector" />
<Interceptor className= "org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor" />
< /Channel >
<Valve className= "org.apache.catalina.ha.tcp.ReplicationValve" filter= "" />
<Valve className= "org.apache.catalina.ha.session.JvmRouteBinderValve" />
<Deployer className= "org.apache.catalina.ha.deploy.FarmWarDeployer" tempDir= "/tmp/war-temp/" deployDir= "/tmp/war-deploy/" watchDir= "/tmp/war-listen/" watchEnabled= "false" />
<ClusterListener className= "org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener" />
<ClusterListener className= "org.apache.catalina.ha.session.ClusterSessionListener" />
< /Cluster >
|
1
2
3
4
5
6
7
8
9
10
11
|
# Load mod_jk module LoadModule jk_module modules /mod_jk .so
# Specify jk log file. JkLogFile /var/log/mod_jk .log
# Specify jk log level [debug/error/info] JkLogLevel info # Specify workers.properties, this file tell jk: # how many nodes and where they are. JkWorkersFile conf /workers .properties
# Specify which requests should handled by which node. JkMount /* controller |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
[root@lw-01 conf] # pwd
/usr/local/appache/conf [root@lw-01 conf] # cat workers.properties
#所有节点列表,其中controller是一个逻辑结点,负责负载均衡控制, #如果JkMount中的URL指定给了controller就表示这个请求会被自动散列到某个物理节点上。 #注意:真正负责处理请求的tomcat的名称(这里就是tomcat1,tomcat2)必须于它们在conf/server.xml文件中配置的jvmRoute的属性值是一致的! worker.list = controller #========tomcat1======== worker.tomcat1.port=8009 #ajp13 端口号,在tomcat下server.xml配置,默认8009
worker.tomcat1.host=192.168.1.111 #tomcat的主机地址,如不为本机,请填写ip地
worker.tomcat1. type =ajp13
worker.tomcat1.lbfactor = 1 #server的加权比重,值越高,分得的请求越多
#========tomcat2======== worker.tomcat2.port=8010 #ajp13 端口号,在tomcat下server.xml配置,默认8009
worker.tomcat2.host=192.168.1.111 #tomcat的主机地址,如不为本机,请填写ip地址worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor = 1 #server的加权比重,值越高,分得的请求越多
#========controller,负载均衡控制器======== worker.controller. type =lb
worker.controller.balance_workers=tomcat1,tomcat2 #指定分担请求的tomcat,旧版本中的balanced_workers,已不再推荐使用!
worker.controller.sticky_session=1 #sticky_session为1表示当某一 client的session创建之后,后续由该客户端发起的请求,也就是这个session的所有请求都始终由第一次处理该请求的结点负责处理(除非该结点挂掉)
|
1
2
3
4
5
6
7
8
9
|
[root@lw-02 test ] # pwd
/opt/apache-tomcat-8 .0.14-2 /webapps/test
[root@lw-02 test ] # tree
. ├── index.jsp └── WEB-INF └── web.xml
1 directory, 2 files |
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
|
[root@lw-02 test ] # cat index.jsp
<%@ page contentType= "text/html; charset=UTF-8" %>
<%@ page import = "java.util.*" %>
<html>< head ><title>Cluster App Test< /title >< /head >
<body> <% System.out.println( "SessionID:" + session.getId());
%> Server Info: <% out.println(request.getLocalAddr() + " : " + request.getLocalPort()+ "<br>" );%>
<% out.println( "<br> ID " + session.getId()+ "<br>" ); // 如果有新的 Session 属性设置
String dataName = request.getParameter( "dataName" );
if (dataName != null && dataName.length() > 0) {
String dataValue = request.getParameter( "dataValue" );
session.setAttribute(dataName, dataValue);
}
out.println( "<b>Session 列表</b><br>" );
System.out.println( "============================" );
Enumeration e = session.getAttributeNames();
while (e.hasMoreElements()) {
String name = (String)e.nextElement();
String value = session.getAttribute(name).toString();
out.println( name + " = " + value+ "<br>" );
System.out.println( name + " = " + value);
}
%> <form action= "index.jsp" method= "POST" >
名称:<input type =text size=20 name= "dataName" >
<br>
数值:<input type =text size=20 name= "dataValue" >
<br>
<input type =submit>
< /form >
< /body >
|
1
2
3
4
5
6
7
8
|
[root@lw-02 test ] # cat WEB-INF/web.xml
<web-app xmlns= "http://java.sun.com/xml/ns/j2ee"
xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation= "http://java.sun.com/xml/ns/j2ee [url]http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd[/url]"
version= "2.4" >
<display-name>TomcatDemo< /display-name >
<distributable/>
< /web-app >
|
欢迎大家访问我的个人网站 萌萌的IT人
相关推荐
NULL 博文链接:https://tim-fly.iteye.com/blog/1901239
linux下apache+tomcat实现集群,压缩包里包括两篇文档(操作步骤和详解),3个压缩包(安装文件)
linux rhel6.1 apache_tomcat 集群,里面提供文档和资源包。
详细介绍如何在Linux系统下实现Apache+Tomcat集群,以及工作原理的介绍。此方案是我自己测试过的,希望能对你有帮助。
LINUX下使用apache+tomcat构建WEB集群系统
linux 下实现apache+tomcat集群及session复制
本文为您讲述了如何在 Windows 或 Linux 下进行 Tomcat 集群的安装配置。 Windows 下 Tomcat 集群的安装配置与 Linux 下稍有区别,道长为了在一篇教程中讲解两 种操作系统的配置,因此使用两台机器进行安装工作,一...
linux下tomcat apache集群配置说明.doc
经测试本文详细描述了Linux下搭建tomcat集群全记录
Apache 的 Tomcat 负载均衡和集群 ( linux, centos) jkmod
linux下apache、tomcat及JDK安装过程图解 tomcat集群
本说明手册为了阐述Linux搭建Apache+Tomcat环境,并详细介绍Tomcat的集群和负载均衡配置而编写。届时介绍域名的绑定,Red Hat和Ubuntu中随系统自动启动个软件的配置方法。
1), VM虚拟机: VMware-workstation-full-10.0 (2),linux系统ubuntu-12.04.3-server-amd64 ...(6),tomcat: apache-tomcat-7.0.47 (7),mysql: 5.5.34-0ubuntu0.12.04.1 (8),测试工具:apache-jmeter-2.9
Apache+Tomcat+Linux集群和负载均衡
Apache+Tomcat+Linux集群和均衡负载(Session同步复制
该资源为博客:http://blog.csdn.net/cy104204/article/details/14229275 附件资料,参考研究,共同进步。
apache + tomcat + mod_jk集群。我分别在windwos、linux32位、linux64位系统下都成功搭建。
讲述了怎样在liunx系统下配置tomcat集群,apache负载均衡,session黏贴,关于缓存,压缩可以在此基础上扩展
Linux平台Apache高可用双机集群Tomcat负载均衡集群配置手册[定义].pdf
Linux(64位)下 apache-2.2.22与tomcat6.0.37 纵向集群配置文件