Linux软件安装
一、 Pcre+nginx + nginx_upstream_jvm_route安装
a.安装pcre
tar zxvf pcre-7.2.tar.gz
cd pcre
./configure –prefix = /pcre
Make;make install
b,安装nginx
tar zxvf nginx-0.6.32.tar.gz
cd nginx-0.6.32
#patch -p0 < ./nginx-upstream-jvm-route-read-only/jvm_route.patch
./configure –prefix=/nginx –with-pcre=/pcre –with-http_rewrite_module –add-module=/root/nginx-upstream-jvm-route-read-only
#make;
#make install
二、 修改nginx.conf文件
修改成以下内容:
#user nobody;
worker_processes 5;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
use epoll;
worker_connections 2048;
}
http {
upstream backend {
server localhost:8087 invalid=web_tomcat2; #负载均衡服务器
server localhost:8088 invalid=web_tomcat1; #负载均衡服务器
jvm_route $cookie_JSESSIONID|sessionid reverse;
}
include mime.types;
default_type application/octet-stream;
charset UTF-8;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 20m;
limit_rate 1024k;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
#limit_zone crawler $binary_remote_addr 10m;
server {
listen 80;
server_name localhost;
index index.jsp index.htm index.html;
root /usr/local/program/xhxw_web;
#access_log logs/host.access.log main;
location / {
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 ~ .*\.(htm|html|ico|gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
location /Nginxstatus {
stub_status on;
access_log off;
}
log_format access ‘$remote_addr – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” $http_x_forwarded_for';
#access_log off;
}
server {
listen 80;
server_name cms.xhxw.com;
index index.jsp index.htm index.html;
root /usr/local/program/xhxw;
#access_log logs/host.access.log main;
location / {
proxy_pass http://localhost:8058;
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;
}
}
}
测试 配置文件是否有错 /usr/local/nginx/sbin/nginx –t
如果出现:
the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
configuration file /usr/local/nginx/conf/nginx.conf test is successful
说明配置成功
三、 Tomcat配置文件修改
修改server.xml
在 <Engine name=”Catalina” defaultHost=”localhost”> 加上 jvmRoute=”web_tomcat1″
添加后:<Engine name=”Catalina” defaultHost=”localhost” jvmRoute=”web_tomcat1″>。
在 <Engine name=”Catalina” defaultHost=”localhost” jvmRoute=”web_tomcat1″>下面添加
<Cluster className=”org.apache.catalina.ha.tcp.SimpleTcpCluster”
channelSendOptions=”8″>
<Manager className=”org.apache.catalina.ha.session.DeltaManager”
expireSessionsOnShutdown=”false”
notifyListenersOnReplication=”true”/>
<Channel className=”org.apache.catalina.tribes.group.GroupChannel”>
<Membership className=”org.apache.catalina.tribes.membership.McastService”
address=”224.0.0.4″
port=”45564″
frequency=”500″
dropTime=”3000″/>
<Receiver className=”org.apache.catalina.tribes.transport.nio.NioReceiver”
address=”auto”
port=”4001″
autoBind=”100″
selectorTimeout=”5000″
maxThreads=”6″/>
<!– timeout=”60000″–>
<Sender className=”org.apache.catalina.tribes.transport.ReplicationTransmitter”>
<Transport className=”org.apache.catalina.tribes.transport.nio.PooledParallelSender” />
</Sender>
<Interceptor className=”org.apache.catalina.tribes.group.interceptors.TcpFailureDetector”/>
<Interceptor className=”org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor”/>
<Interceptor className=”org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor”/>
</Channel>
<Valve className=”org.apache.catalina.ha.tcp.ReplicationValve”
filter=””/>
<Valve className=”org.apache.catalina.ha.session.JvmRouteBinderValve”/>
<Deployer className=”org.apache.catalina.ha.deploy.FarmWarDeployer”
tempDir=”/tmp/war-temp/”
deployDir=”/tmp/war-deploy/”
watchDir=”/tmp/war-listen/”
watchEnabled=”false”/>
<ClusterListener className=”org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener”/>
<ClusterListener className=”org.apache.catalina.ha.session.ClusterSessionListener”/>
</Cluster>
多个tomcat的话一定要修改 成不同的port .port=”4001″
需要修改程序web.xml ,</web-app>前面加入以下这句话
<distributable/>
session同步到这里设置完毕