添加到自启动并设置mysql密码
服务器:
l 192.168.14.30(Apache负载)
l 10.0.30.67(Tomcat服务器)
l 10.0.30.151(Tomcat服务器)
软件环境:
l CentOS-5.5-x86_64
l Apache 2.2.3(CentOS安装时自带)
l jdk-6u26-linux-x64-rpm.bin
l apache-tomcat-6.0.32.tar.gz
1、首先配置Tomcat服务器
安装JDK,并配置Java路径:
[root@cloud download]# vim /etc/profile
JAVA_HOME=/usr/java/jdk1.6.0_26
PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$CATALINA_HOME/common/lib
export JAVA_HOME
export PATH
export CLASSPATH
[root@cloud download]# source /etc/profile
[root@cloud download]# ./ jdk-6u26-linux-x64-rpm.bin
[root@cloud download]# java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
安装Tomcat
[root@cloud download]# tar zxvf apache-tomcat-6.0.32.tar.gz
cp -r apache-tomcat-6.0.32 /usr/tomcat6
修改server.xml配置文件
去掉注释,,这是路由使用的,在apache中会用到jvmRoute的值
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">另外一台命名为jvm2
<!--<Engine name="Catalina" defaultHost="localhost">-->
把<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>改成:
<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>
上面配置说明:
Using the above configuration will enable all-to-all session replication using the DeltaManager to replicate session deltas. By all-to-all we mean that the session gets replicated to all the other nodes in the cluster. This works great for smaller cluster but we don't recommend it for larger clusters(a lot of tomcat nodes). Also when using the delta manager it will replicate to all nodes, even nodes that don't have the application deployed.
To get around this problem, you'll want to use the BackupManager. This manager only replicates the session data to one backup node, and only to nodes that have the application deployed. Downside of the BackupManager: not quite as battle tested as the delta manager.
Here are some of the important default values:
1. Multicast address is 228.0.0.4
2. Multicast port is 45564 (the port and the address together determine cluster membership.
3. The IP broadcasted is java.net.InetAddress.getLocalHost().getHostAddress() (make sure you don't broadcast 127.0.0.1, this is a common error)
4. The TCP port listening for replication messages is the first available server socket in range 4000-4100
5. Two listeners are configured ClusterSessionListener and JvmRouteSessionIDBinderListener
6. Two interceptors are configured TcpFailureDetector and MessageDispatch15Interceptor
The following is the default cluster configuration:
To run session replication in your Tomcat 6.0 container, the following steps should be completed:
l All your session attributes must implement java.io.Serializable
l Uncomment the Cluster element in server.xml
l If you have defined custom cluster valves, make sure you have the ReplicationValve defined as well under the Cluster element in server.xml
l If your Tomcat instances are running on the same machine, make sure the tcpListenPort attribute is unique for each instance, in most cases Tomcat is smart enough to resolve this on it's own by autodetecting available ports in the range 4000-4100
l Make sure your web.xml has the <distributable/> element
l If you are using mod_jk, make sure that jvmRoute attribute is set at your Engine <Engine name="Catalina" jvmRoute="node01" > and that the jvmRoute attribute value matches your worker name in workers.properties
l Make sure that all nodes have the same time and sync with NTP service!
l Make sure that your loadbalancer is configured for sticky session mode.
配置web.xml,增加<distributable/>元素,表示此应用将与群集服务器复制Session
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" 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 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>cncloud_gr</display-name>
<distributable/>
配置webapp访问路径:
<Context path="" docBase="cncloud" debug="0" />
配置webapp端口:
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8"
useBodyEncodingForURI="true" />
把web项目打成war包放在Tomcat/webapps目录下
启动Tomcat,检查各个服务器是否能够正常访问:
./ startup.sh
2、安装Apache服务器
可以使用以下三种方式:
l 命令:yum install httpd httpd-devel mod_ssl
l 编译Apache源码,如果使用源代码安装,一般默认安装在/usr/local/apache2目录下
l 图形界面操作:
测试Apache是否安装成功:http://192.168.14.30/
默认apache配置文件:/etc/httpd/conf/httpd.conf
模块路径:/usr/sbin/apachectl
web目录:/var/www/html
启动apache:service httpd start
出现上面提示是因为没有配置好主机名
[root@cloud download]# vim /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.14.30 cloud_test.com cloud_test
修改apache配置文件
vim /etc/httpd/conf/httpd.conf
设置web服务器根目录:
DocumentRoot "/var/www/html"
设置目录首页:
DirectoryIndex index.html index.html.var
修改为
DirectoryIndex index.html index.jsp index.htm
ServerName http://i-dbank.com:80
在文件最后添加下面内容:
<Location /server-status>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from all
</Location>
<Location /balancer-manager>
SetHandler balancer-manager
Order Deny,Allow
Deny from all
Allow from all
</Location>
ProxyPass /images !
ProxyPass /css !
ProxyPass /js !
ProxyRequests Off
ProxyPass / balancer://tomcatcluster/ stickysession=jsessionid nofailover=On
ProxyPass /temp http://192.168.14.30/temp/
#ProxyPassReverse / balancer://tomcatcluster/
#ProxyPassReverse /ccas balancer://tomcatcluster/ccas/
#ProxyPassReverse /clpay balancer://tomcatcluster/clpay/
<Proxy balancer://tomcatcluster>
#BalancerMember http://192.168.14.30:8080 loadfactor=1
BalancerMember http://10.0.30.67 route=jvm1 loadfactor=1
# Less powerful server,don't send as many requests there
BalancerMember http://10.0.30.151 route=jvm2 loadfactor=2
</Proxy>
查看apache编译的模块信息
[root@cloud_test tomcat-connectors-1.2.32-src]# /usr/sbin/apachectl -l
Compiled in modules:
core.c
prefork.c
http_core.c
mod_so.c
重新启动Apache:service httpd start
- 大小: 100.1 KB
- 大小: 80.9 KB
- 大小: 73.1 KB
- 大小: 26.8 KB
- 大小: 60.1 KB
- 大小: 33.5 KB
- 大小: 106.3 KB
- 大小: 19.1 KB
- 大小: 6.2 KB
- 大小: 10.9 KB
- 大小: 15.6 KB
- 大小: 14.3 KB
- 大小: 77.9 KB
- 大小: 33.3 KB
分享到:
相关推荐
Apache+Tomcat+Linux集群和均衡负载(Session同步复制
### Apache+Tomcat+Linux集群和负载均衡 在IT领域,Apache+Tomcat+Linux集群与负载均衡技术是实现高可用性、高性能Web服务的重要手段之一。本文将围绕这一主题展开详细讨论,涵盖关键技术概念、配置流程及注意事项...
通过以上步骤,我们完成了在 Red Hat Linux 9.0 上安装 Apache、Tomcat 和 Mod_jk 的过程,并进行了简单的负载均衡配置。这些配置能够帮助我们更好地管理应用服务器集群,提高系统的稳定性和性能。当然,实际部署时...
本文主要介绍了如何在Windows和Linux环境下搭建Tomcat集群并使用Apache作为集群的代理服务器和负载均衡器。通过本指南,读者可以学习到在不同操作系统下进行集群配置的具体步骤。 #### 二、准备工作 在开始安装之前...
在Linux环境下,构建一个基于Apache2和Tomcat7.0的SSL集群是一项关键任务,它涉及到网站的安全性和负载均衡。Apache作为前端服务器处理HTTPS请求,而Tomcat则作为后端应用服务器处理Java应用。以下是对这个配置过程...
### Linux环境下Apache+Tomcat集群负载均衡搭建详解 在企业级应用中,为了提升服务器的稳定性和处理能力,常采用Apache+Tomcat集群的方式来进行负载均衡。本文将详细介绍如何在Linux环境下搭建Apache+Tomcat集群...
Apache 的 Tomcat 负载均衡和集群 ( linux, centos) jkmod
Apache Tomcat 集群负载均衡 ##### 1.13 Tomcat 端口配置 为了实现集群中的负载均衡,需要对 Tomcat 实例上的端口进行配置。这通常涉及到以下端口: - **HTTP 端口**:用于接收客户端的 HTTP 请求。 - **AJP 端口*...
在Linux环境中,通过Apache HTTP服务器(简称Apache)搭建Tomcat集群是一种常见的高可用性和负载均衡配置方式。Apache作为反向代理服务器,可以将用户的请求分发到多个Tomcat实例上,从而实现应用服务的扩展和容错。...
以上步骤详细介绍了如何在Linux环境下构建Apache双机高可用集群和Tomcat负载均衡集群。确保每一步都正确执行,以实现高可用性和负载均衡,提升Web服务的稳定性和效率。在实际操作过程中,可能需要根据实际情况对配置...
以上就是基于Red Hat 5的Linux环境中,Apache与Tomcat集群的基本配置步骤和注意事项。通过这种方式,您可以实现高效、可靠的Web服务环境,以应对高并发访问和确保业务连续性。对于更复杂的需求,如SSL加密、缓存策略...
总结,实现Apache+Tomcat集群负载均衡的关键在于正确配置Apache的mod_proxy模块,以及确保Tomcat集群的会话一致性。通过这种方式,我们可以有效分摊高并发访问压力,提高系统的稳定性和响应速度。同时,持续监控和...
在构建高性能的Web服务环境中,...总结来说,Nginx+Memcache+Linux+Tomcat集群通过合理利用资源,实现了Web服务的高性能、高可用性和可扩展性。这种架构在处理大量并发请求时表现出色,是现代互联网服务的常见选择。
本篇文章将详细介绍如何在 Linux 环境下搭建基于 Apache 和 Tomcat 的集群负载均衡,并实现 session 复制,以确保在多台服务器之间能够无缝地进行会话共享。 #### 二、环境配置 在部署 Apache+Tomcat 集群之前,...
在Linux环境中,使用Apache、Tomcat和JK模块实现负载均衡和群集是一项常见的高可用性架构设计,它能够有效地分发网络流量,提高系统的可扩展性和稳定性。Apache作为前端Web服务器,负责接收用户请求并根据配置策略将...
在本文中,我们将深入探讨如何在Linux环境下部署一个基于Tomcat 6和Apache 2.2的集群。首先,我们需要准备相应的软件包,包括JDK、Apache HTTP服务器、Tomcat以及JK模块,这些是构建集群的基础组件。 1. **JDK安装*...
### Linux下Apache+Tomcat集群指南 #### 一、系统集群环境...通过上述步骤和注意事项,您可以在Linux环境下成功搭建一个Apache+Tomcat集群,并实现负载均衡和Session复制等功能,从而显著提升Web应用的性能和稳定性。
配置文件server.xml是Tomcat的核心配置文件,通过编辑该文件可以配置Connector和Engine等关键组件,文档中提到了为支持负载均衡通过AJP连接器设置jvmRoute属性,这是为了支持在多台Tomcat服务器上进行负载均衡配置。...
在IT行业中,集群部署是一种常见的高可用性和负载均衡解决方案,特别是在服务器端应用中。本教程将详细介绍如何在Linux系统上部署一个基于Tomcat6和Apache2.4的集群环境。这个集群部署旨在提高应用程序的性能和稳定...