1、nginx作为负载均衡的入口,修改nginx.conf
user administrator;
worker_processes 4;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
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;
upstream localhost{
server 10.197.0.26:8086 weight=2;
server 10.197.0.26:8087 weight=1;
}
server {
listen 80;
server_name xxx.xxxx.com;
charset utf-8;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
proxy_pass http://localhost;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
}
#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;
}
}
}
2、两个或多个Tomcat的配置(tomcat可在不同局域网ip的机器上)
a、机器环境配置,让两个Tomcat能同时在一台机器上运行
修改环境变量path
修改startup.bat shutdown.bat
将其中一个tomcat的环境变量CATALINA_BASE和CATALINA_HOME改成对应路径的变量
b、Tomcat负载均衡配置
在路径 D:\apache-tomcat-7.0.58\conf下的context.xml的redis配置
给tomcat下的lib增加三个jar包 D:\apache-tomcat-7.0.58\lib
网友评论