링크 ux 하 nginx tomcat 클 러 스 터
11037 단어 tomcat 군집
, 。
, , 、 。 , 。 tomcat 。
, nginx pcre jvm-remote 。
、 :
1、nginx-1.1.2.tar.gz, / , http://nginx.org/en/download.html 。
2、pcre-8.10.tar.gz, , http://sourceforge.net/projects/pcre/ ;
3、nginx-upstream-jvm-route-0.1.tar.gz, Nginx , Cookie Session Sticky , http://code.google.com/p/nginx-upstream-jvm-route/downloads/list ;
、
1、
[root@localhost ~]# tar zxvf pcre-8.10.tar.gz
[root@localhost ~]# tar zxvf nginx-upstream-jvm-route-0.1.tar.gz
[root@localhost ~]# tar nginx-1.1.2.tar.gz
2、
[root@localhost ~]# cd nginx-1.1.2
[root@localhost ~]# patch -p0 < ${nginx-upstream-jvm-route }/jvm_route.patch
[root@localhost ~]# ./configure --prefix=/usr/local/nginx --with-pcre=${pcre } --with-http_stub_status_module --with-http_ssl_module --add-module=${nginx-upstream-jvm-route }
[root@localhost ~]# make
[root@localhost ~]# make install
、
1、 tomcat server.xml, tomcat :
<Engine name="Catalina" defaultHost="localhost" >
:
Tomcat01:
<Engine name="Catalina" defaultHost="localhost" jvmRoute="a">
Tomcat02:
<Engine name="Catalina" defaultHost="localhost" jvmRoute="b">
Tomcat03:
<Engine name="Catalina" defaultHost="localhost" jvmRoute="c">
2、 nginx nginx.conf
# NGINX
user root;
#nginx , cpu , , 10M
worker_processes 1;
#
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
# epoll I/O
use epoll;
# , ulimit -n
worker_connections 24;
}
http {
# , IP: srun_id tomcat jvmRoute
upstream backend{
server2.168.12.128:18080 srun_id=a;
server2.168.12.128:28080 srun_id=b;
server2.168.12.128:38080 srun_id=c;
jvm_route $cookie_JSESSIONID|sessionid reverse;
}
include mime.types;
# , , PHP , ,
default_type application/octet-stream;
charset UTF-8;
server_names_hash_bucket_size8;
client_header_buffer_sizek;
large_client_header_buffers 4k;
client_max_body_sizem;
limit_rate24k;
sendfile on;
tcp_nopush on;
keepalive_timeout;
tcp_nodelay on;
fastcgi_connect_timeout0;
fastcgi_send_timeout0;
fastcgi_read_timeout0;
fastcgi_buffer_sizek;
fastcgi_buffers 4k;
fastcgi_busy_buffers_size8k;
fastcgi_temp_file_write_size8k;
gzip on;
#gzip_min_length 1k;
gzip_buffers 4k;
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_addrm;
server {
listen ;
server_name 2.168.12.128; # ,
index index.html index.htm index.jsp;
charset UTF-8;
root /usr/local/tomcats/project/;# , ( ), web project
#access_log logs/host.access.log main;
# ,yourproject
location /yourproject/ {
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;
index index.html index.htm index.jsp;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expiresd;
}
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';
error_page 4 /404.html;
error_page 0234 /50x.html;
location = /50x.html {
root html;
}
}
}
3、 nginx
[root@localhost ~]# /usr/local/nginx/sbin/nginx -t -c /usr/nginx/conf/nginx.conf
、
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
/usr/local/tomcats/tomcat-a/bin/startup.sh
/usr/local/tomcats/tomcat-b/bin/startup.sh
/usr/local/tomcats/tomcat-c/bin/startup.sh
/usr/local/tomcats/tomcat-a/bin/shutdown.sh
/usr/local/tomcats/tomcat-b/bin/shutdown.sh
/usr/local/tomcats/tomcat-c/bin/shutdown.sh
pkill -9 nginx