resin4.0.23+nginx1.1集群
一,web服务器小论
以前的公司使用的web服务器是tomcat(tomcat+apache作集群),现在的公司是一家互联网公司,采用的架构是resin+nginx作集群(resin比tomcat快?还有待以后章节比较讨论),
集群配置服务器说明:
1),serve1:127.0.0.1:8080
2), serve2:127.0.0.1:8081
3), nginx:127.0.0.1:80
集群配置服务器说明:
1),serve1:127.0.0.1:8080
2), serve2:127.0.0.1:8081
3), nginx:127.0.0.1:80
二,配置resin服务器
(注:resin4之前,可以搭一个服务器,在<cluster></cluster>中配置多个server实例,通过实例启动,4.0之后就不可以了,要有专业版才能实现)
在安装resin之前,必须先安装完jvm环境。
serve1:127.0.0.1:8080--->
1,安装resin-4.0.*.tar.gz包
- shell $> tar zxvf resin-4.0.23.tar.gz
- shell $> cd resin-4.0.23
- shell $> ./configure --prefix=/usr/resin/resinserver1/resinserver1/
- shell $> make
- shell $> make install
2,配置resin.conf文件
shell $> cd /usr/resin/resinserver1/resinserver1/
- shell $> cd conf
- shell $> vim resin.conf
- ## 查找 <http address="*" port="8080"/>
- ## 注释掉 <!--http address="*" port="8080"/-->
- ## 查找 <server id="" address="127.0.0.1" port="6800">
- ## 替换成
- <server id="resinserver1" address="127.0.0.1" port="6800">
- <!--<strong>两台服务器配置不同的watchdog端口,否则会出现异常</strong>-->
- <watchdog-port>6700</watchdog-port>
- <http id="" port="8080"/>
- </server>
- ###重启 resin 服务#####
- shell $> cd ../bin
- shell $>./resin.sh -server resinserver1 start
serve1:127.0.0.1:8081--->
---1,
- shell $> tar zxvf resin-4.0.23.tar.gz
- shell $> cd resin-4.0.23
- shell $> ./configure --prefix=/usr/resin/resinserver2/resinserver2/
- shell $> make
- shell $> make install
2,配置resin
shell $> cd conf
- shell $> vim resin.conf
- ## 查找 <http address="*" port="8080"/>
- ## 注释掉 <!--http address="*" port="8080"/-->
- ## 查找 <server id="" address="127.0.0.1" port="6800">
- ## 替换成
- <server id="resinserver2" address="127.0.0.1" port="6801">
- <!--两台服务器配置不同的watchdog端口-->
- <watchdog-port>6701</watchdog-port>
- <http id="" port="8081"/>
- </server>
- ###重启 resin 服务#####
- shell $> cd ../bin
- shell $>./resin.sh -server resinserver2 start
通过以上配置,开启两台resin服务器,接下来就是配置nginx
三,nginx的配置
nginx安装需要以下软件包安装
1,nginx-1.1.5.tar.gz
2,tbje-nginx-upstream-jvm-route-6016b39.tar.gz
3,openssl-1.0.0e.tar.gz(OPENSSL不需要编译安装,只需要解压出来就行)
分别解压以上程序...
- shell $> cd nginx-1.1.5
- shell $> patch -p0 < ../tbje-nginx-upstream-jvm-route-6016b39/jvm_route.patch
- shell $> useradd www
- shell $> ./configure --user=www --group=www --prefix=/usr/nginx/nginxserver --with-http_stub_status_module --with-http_ssl_module=/usr/nginx/openssl-1.0.0e --add-module=/usr/nginx/tbje-nginx-upstream-jvm-route-6016b39
- shell $> make
- shell $> make install
到nginxserver/sbin目录下,,运行./nginx 访问http://127.0.0.1 出现“webcome to nginx”代表nginx安装成功
四,配置集群
打开nginxserver/conf/nginx.conf文件。
- user www www;#工作进程的属主
- worker_processes 2;#工作进程数,一般与 CPU 核数等同
- error_log logs/error.log crit;
- #error_log logs/error.log notice;
- #error_log logs/error.log info;
- pid logs/nginx.pid;
- events {
- worker_connections 1024;#每个工作进程允许最大的同时连接数
- }
- http {
- upstream backend {#集群服务器
- server 127.0.0.1:8080 srun_id=resinserver1;
- server 127.0.0.1:8081 srun_id=resinserver2;
- jvm_route $cookie_JSESSIONID|sessionid;#session共享
- }
- 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;#打开gzip文件压缩
- server {
- listen 80;
- server_name localhost;
- charset UTF-8;
- #下面为location的配置,可以根据自己的业务情况进行定制
- #access_log logs/host.access.log main;
- location / {
- root html;
- index index.html index.htm;
- }
- #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;
- }
- location ~ .*\.jsp$
- {
- proxy_pass http://backend;
- proxy_redirect off;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header Host $http_host;
- }
- location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
- {
- expires 30d;
- }
- location ~ .*\.(js|css)?$
- {
- expires 1h;
- }
- # 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 /scripts$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;
- # server_name localhost;
- # ssl on;
- # ssl_certificate cert.pem;
- # ssl_certificate_key cert.key;
- # ssl_session_timeout 5m;
- # ssl_protocols SSLv2 SSLv3 TLSv1;
- # ssl_ciphers HIGH:!aNULL:!MD5;
- # ssl_prefer_server_ciphers on;
- # location / {
- # root html;
- # index index.html index.htm;
- # }
- #}
- }
nginx命令:
- start nginx 开启nginx
- Nginx -s stop 快速关闭Nginx,可能不保存相关信息,并迅速终止web服务。(quick exit)
- Nginx -s quit 平稳关闭Nginx,保存相关信息,有安排的结束web服务。(graceful exit)
- Nginx -s reload 因改变了Nginx相关配置,需要重新加载配置而重载。(changing configuration,start a new worker,quitting an old worker gracefully.)
- Nginx -s reopen 重新打开日志文件。(reopenging log files)
上面两resin的服务器已经打开,更改两服务器下的如(resinserver1):/usr/resin/resinserver1/resinserver1/webapps/ROOT 下的index.jsp
区别服务器访问路径:
- <%@page language="java" import="java.util.*" pageEncoding="UTF-8"%>
- <%
- %>
- <html>
- <head>
- </head>
- <body>
- nginxserver1<!--在另一台服务器上写nginxserver2-->
- <br />
- <%out.print(request.getSession()) ;%>
- <br />
- <%out.println(request.getHeader("Cookie")); %>
- </body>
- </html>
这时重启nginx
这时访问:http://127.0.0.1/index.jsp会出现以下情况:
- 比较
- resinserver1----->
- nginxserver1
- SessionImpl[aaadbhbcljrab7wtdprmt,]
- JSESSIONID=aaadbhbcljrab7wtdprmt
- 或者
- resinserver2----->
- nginxserver2
- SessionImpl[aaadbhbcljrab7wtdprmt,]
- JSESSIONID=aaadbhbcljrab7wtdprmt
自我总结:
1,下面这个端口号也要变,不然只能启动一个resin实例(未解)
<http address="*" port="8444">
<jsse-ssl self-signed-certificate-name="resin@localhost"/>
</http>
2,上面那两个软件windows中不能安装,会报异常,改成以下配置,
server 127.0.0.1:8080 ;
server 127.0.0.1:8081;
}
session replication 策略是复制会话,即一个用户访问了一次就把session复制到所有的服务器或这一部分服务器。
这样的好处是如果正访问的服务器down了 用户可以自动被转到别的服务器session不丢失。缺点当然是效率低。
session sticky策略则是不复制,一个用户访问了一次后,同一个session周期内,所有的请求都定向到这个服务器,
down了session就丢了。
3,启动不同服务名称的resin实例时,要到命令行去,不然不知道启动哪个,报异常。 到
resin4.0.23+nginx1.1集群的更多相关文章
- Hadoop 3.1.2(HA)+Zookeeper3.4.13+Hbase1.4.9(HA)+Hive2.3.4+Spark2.4.0(HA)高可用集群搭建
目录 目录 1.前言 1.1.什么是 Hadoop? 1.1.1.什么是 YARN? 1.2.什么是 Zookeeper? 1.3.什么是 Hbase? 1.4.什么是 Hive 1.5.什么是 Sp ...
- 超详细!CentOS 7 + Hadoop3.0.0 搭建伪分布式集群
超详细!CentOS 7 + Hadoop3.0.0 搭建伪分布式集群 ps:本文的步骤已自实现过一遍,在正文部分避开了旧版教程在新版使用导致出错的内容,因此版本一致的情况下照搬执行基本不会有大错误. ...
- spark1.1.0部署standalone分布式集群
配置三个节点的spark集群,集群模式为standalone模式,其中sp1节点作为主节点,sp2节点和sp3节点为从节点.***注意所有操作均为root用户. 创建3个CentOS虚拟机,如下: s ...
- hadoop2.2.0的ha分布式集群搭建
hadoop2.2.0 ha集群搭建 使用的文件如下: jdk-6u45-linux-x64.bin hadoop-2.2.0.x86_64.tar zookeeper-3.4.5. ...
- Apache Spark 2.2.0 中文文档 - 集群模式概述 | ApacheCN
集群模式概述 该文档给出了 Spark 如何在集群上运行.使之更容易来理解所涉及到的组件的简短概述.通过阅读 应用提交指南 来学习关于在集群上启动应用. 组件 Spark 应用在集群上作为独立的进程组 ...
- MongoDB 4.0 开发环境搭建集群
环境准备 Liunx 服务器一台 以下示例为单机版安装集群, 没有分片 MongoDB 安装 1.下载 MongoDB tgz 安装包: 可以从下载中心下载: https://www.mongodb. ...
- redis 5.0.3 讲解、集群搭建
REDIS 一 .redis 介绍 不管你是从事Python.Java.Go.PHP.Ruby等等... Redis都应该是一个比较熟悉的中间件.而大部分经常写业务代码的程序员,实际工作中或许只用到了 ...
- mongodb之 3.4.0 mongodb sharing 副本集群搭建
系统系统 centos6.5三台服务器:10.100.25.42/43/44安装包: mongodb-linux-x86_64-rhel62-3.4.0.tgz 服务器规划:mongos mongos ...
- hadoop-2.6.0.tar.gz的集群搭建(3节点)(不含zookeeper集群安装)
前言 本人呕心沥血所写,经过好一段时间反复锤炼和整理修改.感谢所参考的博友们!同时,欢迎前来查阅赏脸的博友们收藏和转载,附上本人的链接http://www.cnblogs.com/zlslch/p/5 ...
随机推荐
- 【Unity】3.0 第3章 创建和导入3D模型
分类:Unity.C#.VS2015 创建日期:2016-04-02 一.简介 利用Unity内置的基本模型和工具,不需要借助任何其他的三维建模软件,就可以直接创建出各种3D模型,这是这一章我们首先学 ...
- android 自己定义视频播放器之2/1
非常久没更新博客,相信大家年后都比較忙. 今天给大家带来了一款视频播放器,首先确认的得有几点. 1.首先得有个播放视频的view. 2.加点额外功能进去左边上下滑动调节亮度,右边上下滑动调节声量: 3 ...
- u3d中的INput
属性 属性: 功能: 轴 (Axes) 包含当前工程的所有定义的输入轴:数目 (Size) 该工程中不同输入轴的数量,元素 0.1.... 是要修改的特定的轴. 名称 (Name) 在游戏启动器中以及 ...
- WeakReference 学习和使用
本文转自:http://qifuguang.me/2015/09/02/[Java%E5%B9%B6%E5%8F%91%E5%8C%85%E5%AD%A6%E4%B9%A0%E4%B8%83]%E8% ...
- TNS-12518,TNS-12536,TNS-00506,Linux Error: 11: Resource temporarily unavailable
TNS-12518: TNS:listener could not hand off client connection TNS-12536: TNS:operation would block T ...
- BAT-增加JAVA环境变量(WIN764位)
相关资料:1.http://www.jb51.net/article/52756.htm2.http://blog.csdn.net/fireghost57/article/details/21103 ...
- [转]mysql中的字符串的拼接
字符串的拼接 1,Mysql 在Java.C#等编程语言中字符串的拼接可以通过加号“+”来实现,比如:"1"+"3"."a"+"b ...
- 前端常用功能记录(三)—datatables表格初始化(转)
数据源 我经常使用的有两种,一种是JavaScript 中的数组,通过在初始化对象中传递一个名为 aaData 的数组,同样可以提供表格数据,前缀 aa 说明这是一个数组的数组,外层的数组表示表格的行 ...
- 【WPF】使用CefSharp嵌入HTML网页
需求:WPF项目中要做用户的商铺主页,由于考虑到每个商家的主页布局各不相同,不能用XAML写死布局.最好的办法是WPF这边XAML写好一个容器,用户使用HTML可视化编辑器(比如这个)来准备好网页,输 ...
- WPF使用socket实现简单聊天软件
公司网络限制不能传文件,先贴部分代码 控件添加到界面就行,界面随意布局 项目结构: 1.解决方案 1.1. Client 1.2. Server Client: <Window x:Class= ...