Open v5tech opened 8 years ago
nginx.conf
#user nobody;
worker_processes 4;
#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 65;
#gzip on;
upstream site {
server localhost:8080;
server localhost:9080;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
#root html;
index index.jsp index.html index.htm index.php;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_buffers 32 4k;
proxy_connect_timeout 3;
proxy_send_timeout 30;
proxy_read_timeout 30;
proxy_pass http://site;
}
#error_page 404 /404.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 $document_root$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;
# }
#}
}
tomcat-7.0.X/conf/context.xml
<?xml version='1.0' encoding='utf-8'?>
<Context>
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<!-- Uncomment this to enable Comet connection tacking (provides events
on session expiration as well as webapp lifecycle) -->
<!--
<Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
-->
<!--tomcat-redis-session-manager-->
<!--
<Valve className="com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" />
<Manager className="com.orangefunction.tomcat.redissessions.RedisSessionManager"
host="localhost"
port="6379"
database="0"
maxInactiveInterval="60" />
-->
<!--memcached-session-manager-->
<!--
de.javakaffee.web.msm.JavaSerializationTranscoderFactory
de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory
de.javakaffee.web.msm.serializer.xstream.XStreamTranscoderFactory
de.javakaffee.web.msm.serializer.json.JSONTranscoderFactory
de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory
-->
<!-- java默认序列化 -->
<!--
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:127.0.0.1:11211"
sticky="false"
sessionBackupAsync="false"
sessionBackupTimeout="100"
lockingMode="auto"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.JavaSerializationTranscoderFactory"
/>
-->
<!-- Kryo -->
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:127.0.0.1:11211"
sticky="false"
sessionBackupAsync="false"
sessionBackupTimeout="100"
lockingMode="auto"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
copyCollectionsForSerialization="true"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
/>
<!-- XStream -->
<!--
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:127.0.0.1:11211"
sticky="false"
sessionBackupAsync="false"
sessionBackupTimeout="100"
lockingMode="auto"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.xstream.XStreamTranscoderFactory"
/>
-->
<!-- flexjson -->
<!--
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:127.0.0.1:11211"
sticky="false"
sessionBackupAsync="false"
sessionBackupTimeout="100"
lockingMode="auto"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.json.JSONTranscoderFactory"
/>
-->
<!-- javolution -->
<!--
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:127.0.0.1:11211"
sticky="false"
sessionBackupAsync="false"
sessionBackupTimeout="100"
lockingMode="auto"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
copyCollectionsForSerialization="true"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"
/>
-->
</Context>
tomcat-7.X/lib
asm-3.2.jar
flexjson-3.3.jar
javolution-5.4.3.1.jar
kryo-1.04.jar
kryo-serializers-0.11.jar
memcached-session-manager-1.8.3.jar
memcached-session-manager-tc7-1.8.3.jar
minlog-1.2.jar
msm-flexjson-serializer-1.8.3.jar
msm-javolution-serializer-1.8.3.jar
msm-kryo-serializer-1.8.3.jar
msm-xstream-serializer-1.8.3.jar
reflectasm-1.01.jar
spymemcached-2.11.1.jar
xmlpull-1.1.3.4a.jar
xpp3_min-1.1.4c.jar
xstream-1.4.8.jar
Installing Memcached on Windows
http://downloads.northscale.com/memcached-1.4.5-amd64.zip
启动Memcached
添加依赖、修改配置
核心公共依赖
不需要添加任何依赖jar,只添加上述核心公共依赖
注:以上所有的修改均为修改tomcat/conf/context.xml文件
启动nginx、tomcat
参考文档
https://commaster.net/content/installing-memcached-windows http://chenzhou123520.iteye.com/blog/1650212 http://blog.csdn.net/zhu_tianwei/article/details/18033483 https://github.com/magro/memcached-session-manager https://github.com/magro/memcached-session-manager/wiki/SetupAndConfiguration https://github.com/magro/memcached-session-manager/wiki/SerializationStrategies