800x600
Normal
0
7.8 磅
0
2
false
false
false
EN-US
ZH-CN
X-NONE
MicrosoftInternetExplorer4
st1\:*{behavior:url(#ieooui) }
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman","serif";}
架构文档说明
1. nginx环境
1.1 安装
下载nginx服务包,在此我使用的是nginx1.3.13
800x600
Normal
0
7.8 磅
0
2
false
false
false
EN-US
ZH-CN
X-NONE
MicrosoftInternetExplorer4
st1\:*{behavior:url(#ieooui) }
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman","serif";}
主要配置conf目录下的配置文件和使用nginx.exe的服务。
1.2 在cmd中进入nginx.exe所在的目录,输入:start nginx.exe启动nginx服务;nginx.exe –s quit或nginx.exe –s stop 停止nginx服务;nginx.exe
–s reload刷新nginx的配置文件。
1.1
配置
找到nginx的安装目录:ngin1.3.13/conf/conf文件
800x600
Normal
0
7.8 磅
0
2
false
false
false
EN-US
ZH-CN
X-NONE
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman","serif";}
nginx.conf文件是nginx的核心配置文件。具体配置见下图:
800x600
Normal
0
7.8 磅
0
2
false
false
false
EN-US
ZH-CN
X-NONE
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman","serif";}
2.
msm环境
2.1
安装
下载memcached服务及安装包,如图所示:
800x600
Normal
0
7.8 磅
0
2
false
false
false
EN-US
ZH-CN
X-NONE
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman","serif";}
memcached.exe为memcached服务,也是windows服务的一部分,memcached.exe一定要下载和自己电脑的bit数一致,如:32为、64位;其它则为缓存服务器所依赖的JAR文件,其中
800x600
Normal
0
7.8 磅
0
2
false
false
false
EN-US
ZH-CN
X-NONE
MicrosoftInternetExplorer4
st1\:*{behavior:url(#ieooui) }
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman","serif";}
是Tomcat7及以上所需要的JAR,如果使用的是Tomact6的版本则下载对应的版本,如:memcached-session-maager-tc7-1.6.3.jar,其他的JAR文件在该地址中都可以对应的找到:
http://code.google.com/p/memcached-session-manager/downloads/list。
将memcached.exe放到一个目录下面,如D:\msm\memcached.exe。在cmd中进入到memcached.exe的目录:memcached.exe
–d install安装memcached服务;memcached.exe
–p 11211 –d start启动memcached服务,其中11211是该服务的端口号;memcached.exe –d uninstall 卸载memcached服务。
2.2
配置
在tomcat的lib目录中加入memcached缓存支持的JAR文件(12个jar)。
在tomcat目录下的content.xml文件,在content标签中加入:
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager" memcachedNodes="n2:localhost:11211" requestUriIgnorePattern=".*/.(png|gif|jpg|css|js)$" sessionBackupAsync="false" sessionBackupTimeout="100" transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory" copyCollectionsForSerialization="false"/>
800x600
Normal
0
7.8 磅
0
2
false
false
false
EN-US
ZH-CN
X-NONE
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman","serif";}
memcachedNodes属性中的n2表示服务中的节点,可以自定义的,但是不同的memcached服务规定节点不能一样,否则不能实现session共享,不同的服务定义不同的节点,一个memcachedNodes也可以定义多个节点:memcachedNodes=" n2:localhost:11211 n2:192.168.21.**:11211",不同的节点直接用空格或逗号隔开即可。
修改tomcat目录下的server.xml文件,在Engine标签中添加jvmRote属性,jvm的值不能和集群中tomcat中的jvmRote值重复。
tomcat通过在不同的jmv上配置不同的jvmRoute参数,来防止集群的时候sessionid冲突:<Engine name="Catalina"
defaultHost="localhost" jvmRoute="jvm1" />。
注意:jvm值在同一个集群中不能一样,用来标识不同的tomcat服务,在msm集群中的每个tomcat必须要写。
3.
tomcat环境
3.1每个tomcat的端口不能重复,如图:
800x600
Normal
0
7.8 磅
0
2
false
false
false
EN-US
ZH-CN
X-NONE
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman","serif";}
下图是对tomcat中server.xml文件中的端口解释
800x600
Normal
0
7.8 磅
0
2
false
false
false
EN-US
ZH-CN
X-NONE
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman","serif";}
3.2
实现域名访问tomcat中的项目需要把tomcat默认显示的index.jsp进行更改掉
800x600
Normal
0
7.8 磅
0
2
false
false
false
EN-US
ZH-CN
X-NONE
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman","serif";}
打开index.jsp页面,将里面css部分、body标签部分全部删除,然后在index.jsp内部最后添加:
<script> Window.onload=function(){ Window.loaction=”../dkce/app/index.jsp”; } </script>
800x600
Normal
0
7.8 磅
0
2
false
false
false
EN-US
ZH-CN
X-NONE
MicrosoftInternetExplorer4
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman","serif";}
注意:每个tomcat中的访问端口必须要在防火墙的入站规则里面进行创建,如当前的tomcat的对外端口是8080,则要在入站规则里面创建一个对外的端口。
1. 安装配置与启动项
1.1 将nginx和memcached服务进行安装,然后启动memcached服务。
1.2 配置JDK、环境变量,将项目放入tomcat中,进行配置memcached和域名访问的方式,上面已经详细介绍,启动tomcat。
1.3 配置nginx脚本(conf.xml),配置完成之后进行启动。
1.4 A.如果重启nginx服务不需要重启tomcat服务。B.如果重启tomcat服务,需要重启nginx服务(不是关机重启,是使用命令重启,2秒钟即可完成)。
1.5 如果在tomcat集群中移除其中的一台tomcat服务器,对于整个集群是不受影响的。添加一台tomcat服务器只需在nginx中注册该服务并重启nginx服务即可。在整个集群,无论nginx停止或重启、tomcat停止或重启对memcached服务不受任何影响。