如何搭建apache+tomcat集群
1、安装tomcat+apache+mysql。2、修改tomcat的端口,即修改server.xml中的配置,并修改
3、修改httpd.conf,解注释Include conf.d/*.conf
4、在conf.d文件夹中加入xxx.conf文件,在该文件中添加如下配置:
#LoadModule proxy_http_module modules/mod_proxy_http.so
ProxyRequests Off
ProxyPass / balancer://chinatrial-cluster/ stickysession=JSESSIONID nofailover=Off
ProxyPa***everse / http://127.0.0.1:8084/
ProxyPa***everse / http://127.0.0.1:8184/
#ProxyPa***everse / http://127.0.0.1:8380/
BalancerMemberhttp://127.0.0.1:8084/max=800 loadfactor=10 route=tomcat_8084
BalancerMemberhttp://127.0.0.1:8184/max=800 loadfactor=10 route=tomcat_8184
# BalancerMemberhttp://127.0.0.1:8380/max=800 loadfactor=10 route=chinatrial_8080
其中route后面的值是和tomcat的server.xml中的中的jvmRoute相对应
5、实现session共享
在数据库中建session共享表:
CREATE DATABASE `session`
USE `session`;
DROP TABLE IF EXISTS `session`.`tomcat_sessions`;
CREATE TABLE`session`.`tomcat_sessions` (
`session_id` varchar(100) NOT NULL,
`valid_session` char(1) NOT NULL,
`max_inactive` int(11) NOT NULL,
`last_access` bigint(20) NOT NULL,
`app_context` varchar(255) default NULL,
`session_data` mediumblob,
PRIMARY KEY(`session_id`),
KEY `kapp_context` (`app_context`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
6、在项目的context.xml中进行Manager的配置:
页:
[1]