nginx + memcached-session-manager 实现tomcat下的负载均衡
2024-10-18 22:38:10
1. tomcat6.0 配置
memcached-session-manager 实现session共享
1.1 下载memcached-session-manager-1.6.5.jar、memcached-session-manager-tc6-1.6.5.jar(tomcat6.0)、msm-javolution-serializer-1.6.5.jar、spymemcached-2.8.12.jar、javolution-5.4.3.1.jar和couchbase-client-1.1.4.jar 共5个jar包放入tomcat的lib目录下;
1.2 context节点下增加如下配置
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:192.168.1.104:11211"
sticky="false"
requestUriIgnorePattern=".*\.(png|gif|jpg|css|js)$"
sessionBackupAsync="false"
sessionBackupTimeout="100"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"
copyCollectionsForSerialization="false"
/>
2.nginx-1.5.6 配置
#user nobody;
worker_processes 1; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 10; #gzip on;
upstream localhost {
server 192.168.1.104:85;
server 192.168.1.106:85;
} server {
listen 80;
server_name localhost; #charset koi8-r;
charset utf-8; #access_log logs/host.access.log main; location / {
root html;
index index.html index.htm;
proxy_pass http://localhost;
proxy_set_header X-Real-IP $remote_addr;
client_max_body_size 100m;
} location ~ ^/(WEB-INF)/ {
deny all;
} #error_page 404 /404.html;\
error_page 500 502 503 504 /50x.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }
最新文章
- [题解]poj 1274 The Perfect Stall(网络流)
- JavaScript Patterns 5.5 Sandbox Pattern
- 快速、直接的XSS漏洞检测爬虫 – XSScrapy
- MetInfo安装
- IOS知识小记
- Javascript新手集中营
- Springboot 学习笔记 ①
- Jfinal启动原理及源码简析
- ASP.NET 使用Session,避免用户F5刷新时重复提交(转)
- 拼接SQL执行语句时,对单引号的处理
- burnside+polya 整理
- Linux 程序后台运行
- SQL Server-- 存储过程中错误处理
- leetcode944
- 第 6 章 C控制语句:循环
- amcharts属性
- ASP.NET Web Api OwinSelfHost Restful 使用
- Linux时间子系统(四) timekeeping
- 【Loadrunner】性能测试:通过服务器日志获取性能需求
- CentOS-7设置开机进入命令行界面(不进入图形界面)
热门文章
- Apache+Tomcat +mod_proxy集群负载均衡及session
- html-----007
- jQuery 源码分析3: jQuery.fn/ jQuery.prototype
- CCPC网络赛,HDU_5842 Lweb and String
- ZeroMemory和memset的区别
- 动态SQL实现批量删除指定数据库的全部进程
- ABP手机端调用API时的CORS
- main(int argc , char *argv[])
- docker的基本使用
- @font-face