nginx memcache Tomcat
来源:互联网 发布:淘宝培训机构 编辑:程序博客网 时间:2024/05/22 10:25
node1:172.25.50.1 nginx Tomcat memcached
node2:172.25.50.2 Tomcat memcached
<下图来自于网络>
一、memcache
安装包:memcache-2.2.5.tgz
解压
配置
vim ~/.bash_profile --> PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin:/usr/local/lnmp/php/binsource ~/.bash_profilephpize./configure --enable-memcache //编译make make installvim /usr/local/lnmp/php/etc/php.ini --> 851 extension=memcache.socd /memcache-2.2.5 vim memcache.php -->23 define('ADMIN_PASSWORD','westos'); // Admin Password 28 $MEMCACHE_SERVERS[] = '172.25.50.1:11211'; // add more as an array cp example.php memcache.php /usr/local/lnmp/nginx/htmlyum install memcached -y //并且打开服务
测试:
二、Tomcat
安装包:
apache-tomcat-7.0.37.tar.gz jdk-7u79-linux-x64.tar.gz
jdk:Java语言的软件开发工具包
tomcat:应用(Java)服务器,是apache的扩展
解压
配置
tar zxf jdk-7u79-linux-x64.tar.gz -C /usr/local/ cd /usr/local ln -s jdk1.7.0_79/ javavim /etc/profile --> 80 export JAVA_HOME=/usr/local/java 81 export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib 82 export PATH=$PATH:$JAVA_HOME/bin
测试java包是否安装好,写一个java脚本,再进行编译测试。
vim test.java
–> public class test
{
public static void main(String[] args){
System.out.println(“Hello World!”);
}
}
javac test.java[root@server1 ~]# java testHello world!
tar zxf apache-tomcat-7.0.37.tar.gz -C /usr/local cd /usr/local ln -s apache-tomcat-7.0.37/ tomcat##开启tomcat ##为8080端口## 为tomcat目录下的bin/startup.sh## 关闭为bin/shutdown.shvim /usr/local/lnmp/nginx/conf/nginx.conf --> 70 location ~ \.jsp$ { 71 proxy_pass http://172.25.50.1:8080; 72 }
测试是否安装成功:
也可写一个脚本测试:
vim /usr/local/tomcat/webapps/ROOT/test.jsp -->server1 time is: <%= new java.util.Date() %>
将jar目录中的内容全部放在tomcat下面的lib中,删除掉memcached-session-manager-tc6-1.5.1.jar
vim /usr/local/tomcat/conf/context.xml //在最后加上 <Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager" memcachedNodes="172.25.50.1:11211,n2:172.25.50.2:11211" failoverNodes="n1" #在node2上此项设置为“n2” requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$" transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory" />启动该服务的命令为 /usr/local/tomcat/bin/startup.sh关闭命令为 /usr/local/tomcat/bin/shutdown.sh
三、配置nginx
vim /usr/local/lnmp/nginx/conf/nginx.conf--> http { upstream westos { sticky; server 172.25.50.1:8080; server 172.25.50.2:8080; } location ~ \.jsp$ { proxy_pass http://westos; }
最后也可以自写测试页
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);}%><form action="test.jsp" method="POST">name:<input type=text size=20 name="dataName"><br>key:<input type=text size=20 name="dataValue"><br><input type=submit></form></body></html>
阅读全文
0 0
- nginx+tomcat+memcache----3 memcache
- java+nginx+tomcat+memcache
- nginx memcache Tomcat
- nginx+tomcat+memcache
- nginx+tomcat+memcache配置
- tomcat+memcache+nginx实现共享
- nginx+tomcat+memcache----2 tomcat+nginx负载均衡
- Nginx+双tomcat+memcache实现软负载
- session共享之nginx+tomcat+memcache
- Nginx+Tomcat+Memcache|Redis集群配置
- nginx+tomcat+memcache负载均衡动静分离
- nginx+tomcat+memcache----1 jdk+tomcat 环境配置
- memcache nginx
- nginx负载均衡 tomcat集群 memcache共享session
- nginx负载均衡 tomcat集群 memcache共享session
- nginx负载均衡 tomcat集群 memcache共享session
- linux学习之nginx+tomcat+memcache高可用web服务器
- windows下nginx+tomcat+memcache负载均衡集群搭建
- Linux下启动和停止apache服务
- hadoop涉及到分摊磁盘io负载的配置
- <Shader> 最终版本的水纹效果
- ubuntu12.04 挂载samba网盘命令
- (138)lightmass 全局光照
- nginx memcache Tomcat
- Linux(CentOS7) 系统中指定机器的IP地址(静态IP)
- Oravcle积累
- 22、vue.js 之常用的一些数据处理方法
- Apache Tiles教程
- Chrome接口调试插件、浏览器接口调试插件、浏览器接口调试工具
- Spring Cloud Netflix的3大组件应用 Eureka&Ribbon&Hystrix
- 我对AOP(面向切面编程)的理解
- 一种整数数据压缩存储的算法实现