添加到自启动并设置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集群和负载均衡
本文为您讲述了如何在 Windows 或 Linux 下进行 Tomcat 集群的安装配置。 Windows 下 Tomcat 集群的安装配置与 Linux 下稍有区别,道长为了在一篇教程中讲解两 ...器上),它同时也负责负载均衡。
Apache 的 Tomcat 负载均衡和集群 ( linux, centos) jkmod
Linux平台Apache高可用双机集群Tomcat负载均衡集群配置手册[定义].pdf
tomcat+apache+linux负载均衡集群配置反向代理
本说明手册为了阐述Linux搭建Apache+Tomcat环境,并详细介绍Tomcat的集群和负载均衡配置而编写。届时介绍域名的绑定,Red Hat和Ubuntu中随系统自动启动个软件的配置方法。
讲述了怎样在liunx系统下配置tomcat集群,apache负载均衡,session黏贴,关于缓存,压缩可以在此基础上扩展
最近学习Nginx+tomcat实现 负载均衡。 首先大家注意: 本文章中没有session共享,关于session共享我会在下一篇中讲解,先实现Nginx+tomcat负载均衡再实现session共享。 从网上查了好多资料,多走了很多弯路,现在把...
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
本文主要总结了在Ubuntu10下常用...为进一步配置和实现LNMJ和LAMJ架构(负载均衡与集中式Memcached集群)进行前期准备。本文记录了安装过程经常出现的错误,并提供了解决办法,具有很好的实用性,是居家旅行必备之良品。
tomcat: 1.6 os: Red Hat Enterprise Linux Server release 5.5 apache:2.4.7 jk:1.2.37 Red Hat Enterprise Linux 下两台服务器布署...win7下 单机双 tomcat 布署测试成功(apache布署在linux上) 都可实现session复制
linux-apache-tomcat集群,负载均衡
linux-apache tomcat集群,服务器集群,分压作用,负载均衡
javaweb高可用+负载均衡-服务器集群(keepalived+apache+tomcat)生产环境部署手册 所用技术:1高可用集群keepalived。2负载均衡集群apache。3tomcat服务。4生产环境的日常维护脚本 真实生产环境在用的技术架构,亲...
************************************************************************************************************...3. 通过chmod +x jdk-1_5_x-rc-linux-i586-rpm.bin命令使其获得可执行权限 4. 执行./jdk-1_5_0_1
Redhat_Linux中JDK的卸载和安装 Redhat_Linux搭建FTP服务 Redhat安装Apache和SVN Mod_Proxy+Apache+Tomcat负载均衡与集群配置 Redhat_linux创建FTP用户(含-SELinux简介)
其占有内存少,并发能力强,在同类型的网页服务器中表现较好。...在这里我们采用集群部署方式,使用多个Tomcat,反向代理使用Nginx。 架构如下: 准备工作 apache-tomcat-7.0.61 nginx-1.12.2 Redis-x64-3.2.10
linux环境下搭建Tomcat集群详细步骤及各个参数配置,jk连接器的使用和代理配置,Apache安装和设置,Tomcat部署
主要介绍了秀脱linux笔记之tomcat6_apache2.2负载均衡加集群实战篇,需要的朋友可以参考下