标签:
本文主要介绍Windows server 2008-32位 单机的nginx-1.9.6+tomcat8+memcached-win32-1.4.4+session共享的配置
第一章:安装配置memcached-win32-1.4.4以便后面共享tomcat8 的session信息
1、下载服务端memcached软件:http://blog.couchbase.com/memcached-144-windows-32-bit-binary-now-available
2、memcached基本参数设置:
-p 监听的端口
-l 连接的IP地址, 默认是本机
-d start 启动memcached服务
-d restart 重起memcached服务
-d stop|shutdown 关闭正在运行的memcached服务
-d install 安装memcached服务
-d uninstall 卸载memcached服务
-u 以的身份运行 (仅在以root运行的时候有效)
-m 最大内存使用,单位MB。默认64MB
-M 内存耗尽时返回错误,而不是删除项
-c 最大同时连接数,默认是1024
-f 块大小增长因子,默认是1.25
-n 最小分配空间,key+value+flags默认是48
-h 显示帮助
3、以管理员身份运行 cmd.exe,并转至memcached所在文件夹,比如:
cd D:\wamp_win7\bin\memcached-win32-1.4.4
|
注意:如果不以管理员身份运行,将得到报错“failed to install service or service already installed”
4、安装memcached:
memcached.exe -d
install -m 500 -c 2048
(之后屏幕无任何提示,可以再[控制面板]->[管理工具]->[服务]中查看到memcached)
5、启动memcached:[控制面板]->[管理工具]->[服务] 找到 memcached 服务
启动类型:选择【自动】
服务状态:点击下面的【启动】
第二章:安装配置apache-tomcat-8.0.28-windows-x86
首先要先下载依赖包:http://download.csdn.net/download/xuzhaoshan/9264151
将下载的jar包复制到tomcat8的lib目录下(必须)。
设置tomcat8 的jdk ,在setclasspath.bat文件中添加jdk路径:
set JAVA_HOME="D:\Tomcat8-Cluster\jdk1.8"
set JRE_HOME="D:\Tomcat8-Cluster\jre1.8"
1、配置tomcat-8-1
配置conf目录的context.xml文件,内容如下:
<?xml version=‘1.0‘ encoding=‘utf-8‘?>
<Context> -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:localhost:11211"
sticky="false"
sessionBackupAsync="false"
lockingMode="none"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.JavaSerializationTranscoderFactory"/>
</Context>
配置conf目录的server.xml文件,内容如下:
<?xml version=‘1.0‘ encoding=‘utf-8‘?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="1000" maxIdleTime="60000" minSpareThreads="20"/>
<Connector port="81" protocol="org.apache.coyote.http11.Http11AprProtocol"
executor="tomcatThreadPool" compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain,application/json,application/x-javascript"
maxThreads="30000" minSpareThreads="512" enableLookups="false" acceptCount="35000"
connectionTimeout="40000" disableUploadTimeout="true" URIEncoding="UTF-8" useBodyEncodingForURI="true" redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="192.168.1.2" jvmRoute="tomcat8-1">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
<Host name="192.168.1.2" appBase="webapps" unpackWARs="true" autoDeploy="false">
<Context path="" docBase="D:\Tomcat8-Cluster\项目名称" reloadable="false" />
</Host>
</Engine>
</Service>
</Server>
1、配置tomcat-8-2
配置conf目录的context.xml文件,内容如下:
<?xml version=‘1.0‘ encoding=‘utf-8‘?>
<Context> -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:localhost:11211"
sticky="false"
sessionBackupAsync="false"
lockingMode="none"
requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.JavaSerializationTranscoderFactory"/>
</Context>
配置conf目录的server.xml文件,内容如下:
<?xml version=‘1.0‘ encoding=‘utf-8‘?>
<Server port="8006" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="1000" maxIdleTime="60000" minSpareThreads="20"/>
<Connector port="82" protocol="org.apache.coyote.http11.Http11AprProtocol"
executor="tomcatThreadPool" compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain,application/json,application/x-javascript"
maxThreads="30000" minSpareThreads="512" enableLookups="false" acceptCount="35000"
connectionTimeout="40000" disableUploadTimeout="true" URIEncoding="UTF-8" useBodyEncodingForURI="true" redirectPort="8444" />
<Connector port="8010" protocol="AJP/1.3" redirectPort="8444" />
<Engine name="Catalina" defaultHost="192.168.1.2" jvmRoute="tomcat8-2">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
<Host name="192.168.1.2" appBase="webapps" unpackWARs="true" autoDeploy="false">
<Context path="" docBase="D:\Tomcat8-Cluster\gy" reloadable="false" />
</Host>
</Engine>
</Service>
</Server>
第三章:安装配置nginx-1.9.6
首先要先下载nginx-1.9.6,修改nginx.conf文件,如下:
#user nobody;
#工作进程数:这个数值要根据服务器CPU核心数来配置,如6核12线程的cpu可以配置为6或12。
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 {
#设置单个进程同时打开的最大连接数,这个值设置大些能接受较多的连接,当然这需要cpu和内存支持哦~~
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
#gzip on;
# 在此处设置tomcat服务器信息,同样tomcat也可以不在同一主机中。这里设置了两个tomcat服务,比重是1:1了。 localhost更换为服务器的IP
upstream 192.168.1.2{
server 192.168.1.2:81 max_fails=0;
server 192.168.1.2:82 max_fails=0;
#ip_hash;
}
server {
listen 80;
server_name 192.168.1.2;
charset utf-8;
location / {
root html;
index index.html index.htm;
proxy_pass http://192.168.1.2;
proxy_redirect default;
}
#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;
}
}
}
启动方式,可以将命令保存为 .bat文件,方便操作
启动:start nginx
停止:nginx -s stop
重新加载:nginx -s reload
分布式部署一(Windows server 2008-32位 单机)
标签:
原文地址:http://my.oschina.net/glenxu/blog/529714