求刺骨by酸菜坛子bl文库 by殇绝天下《制定公馆》全文百度云

博客访问: 155871
博文数量: 69
博客积分: 2802
博客等级: 少校
技术积分: 614
注册时间:
IT168企业级官微
微信号:IT168qiye
系统架构师大会
微信号:SACC2013
分类: 架构设计与优化
原文地址: 作者:
由于技术研发部在开发三期业务时没有考虑到与二期业务的兼容性,为了保证三期业务上线时不影响二期用户客户端的使用,需要在同一tomcat下部署两个工程。但由于这两个工程之间需要相互调用,据博主测试这两个工程如果再同一端口下运行时总会有一个工程无法正常请求另一个工程的业务(研发部门未经测试直接交付实施上线【太可怕了】),所以在部署业务时,笔者为了保证业务按时上线采用了在一个Tomcat配置多个端口号以对应不同服务完成业务的正常交付。
一、在Tomcat下配置多个服务,用不同的端口号。下面以增加1个端口号为例&。具体实施步骤如下所示:
第一步、修改 vi /webapp/tomcat6/conf/server.xml文件
具体修改内容如下:
&&& <Resource
name="UserDatabase" auth="Container"
&&&&&&&&&&&&&
type="org.apache.catalina.UserDatabase"
&&&&&&&&&&&&&
description="User database that can be updated and saved"
&&&&&&&&&&&&&
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
&&&&&&&&&&&&&
pathname="conf/tomcat-users.xml" />
&&& <Connector
port="8080" protocol="HTTP/1.1"
&&&&&&&&&&&&&&
connectionTimeout="20000"
&&&&&&&&&&&&&&
redirectPort="8443" />
&&&&& <Realm
className="org.apache.catalina.realm.UserDatabaseRealm"
&&&&&&&&&&&&
resourceName="UserDatabase"/>
&&&&& <Host
name="localhost"&
appBase="webapps"
&&&&&&&&&&&
unpackWARs="true" autoDeploy="true"
&&&&&&&&&&&
xmlValidation="false" xmlNamespaceAware="false">
&&& <Connector
port="8090" protocol="HTTP/1.1"
&&&&&&&&&&&&&&
connectionTimeout="20000"
&&&&& &&&&&&&&&redirectPort="8443" />
&&&&& <Realm
className="org.apache.catalina.realm.UserDatabaseRealm"
&&&&&&&&&&&&
resourceName="UserDatabase"/>
&&&&& <Host
name="localhost"&
appBase="webapp"
&&&&&&&&&&&
unpackWARs="true" autoDeploy="true"
&&&&&&&&&&&
xmlValidation="false" xmlNamespaceAware="false">
第二步、在/webapp/tomcat6创建相应的部署目录&
[root@localhost
tomcat6]# mkdir webapp
同时将工程发布到的新建的部署目录&中
第三步、创建配置文件目录和配置文件&
1)进入相应目录
&[root@localhost tomcat6]# cd /webapp/tomcat6/conf
2)创建目录
&[root@localhost conf]# mkdir Catalinai
3)拷贝配置文件
[root@localhost
conf]# cp -r ./Catalina/localhost/ ./Catalinai
4)验证以上操作的正确性
[root@localhost
conf]# cd Catalinai/
&[root@localhost Catalinai]# cd localhost/
[root@localhost
localhost]# pwd
/webapp/tomcat6/conf/Catalinai/localhost
[root@localhost
localhost]# ls
host-manager.xml& manager.xml
第四步、重启tomcat服务并验证相应端口服务已经正常运行
1)&&&&& lsof
2)&&&&& lsof
如果返回相应java进程则证明配置无误。
二、附tomcat前端Nginx代理相关的调整和配置
##以下为测试环境下Nginx配置文件的详细内容,关键配置点参见蓝色标注的文字亲
worker_processes& 2;
error_log&&
/usr/local/nginx/logs/error.
#error_log& logs/error.log&
#error_log& logs/error.log&
pid&&&&&&&
/usr/local/nginx/logs/nginx.
worker_connections& 65535;
&&& server_
&&& include&&&&&& mime.
&&& default_type& application/octet-
&&& #include
/usr/local/nginx/conf/proxy.
&&& #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&
&&& server_names_hash_bucket_size
&&& client_header_buffer_size 32k;
&&& large_client_header_buffers 8
&& # client_max_body_size 8m;
&&& sendfile&&&&&&&
&&& #tcp_nopush&&&&
&&& #keepalive_timeout& 0;
&&& keepalive_timeout& 65;
&&& #gzip&
&&& proxy_connect_timeout 5;
&&& proxy_read_timeout 60;
&&& proxy_send_timeout 5;
&&& proxy_buffer_size 16k;
&&& proxy_buffers 4 64k;
&&& proxy_busy_buffers_size 128k;
&&& proxy_temp_file_write_size
&&& proxy_temp_path
/usr/local/nginx/
&&& proxy_cache_path
/usr/local/nginx/cache levels=1:2 keys_zone=cache_one:200m inactive=1d
max_size=30g;
#&&& upstream 124.128.153.56 {
#&&&&&&&&&&&&&&&&&&&&&&&&&&
#&&&&&&&&&&&&&&&&&&&&&&&&&& server
http://10.0.211.5/sdws/;
#&&&&&&&&&&&&&&&&&&&&&&&&&& server
http://10.0.211.6/sdws/;
#&&&&&&&&&&&&&&&&&&&&&&&&&&& }
&& &server {
&&&&&&& listen&&&&&& 80;
&&&&&&& server_name&
&&&&&&& #charset koi8-r;
&&&&&&& charset utf-8;
&&&&&&& index index.html index.htm index.jsp
&&&&&&& #access_log& logs/host.access.log&
&&&&&&& root /webapp/tomcat6/webapps/
&&&&&&& location ~.*\.(jsp|do|action)$&&&&&&&&&&&&&&&&&&&&&& #设置动态数据的请求url
&&&&&&& index index.
&&&&&&& proxy_pass http://localhost:8080; #动态请求转向处理
&&&&&&& proxy_set_header&&&&&&& Host $
&&&&&&& proxy_set_header&&&&&&& X-Real-IP $remote_
&&&&&&& proxy_set_header&&&&&&& X-Forwarded-For
$proxy_add_x_forwarded_
&&&&&&& location
~.*\.(gif|jpg|jpeg|png|bmp|swf|html)$ #静态数据保存时效
&&&&&&&&&&&&& proxy_pass http://localhost:8080;
&&&&&&&&&&&&& proxy_
&&&&&&&proxy_set_header Host
&&&&&&&&&&&&& proxy_cache cache_
&&&&&&&&&&&&& proxy_cache_valid 200 302 1h;
&&&&&&&&&&&&& proxy_cache_valid 301 1d;
&&&&&&&&&&&&& proxy_cache_valid any 1m;
&&&&&&&&&&&&& expires 30d;
&&&&&&& location ~.*\.(js|css)?$&& #js和css保存时效
&&&&&&&& expires 1h;
location ~(favicon.ico)&
&&&&&&&& log_not_
&&&&&&&& expires 30d;
location /status& #统计Nginx运行状态
&&&&&&& stub_
&&&&&&& access_log
/usr/local/nginx/logs/status.
&&&&&&& auth_basic "NginxStatus";
&&&&&&& allow 10.0.209.0/24;
&&&&& #location / {
&&&&& #&&&&& root&&
&&&&& #&&&&& index&
index.html index.
&&&&& #& }
&&&&&&& error_page& 404&&&&&&&&&&&&& /404.
&&&&&&& # redirect server error
pages to the static page /50x.html
&&&&&&& error_page&& 500 502 503 504& /50x.
&&&&&&& location = /50x.html {
&&&&&&&&&&& root&&
&&&&&&& # 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&&&&&&&&&&
&&&&&&& #&&& fastcgi_pass&& 127.0.0.1:9000;
&&&&&&& #&&& fastcgi_index& index.
&&&&&&& #&&& fastcgi_param& SCRIPT_FILENAME& /scripts$fastcgi_script_
&&&&&&& #&&& include&&&&&&& fastcgi_
&&&&&&& #}
&&&&&&& # deny access to .htaccess
files, if Apache's document root
&&&&&&& # concurs with nginx's one
&&&&&&& #location ~ /\.ht {
&&&&&&& #&&& deny&
&&&&&&& #}
##add by fengzhanhai 3qiwangluotai
&&&&&&& listen&&&&&& 81;
&&&&&&& server_name&
&&&&&&& #charset koi8-r;
&&&&&&& charset utf-8;
&&&&&&& index index.html index.htm index.jsp
&&&&&&& #access_log& logs/host.access.log&
&&&&&&& root /webapp/tomcat6/webapp/mbp/;
&&&&&&& location ~.*\.(jsp|do|action)$&&&&&&&&&&&&&&&&&&&&&& #设置动态数据的请求url
&&&&&&& index index.
# root /webapp/tomcat6/webapps/mbp/;
&&&&&&& proxy_pass http://localhost:8090;#动态请求转向处理
&&&&&&& proxy_set_header&&&&&&& Host $
&&&&&&& proxy_set_header&&&&&&& X-Real-IP $remote_
&&&&&&& proxy_set_header&&&&&&& X-Forwarded-For
$proxy_add_x_forwarded_
&&&&&&& location
~.*\.(gif|jpg|jpeg|png|bmp|swf|html)$ #静态数据保存时效
&&&&&&&&&&&&& proxy_pass http://localhost:8090;
&&&&&&&&&&&& # root
/webapp/tomcat6/webapps/mbp/;
&&&&&&&&&&&&& proxy_
&&&&&&&&&&&&& proxy_set_header Host $
&&&&&&&&&&&&& proxy_cache cache_
&&&&&&&&&&&&& proxy_cache_valid 200 302 1h;
&&&&&&&&&&&&& proxy_cache_valid 301 1d;
&&&&&&&&&&&&& proxy_cache_valid any 1m;
&&&&&&&&&&&&& expires 30d;
&&&&&&& location ~.*\.(js|css)?$&& #js和css保存时效
&&&&&&&& expires 1h;
location ~(favicon.ico)
&&&&&&&& log_not_
&&&&&&&& expires 30d;
&&& # another virtual host using
mix of IP-, name-, and port-based configuration
&&& #server {
&&& #&&& listen&&&&&&
&&& #&&& listen&&&&&&
somename:8080;
&&& #&&& server_name&
somename& alias& another.
&&& #&&& location / {
&&& #&&&&&&& root&&
&&& #&&&&&&& index&
index.html index.
&&& #&&& }
&&& server {
&&&&&&& listen&&&&&& 82;
&&&&&&& server_name&
&&&&&&& #charset koi8-r;
&&&&&&& #access_log& logs/host.access.log&
&&&&&&& location / {
&&&&&&&&&&&&&& proxy_pass
http://127.0.0.1:8080/sdws/;
&&&&&&&&&&&&&& proxy_set_header
&&&&&&&&&&&&&& proxy_set_header
X-Forwarded-For $proxy_add_x_forwarded_
&&&&&&& #error_page& 404&&&&&&&&&&&&& /404.
&&&&&&& # redirect server error
pages to the static page /50x.html
&&&&&&& error_page&& 500 502 503 504& /50x.
&&&&&&& location = /50x.html {
&&&&&&&&&&& root&&
&&&&&&& location ~
.*\.(gif|jpg|jpeg|png|bmp|swf)$
&&&&&&&& root
/webapp/tomcat6/webapps/
&&&&&&&& if (-f $request_filename)
&&&&&&&&& expires 1d;
&&&&&&&&& }
&&&&&&&& }
&&&&&& location ~ .*\.(js|css)$
&&&&&&&& root
/webapp/tomcat6/webapps/;
&&&&&&&& if (-f $request_filename)
&&&&&&&&& expires 1d;
&&&&&&&&& }
&&&&&&&& }
####################################################################################
#&&& server {
#&&&&&&& listen &&&&&&811;
#&&&&&&& server_name&
#&&&&&&& #charset koi8-r;
#&&&&&&& #access_log& logs/host.access.log&
#&&&&&&& location / {
#&&&&&&&&&&&&&& proxy_pass
http://127.0.0.1:8080/mbp/;
#&&&&&&&&&&&&&& proxy_set_header
#&&& &&&&&&&&&&&proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_
#&&&&&&& }
#&&&&&&& #error_page& 404&&&&&&&&&&&&& /404.
&#&&&&&& # redirect server error pages to the
static page /50x.html
& #&&&&& error_page&& 500 502 503 504& /50x.
&& #&&&& location = /50x.html {
&&& #&&&&&&& root&&
&&&& #&& }
&&&&& #& location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
&&&&&& # {
&&&&&&& # root
/webapp/tomcat6/webapps/
&&&&&&& # if (-f
$request_filename) {
&&&&&&&& # expires 1d;
&&&&&&&&& #
&&&&&&&& # }
&&&&&&& # }
&&&&&& #location ~ .*\.(js|css)$
&&&&&&& #{
&&&&&&& # root
/webapp/tomcat6/webapps/
&&&&&&& # if (-f
$request_filename) {
&&&&&&& #& expires 1d;
&&&&&&& #&
&&&&&&& #& }
&&&&&&& # }
#add by fengzhanhai
&&&&&&&&&&& server {
&&&&&&&&&&&&&&& listen&&&&&& 810;
&&&&&&&& &&&&&&&server_name&
&&&&&&&&&&&&&&& #charset koi8-r;
&&&&&&&&&&&&&&& #access_log& logs/host.access.log&
&&&&&&&&&&&&&&& location / {
&&&&&&&&&&&&&&&&&&&&&& proxy_pass
http://127.0.0.1:8080/mbp/;
&&&&&&&&&&&&&&&&&&&&&&
proxy_set_header Host&&& $
&&&&&&&&&&&&&&&&&&&&&&
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_
&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&& #error_page& 404&&& &&&&&&&&&&/404.
&&&&&&&&&&&&&&& # redirect server
error pages to the static page /50x.html
&&&&&&&&&&&&&&& #
&&&&&&&&&&&&&&& error_page&& 500 502 503 504& /50x.
&&&&&&&&&&&&&&& location =
/50x.html {
&&&&&&&&&&&&&&&&&&& root&&
&&&&&&&&&&& &&&&}
&&&&&&&&&&&&&&& location ~
.*\.(gif|jpg|jpeg|bmp|swf|png)$
&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&& root
/webapp/tomcat6/webapps/
&&&&&&&&&&&&&&& #
http://127.0.0.1:8080/sdmp3
&&&&&&&&&&&&&&&& if (-f
$request_filename) {
&&&&&&&&&&&&&&&& expires 1d;
& &&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&&& location ~
.*\.(js|css)$
&&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&&
#http://127.0.0.1:8080/sdmp3
&&&&&&&&&&&&&&&& root
/webapp/tomcat6/webapps/;
&&&&&&&&&&&&&&&& if (-f $request_filename)
&&&&&&&&&&&&&&&& expires 1d;
&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&&& location
~(favicon.ico)&
&&&&&&&&&&&&&&& {
&&&&&&&&&&&&&&&& log_not_found
&&&&&&&&&&&&&&&& expires 30d;
&&&&&&&&&&&&&&&&
&&&&&&&&&&&&&&& }
&&&&&&&&&&&&&&&& }
阅读(15670) | 评论(0) | 转发(0) |
下一篇:没有了
相关热门文章
给主人留下些什么吧!~~
请登录后评论。水善几于道 的BLOG
用户名:水善几于道
文章数:36
访问量:18877
注册日期:
阅读量:5863
阅读量:12276
阅读量:401852
阅读量:1091423
51CTO推荐博文
一、环境:Nginx+tomcat+mysql&&&&&&&&Nginx&&& &&&&&&&192.168.1.200&& web+负载均衡&&&&&&&&Tomcat(A) &&&192.168.1.210&& web应用&&&&&&&&Tomcat(B)&&& 192.168.1.211&& web应用&&&&&&&&Mysql(master)192.168.1.230&& 主从复制,数据库&&&&&&&&Mysql(slava)192.168.1.231&& 主从复制,数据库& 测试域名& abc.com&&二、部署思路&&&&&&& Nginx服务器反向代理所有请求,由Nginx服务器负载均衡到Tomcat(A)服务器(192.168.1.210)与Tomcat(B)服务器(192.168.1.211)上。&&三、Nginx:安装及配置&&&&&&&&yum&-yinstall&gcc&gcc-c++&autoconf&automake&&&&&&&&yum&-yinstall&zlib&zlib-devel&openssl&openssl-devel&pcre-devel&&&&&&&&groupadd&-r&nginx;useradd&-r&-g&nginx&nginx&&&&&&&&&./configure&--prefix=/usr/local/nginx&&--sbin-path=/usr/sbin/nginx&&--conf-path=/etc/nginx/nginx.conf&&&&&&&&&make&&&&make&install&&&&&&&&从网上搜个nginx启动脚本,vim /etc/rc.d/init.d/nginx,粘贴进去&&&&&&&&&&&&添加执行权限 chmod +x/etc/rc.d/init.d/nginx&&&&修改启动项& chkconfig --add nginx&&&&添加开机自动启动 chkconfig nginx on&&&&启动服务 service nginx start&&&&&&&&编辑nginx配置文件& /etc/nginx/nginx.conf&&&&upstream&&{
&&&&&&&&&&server&192.168.1.210:8080;
&&&&&&&&&&server&192.168.1.211:8080;
&&&&&&&&location&/&{
&&&&&&&&&&&&&&&&proxy_pass&http://myCluster&;
&&&&&&&&&&&&&&&&proxy_redirect&
&&&&&&&&&&&&&&&&proxy_set_header&Host&$
&&&&&&&&&&&&&&&&proxy_set_header&X-Real-IP$remote_
&&&&&&&&&&&&&&&&proxy_set_headerX-Forwarded-For&$proxy_add_x_forwarded_
&&&&&&&&&}&&&&&&&&&&& & # 注,如果实现session保持可以使用nginx的ip_hash模块,将ip_hash添加在upstream中即可四、JDK和tomcat安装&&&&tar&xf&apache-tomcat-7.0.57.tar.gzCC&/usr/local/tomcat&&&&tar&xf&jdk-7u80-ea-bin-b03-linux-i586-19_nov_2014.tar.gzCC&/usr/local/jdk1.7.0_80&&&&vim&/etc/profile
&&&&JAVA_HOME=/usr/local/jdk1.6.0_12
&&&&PATH=$JAVA_HOME/bin:$PATH
&&&&CLASS_PATH=$JAVA_HOME/lib:$JAVA_HOME/jre/lib
&&&&export&JAVA_HOME&PATH&CLASS_PATH&
&&&&.&/etc/profile&&&&cp&/usr/local/tomcatbin/startup.sh&/etc/rc.d/init.d/tomcat.sh&&&&chkconfig&--add&tomcat&&&&chkconfig&tomcat&on&&&&service&tomcat&start五、mysql主从复制mysql主从复制原理:主服务器记录二进制日志,从服务器分别以命令模式和行模式进行执行和复制;所以主从服务器都要开启二进制日志。1.配置主服务器&&&&vim&/f
&&&&[mysqld]
&&&&log-bin=/var/log/mysql/mysql-bin.log&&&#&日志路径
&&&&server-id=230&&&&&&&#&服务ID,我理解是用于多服务区分,网内唯一&&&&配置完之后重启mysqld,登录主服务器mysql给从服务器用户授权&&&&mysql&&GRANT&REPLICATION&SLAVE&ON&*.*&to&'myuser'@'192.168.1.231'&IDENTIFIED&BY&'mypass';&&& 2.配置从服务器&&&&vim&/f
&&&&[mysqld]
&&&&log-bin=/var/log/mysql/mysql-bin.log&&&
&&&&server-id=231&&& 配置完成后重启mysqld,登录从服务器启动slave&&&&&mysql&start&&&&&主从配置完成,这时候可以通过修改主服务器的表、库信息来测试,&&&&还可以对比查看 show master status\G;和show slave status\G& 信息&&&&这是线下的测试环境安装,如果线上的配置还需要锁表、数据文件复制等操作。本文出自 “” 博客,请务必保留此出处
了这篇文章
类别:┆阅读(0)┆评论(0)

我要回帖

更多关于 百年不合by北南bl文库 的文章

 

随机推荐