标签:api 1.5 ima jar server javac tick world amp
[root@server1 ~]# tar zxf jdk-7u79-linux-x64.tar.gz -C /usr/local/[root@server3 nginx-1.10.1]# ./configure --prefix=/usr/local/lnmp/nginx --with-http_ssl_module --with-http_stub_status_module --with-file-aio --with-threads --user=nginx --group=nginx --add-module=/root/nginx-sticky-module-ng
[root@server3 nginx-1.10.1]# make && make install 编译安装
[root@server3 nginx-1.10.1]# cd /usr/sbin/
[root@server3 sbin]# nginx
[root@server3 sbin]# cd /usr/local/lnmp/nginx/conf/
[root@server3 conf]# vim nginx.conf
[root@server3 conf]# pwd
/usr/local/lnmp/nginx/conf
[root@server3 conf]# vim nginx.conf
17 http {
18 upstream tomcat { #负载均衡模块
19 sticky;
20 server 192.168.122.12:8080; #后端tomcat
21 server 192.168.122.13:8080;
22 }
23
24 include mime.types;
25 default_type application/octet-stream;
68 location ~ .jsp$ { #所有jsp页面交给tomcat处理,动静分离
69 proxy_pass http://tomcat;
70 }
[root@server3 logs]# nginx -t
测试:
[root@server3 conf]# curl 172.25.135.1:8080/test.jsp
[root@server3 conf]# curl 172.25.135.2:8080/test.jsp
配置session
server1,2上
把如下软件包放置到/usr/local/tomcat/lib 目录中
kryo-1.03.jar
kryo-serializers-0.8.jar
memcached-2.5.jar
memcached-session-manager-1.5.1.jarmemcached-session-manager-tc7-1.5.1.jar
minlog-1.2.jar
msm-kryo-serializer-1.5.1.jar
reflectasm-0.9.jar
[root@server1 ROOT]# cd /usr/local/tomcat/lib/
[root@server1 lib]# ls
annotations-api.jar jsp-api.jar spymemcached-2.7.3.jar
asm-3.2.jar kryo-1.04.jar tomcat-api.jar
catalina-ant.jar kryo-serializers-0.10.jar tomcat-coyote.jar
catalina-ha.jar memcached-session-manager-1.6.3.jar tomcat-dbcp.jar
catalina.jar memcached-session-manager-tc6-1.6.3.jar tomcat-i18n-es.jar
catalina-tribes.jar memcached-session-manager-tc7-1.6.3.jar tomcat-i18n-fr.jar
ecj-4.2.1.jar minlog-1.2.jar tomcat-i18n-ja.jar
el-api.jar msm-kryo-serializer-1.6.3.jar tomcat-jdbc.jar
jasper-el.jar reflectasm-1.01.jar tomcat-util.jar
jasper.jar servlet-api.jar
[root@server1 lib]# cd ..
[root@server1 tomcat]# cd conf/
[root@server1 conf]# pwd
/usr/local/tomcat/conf
[root@server1 conf]# vim context.xml
<?xml version=‘1.0‘ encoding=‘utf-8‘?>
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Valve className="org.apache.catalina.valves.CometConnectionManagerValve" />
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:172.25.135.1:11211,n2:172.25.135.2:11211"
failoverNodes="n1" 在 node2(server3) 上此项设置为“n2 (坏了找自己)
requestUriIgnorePattern=".*.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory"
/>
</Context>
[root@server1 conf]# yum install -y memcached 安装
[root@server1 conf]# /etc/init.d/memcached start
[root@server1 conf]# vim /usr/local/tomcat/webapps/ROOT/test.jsp
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.util.*" %>
<html><head><title>Cluster App Test</title></head>
<body>
Server Info:
<%
out.println(request.getLocalAddr() + " : " + request.getLocalPort()+"<br>");%>
<%
out.println("<br> ID " + session.getId()+"<br>");
String dataName = request.getParameter("dataName");
if (dataName != null && dataName.length() > 0) {
String dataValue = request.getParameter("dataValue");
session.setAttribute(dataName, dataValue);
}
out.print("<b>Session list</b>");
Enumeration e = session.getAttributeNames();
while (e.hasMoreElements()) {
String name = (String)e.nextElement();
String value = session.getAttribute(name).toString();
out.println( name + " = " + value+"<br>");
System.out.println( name + " = " + value);
}
%>
server2相同配置
标签:api 1.5 ima jar server javac tick world amp
原文地址:http://blog.51cto.com/13810716/2299735