|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
欢迎大家来到仓酷云论坛!如今盛行的JavaEE容器有良多:Tomcat、Resin、JBoss、Glassfish等,我们经常使用的次要是前三种,那这个java容器功能方面究竟谁更不乱,并发才能更强呢?那当属resin了,resin官方公布了最新版本4.0.33版,号称并发超出apache,不但撑持jsp言语,还能撑持php。
我们之前年夜多用过tomcat,晓得tomcat假如要在一台呆板设置多个办事,只必要拷贝分歧的设置文件,然后设置分歧的端口就ok,比拟较而言,resin要想在一台呆板设置多个办事,就对照贫苦了,那明天我们一同来研讨一下。
1、体系情况- 体系情况:CentOS6.0x86_64Nginx版本:Nginx-1.2.6Resin版本:Resin-4.0.33JDK版本:JDK-1.6.0_18
复制代码
2、Nginx装置- #起首下载必要装置的软件:【JDK能够往java官网下载并装置】wgethttp://nginx.org/download/nginx-1.2.6.tar.gzwgethttp://www.caucho.com/download/resin-4.0.33.tar.gztarzxvfnginx-1.2.6.tar.gzcdnginx-1.2.6/./configure--user=www--group=www--add-module=../ngx_cache_purge-1.4--prefix=/usr/local/nginx--with-http_stub_status_module--with-http_ssl_modulemake&&makeinstall
复制代码
3、Resin装置- tarCxzvfresin-4.0.33.tar.gzcdresin-4.0.33&&./configure--prefix=/usr/local/resin--with-resin-log=/data/logs/resin/--with-java-home=/usr/java/jdk1.6.0_18/make&&makeinstall
复制代码
4、设置Resin- #cd/usr/local/resin/conf/下#增加以下代码,在本机设置两个实例端口为8080、8081<clusterid="app1"><!--definetheserversinthecluster--><server-multiid-prefix="app1"address-list="${app1_servers}"port="6800"/><!--thedefaulthost,matchinganyhostname--><hostid=""root-directory="."><web-appid="/"root-directory="/var/www/html/app1"/></host></cluster><clusterid="app2"><!--definetheserversinthecluster--><server-multiid-prefix="app2"address-list="${app2_servers}"port="6801"/><!--thedefaulthost,matchinganyhostname--><hostid=""root-directory="."><web-appid="/"root-directory="/var/www/html/app2"/></host></cluster>
复制代码
修正以后目次viresin.properties修正以下内容:- #app-tierTriadservers:app-0app-1app-2app1_servers:127.0.0.1:6800app2_servers:127.0.0.1:6801#Useoverridesforindividualservercontrol,forexample:app-0.http:8081app1.http:8080app2.http:8081
复制代码
设置分歧的端口,然后启动resin办事:- /usr/local/resin/bin/resinctlstart便可然后检察resin端口netstatCtnl我们会看到8080、8081端口
复制代码 5、设置Nginx
跟着Nginx高功能Web办事器大批被利用,今朝Nginx最新不乱版为1.2.6,张宴兄在实践使用中大批利用Nginx,并分享Nginx高功能Web办事器常识,使得Nginx在国际也是飞速的开展。那明天我们再来复习一下Nginx动态分别常识,这里仅供参考。
1、理论情况:- 体系版本:CentOS6.0X86_64Nginx版本:Nginx-1.2.6Tomcat版本:Tomcat-6.0.18
复制代码 2、Nginx装置:
实践情况中装置Nginx,起首必要装置pcre库,然后再装置Nginx:- #装置pcre撑持rewrite库,也能够装置源码,注*装置源码时,指定pcre路径为解压源码的路径,而不是编译后的路径,不然会报错。yuminstallpcre-develpcre-y#下载Nginx源码包cd/usr/src;wget-chttp://nginx.org/download/nginx-1.2.6.tar.gz#解压Nginx源码包tar-xzfnginx-1.2.6.tar.gz#进进解压目次,然后sed修正Nginx版本信息为TDTWScdnginx-1.2.6;sed-i-es/1.2.6//g-es/nginx//TDTWS/g-es/"NGINX"/"TDTWS"/gsrc/core/nginx.h#预编译Nginx./configure--user=www--group=www--prefix=/usr/local/nginx--with-http_stub_status_module--with-http_ssl_module#.configure预编译乐成后,实行make下令举行编译make#make实行乐成后,实行makeinstall正式装置makeinstall#自此Nginx装置终了!!!
复制代码 3、设置Nginx:
这里鉴于我的51CTO博客已有Tomcat装置和设置了,这里疏忽,只设置Nginx。- #进进Nginx使用目次cd/usr/local/nginx/conf#备份原nginx.conf文件mvnginx.confnginx.bak
复制代码 创立vinginx.conf,并写进以下内容:
[code]<olclass="dp-xmllist-paddingleft-2"><liclass="alt">userwwwwww;
worker_processes8;
<liclass="alt">worker_cpu_affinity0000000100000010000001000000100000010000001000000100000010000000;
pid/usr/local/nginx/nginx.pid;
<liclass="alt">
worker_rlimit_nofile102400;
<liclass="alt">
events
<liclass="alt">{
useepoll;
<liclass="alt">worker_connections102400;
}
<liclass="alt">http
{
<liclass="alt">includemime.types;
<liclass="alt">default_typeapplication/octet-stream;
<liclass="alt">fastcgi_intercept_errorson;
<liclass="alt">charsetutf-8;
<liclass="alt">server_names_hash_bucket_size128;
client_header_buffer_size4k;
<liclass="alt">large_client_header_buffers432k;
client_max_body_size300m;
<liclass="alt">
sendfileon;
<liclass="alt">tcp_nopushon;
<liclass="alt">keepalive_timeout60;
<liclass="alt">tcp_nodelayon;
<liclass="alt">client_body_buffer_size512k;
proxy_connect_timeout5;
<liclass="alt">proxy_read_timeout60;
proxy_send_timeout5;
<liclass="alt">proxy_buffer_size16k;
proxy_buffers464k;
<liclass="alt">proxy_busy_buffers_size128k;
proxy_temp_file_write_size128k;
<liclass="alt">
gzipon;
<liclass="alt">gzip_min_length1k;
gzip_buffers416k;
<liclass="alt">gzip_http_version1.1;
gzip_comp_level2;
<liclass="alt">gzip_typestext/plainapplication/x-javascripttext/CSSapplication/xml;
gzip_varyon;
<liclass="alt">
<liclass="alt">###2012-12-19changenginxlogs
<liclass="alt">log_formatmain$http_x_forwarded_for-$remote_user[$time_local]"$request"
$status$body_bytes_sent"$http_referer"
<liclass="alt">"$http_user_agent"$request_time$remote_addr;
<liclass="alt">
#这里为后端办事器wugk使用集群设置,依据后端实践情形修正便可,tdt_wugk为负载平衡称号,能够恣意指定
#但必需跟vhosts.conf假造主机的pass段分歧,不然不克不及转发后真个哀求。
<liclass="alt">upstreamtdt_wugk{
server10.10.141.30:8080weight=1max_fails=2fail_timeout=30s;
<liclass="alt">server10.10.141.30:8081weight=1max_fails=2fail_timeout=30s;
server10.10.141.31:8080weight=1max_fails=2fail_timeout=30s;
<liclass="alt">server10.10.141.31:8081weight=1max_fails=2fail_timeout=30s;
server10.10.141.32:8080weight=1max_fails=2fail_timeout=30s;
<liclass="alt">server10.10.141.32:8081weight=1max_fails=2fail_timeout=30s;
<liclass="alt">}
#这里为后端APP使用负载平衡设置,依据后端实践情形修正便可。tdt_app为负载平衡称号,能够恣意指定
<liclass="alt">upstreamtdt_app{
server10.10.141.40:8080weight=1max_fails=2fail_timeout=30s;
<liclass="alt">server10.10.141.40:8081weight=1max_fails=2fail_timeout=30s;
server10.10.141.41:8080weight=1max_fails=2fail_timeout=30s;
<liclass="alt">server10.10.141.41:8081weight=1max_fails=2fail_timeout=30s;
server10.10.141.42:8080weight=1max_fails=2fail_timeout=30s;
<liclass="alt"><p><spanstyle="padding:0px;margin:0px;border:none;color:black;background-color:inherit;">server10.10.141.42:8081weight=1max_fails=2 |
|