【文件属性】:
文件名称:tomcat8 + nginx + memcached + cas 实现负载均衡的配置包
文件大小:6.24MB
文件格式:ZIP
更新时间:2020-04-13 08:51:04
tomcat8 nginx memcached cas
1,tomcat8的配置:
1.1修改tomcat8.x/conf/context.xml的配置如下:
WEB-INF/web.xml
${catalina.base}/conf/web.xml
1.2添加memcached如下依赖的jar包到tomcat8.x/lib/:
asm-5.1.jar
couchbase-client-1.4.12.jar
javolution-5.5.1.jar
kryo-4.0.0.jar
kryo-serializers-0.38.jar
memcached-session-manager-2.0.0.jar
memcached-session-manager-tc8-2.0.0.jar
minlog-1.3.jar
msm-javolution-serializer-2.0.0.jar
msm-kryo-serializer-2.0.0.jar
msm-xstream-serializer-2.0.0.jar
objenesis-2.1.jar
reflectasm-1.09.jar
spymemcached-2.12.1.jar
2,nginx的配置:
#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;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
#设定负载均衡的服务器列表
upstream 127.0.0.1 {
#设定负载均衡的服务器列表
#ip_hash;
#同一机器在多网情况下,路由切换,ip可能不同 #weigth参数表示权值,权值越高被分配到的几率越大
server 127.0.0.1:8085 weight=1 max_fails=20 fail_timeout=600s;
server 127.0.0.1:8086 weight=1 max_fails=20 fail_timeout=600s;
}
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name localhost;
charset UTF-8;
#设定本虚拟主机的访问日志
access_log logs/host.access.log main;
#对 "/" 所有应用启用负载均衡
location / {
proxy_pass http://127.0.0.1;
#保留用户真实信息
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
index index.html index.htm index.aspx;
}
#对 "/Dossm3RabbitMQConsumer/" 启用负载均衡
location /Dossm3RabbitMQConsumer/ {
proxy_pass http://localhost:8086;
#保留用户真实信息
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
index index.html index.htm index.aspx;
}
}
# 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;
# }
#}
}
3,cas的配置():
3.1 修改/CAS/WEB-INF/spring-configuration/ticketRegistry.xml
Configuration for the default TicketRegistry which stores the tickets in-memory and cleans them out as specified intervals.
3.2 添加cas和memcached整合的如下依赖jar包到/CAS/WEB-INF/lib:
cas-server-integration-memcached-4.0.0.jar
mockito-core-2.1.0-RC.1.jar
spymemcached-2.11.2.jar
参考CAS官方配置:https://apereo.github.io/cas/4.2.x/installation/Memcached-Ticket-Registry.html
【文件预览】:
memcached-win64-1.4.4-14+nginx1.10.1+tomcat8
----nginx-conf()
--------nginx.conf(3KB)
----tomcat8-conf()
--------context.xml(3KB)
--------CAS-conf()
----memcached-win64-1.4.4-14.zip(377KB)
----nginx-1.10.1.zip(1.3MB)
----tomcat8-lib()
--------msm-xstream-serializer-2.0.0.jar(5KB)
--------tomcat8-lib.zip(1.75MB)
--------spymemcached-2.12.1.jar(461KB)
--------javolution-5.5.1.jar(386KB)
--------msm-javolution-serializer-2.0.0.jar(68KB)
--------CAS-lib()
--------msm-kryo-serializer-2.0.0.jar(36KB)
--------kryo-4.0.0.jar(316KB)
--------asm-5.1.jar(52KB)
--------reflectasm-1.09.jar(19KB)
--------memcached-session-manager-2.0.0.jar(163KB)
--------memcached-session-manager-tc8-2.0.0.jar(11KB)
--------kryo-serializers-0.38.jar(83KB)
--------objenesis-2.1.jar(41KB)
--------couchbase-client-1.4.12.jar(337KB)
--------minlog-1.3.jar(5KB)
----ticketRegistry.xml(4KB)