nginx+tomcat负载均衡搭建
一、 单独部署tomcat和nginx
Nginx版本:nginx-1.13.5
Tomcat版本:apache-tomcat-8.5.8
操作系统:win10
必须先部署一个tomcat服务器。Tomcat服务器部署好后,登录tomcat服务器:localhost:8080
显示如下界面,说明部署成功。关于tomcat的部署就不详细介绍了。
我下载的是nginx的解压版,直接解压就可以使用进入到解压目录,启动nginx服务器就可以了。
测试nginx是否部署成功。在浏览器地址栏:输入localhost。看到如下界面说明nginx部署成功。
下面在简单的结合下tomcat服务器。关键点来了。与tomcat的结合主要是要修改配置文件。配置文件在解压后根目录下的/conf中,找到nginx.conf文件。
查看默认配置文件的内容,一看都是英文不懂啊。那我们翻译下和看下nginx的文档。
- #user nobody;
- worker_processes ;
- #error_log logs/error.log;
- #error_log logs/error.log notice;
- #error_log logs/error.log info;
- #pid logs/nginx.pid;
- events {
- worker_connections ;
- }
- 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 ;
- keepalive_timeout ;
- #gzip on;
- server {
- listen ;
- server_name localhost;
- #charset koi8-r;
- #access_log logs/host.access.log main;
- location / {
- root html;
- index index.html index.htm;
- }
- #error_page /.html;
- # redirect server error pages to the static page /50x.html
- #
- error_page /50x.html;
- location = /50x.html {
- root html;
- }
- # proxy the PHP scripts to Apache listening on 127.0.0.1:
- #
- #location ~ \.php$ {
- # proxy_pass http://127.0.0.1;
- #}
- # pass the PHP scripts to FastCGI server listening on 127.0.0.1:
- #
- #location ~ \.php$ {
- # root html;
- # fastcgi_pass 127.0.0.1:;
- # fastcgi_index index.php;
- # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
- # include fastcgi_params;
- #}
- # deny access to .htaccess files, if Apache's document root
- # concurs with nginx's one
- #
- #location ~ /\.ht {
- # deny all;
- #}
- }
- # another virtual host using mix of IP-, name-, and port-based configuration
- #
- #server {
- # listen ;
- # listen somename:;
- # server_name somename alias another.alias;
- # location / {
- # root html;
- # index index.html index.htm;
- # }
- #}
- # HTTPS server
- #
- #server {
- # listen ssl;
- # server_name localhost;
- # ssl_certificate cert.pem;
- # ssl_certificate_key cert.key;
- # ssl_session_cache shared:SSL:1m;
- # ssl_session_timeout 5m;
- # ssl_ciphers HIGH:!aNULL:!MD5;
- # ssl_prefer_server_ciphers on;
- # location / {
- # root html;
- # index index.html index.htm;
- # }
- #}
- }
二、 Nginx.conf配置文件详解
Nginx的配置文件nginx.conf配置详解如下:引用的是cnsd上的帖子,链接地址:http://blog.csdn.net/tjcyjd/article/details/50695922
- user nginx nginx ;
- Nginx用户及组:用户 组。window下不指定
- worker_processes 8;
- 工作进程:数目。根据硬件调整,通常等于CPU数量或者2倍于CPU。
- error_log logs/error.log;
- error_log logs/error.log notice;
- error_log logs/error.log info;
- 错误日志:存放路径。
- pid logs/nginx.pid;
- pid(进程标识符):存放路径。
- worker_rlimit_nofile 204800;
- 指定进程可以打开的最大描述符:数目。
- 这个指令是指当一个nginx进程打开的最多文件描述符数目,理论值应该是最多打开文件数(ulimit -n)与nginx进程数相除,但是nginx分配请求并不是那么均匀,所以最好与ulimit -n 的值保持一致。
- 现在在linux 2.6内核下开启文件打开数为65535,worker_rlimit_nofile就相应应该填写65535。
- 这是因为nginx调度时分配请求到进程并不是那么的均衡,所以假如填写10240,总并发量达到3-4万时就有进程可能超过10240了,这时会返回502错误。
- events
- {
- use epoll;
- 使用epoll的I/O 模型。linux建议epoll,FreeBSD建议采用kqueue,window下不指定。
- 补充说明:
- 与apache相类,nginx针对不同的操作系统,有不同的事件模型
- A)标准事件模型
- Select、poll属于标准事件模型,如果当前系统不存在更有效的方法,nginx会选择select或poll
- B)高效事件模型
- Kqueue:使用于FreeBSD 4.1+, OpenBSD 2.9+, NetBSD 2.0 和 MacOS X.使用双处理器的MacOS X系统使用kqueue可能会造成内核崩溃。
- Epoll:使用于Linux内核2.6版本及以后的系统。
- /dev/poll:使用于Solaris 7 11/99+,HP/UX 11.22+ (eventport),IRIX 6.5.15+ 和 Tru64 UNIX 5.1A+。
- Eventport:使用于Solaris 10。 为了防止出现内核崩溃的问题, 有必要安装安全补丁。
- worker_connections 204800;
- 没个工作进程的最大连接数量。根据硬件调整,和前面工作进程配合起来用,尽量大,但是别把cpu跑到100%就行。每个进程允许的最多连接数,理论上每台nginx服务器的最大连接数为。worker_processes*worker_connections
- keepalive_timeout 60;
- keepalive超时时间。
- client_header_buffer_size 4k;
- 客户端请求头部的缓冲区大小。这个可以根据你的系统分页大小来设置,一般一个请求头的大小不会超过1k,不过由于一般系统分页都要大于1k,所以这里设置为分页大小。
- 分页大小可以用命令getconf PAGESIZE 取得。
- [root@web001 ~]# getconf PAGESIZE
- 4096
- 但也有client_header_buffer_size超过4k的情况,但是client_header_buffer_size该值必须设置为“系统分页大小”的整倍数。
- open_file_cache max=65535 inactive=60s;
- 这个将为打开文件指定缓存,默认是没有启用的,max指定缓存数量,建议和打开文件数一致,inactive是指经过多长时间文件没被请求后删除缓存。
- open_file_cache_valid 80s;
- 这个是指多长时间检查一次缓存的有效信息。
- open_file_cache_min_uses 1;
- open_file_cache指令中的inactive参数时间内文件的最少使用次数,如果超过这个数字,文件描述符一直是在缓存中打开的,如上例,如果有一个文件在inactive时间内一次没被使用,它将被移除。
- }
- ##设定http服务器,利用它的反向代理功能提供负载均衡支持
- http
- {
- include mime.types;
- 设定mime类型,类型由mime.type文件定义
- 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"';
- log_format log404 '$status [$time_local] $remote_addr $host$request_uri $sent_http_location';
- 日志格式设置。
- $remote_addr与$http_x_forwarded_for用以记录客户端的ip地址;
- $remote_user:用来记录客户端用户名称;
- $time_local: 用来记录访问时间与时区;
- $request: 用来记录请求的url与http协议;
- $status: 用来记录请求状态;成功是200,
- $body_bytes_sent :记录发送给客户端文件主体内容大小;
- $http_referer:用来记录从那个页面链接访问过来的;
- $http_user_agent:记录客户浏览器的相关信息;
- 通常web服务器放在反向代理的后面,这样就不能获取到客户的IP地址了,通过$remote_add拿到的IP地址是反向代理服务器的iP地址。反向代理服务器在转发请求的http头信息中,可以增加x_forwarded_for信息,用以记录原有客户端的IP地址和原来客户端的请求的服务器地址。
- access_log logs/host.access.log main;
- access_log logs/host.access.404.log log404;
- 用了log_format指令设置了日志格式之后,需要用access_log指令指定日志文件的存放路径;
- server_names_hash_bucket_size 128;
- #保存服务器名字的hash表是由指令server_names_hash_max_size 和server_names_hash_bucket_size所控制的。参数hash bucket size总是等于hash表的大小,并且是一路处理器缓存大小的倍数。在减少了在内存中的存取次数后,使在处理器中加速查找hash表键值成为可能。如果hash bucket size等于一路处理器缓存的大小,那么在查找键的时候,最坏的情况下在内存中查找的次数为2。第一次是确定存储单元的地址,第二次是在存储单元中查找键 值。因此,如果Nginx给出需要增大hash max size 或 hash bucket size的提示,那么首要的是增大前一个参数的大小.
- client_header_buffer_size 4k;
- 客户端请求头部的缓冲区大小。这个可以根据你的系统分页大小来设置,一般一个请求的头部大小不会超过1k,不过由于一般系统分页都要大于1k,所以这里设置为分页大小。分页大小可以用命令getconf PAGESIZE取得。
- large_client_header_buffers 8 128k;
- 客户请求头缓冲大小。nginx默认会用client_header_buffer_size这个buffer来读取header值,如果
- header过大,它会使用large_client_header_buffers来读取。
- open_file_cache max=102400 inactive=20s;
- 这个指令指定缓存是否启用。
- 例: open_file_cache max=1000 inactive=20s;
- open_file_cache_valid 30s;
- open_file_cache_min_uses 2;
- open_file_cache_errors on;
- open_file_cache_errors
- 语法:open_file_cache_errors on | off 默认值:open_file_cache_errors off 使用字段:http, server, location 这个指令指定是否在搜索一个文件是记录cache错误.
- open_file_cache_min_uses
- 语法:open_file_cache_min_uses number 默认值:open_file_cache_min_uses 1 使用字段:http, server, location 这个指令指定了在open_file_cache指令无效的参数中一定的时间范围内可以使用的最小文件数,如果使用更大的值,文件描述符在cache中总是打开状态.
- open_file_cache_valid
- 语法:open_file_cache_valid time 默认值:open_file_cache_valid 60 使用字段:http, server, location 这个指令指定了何时需要检查open_file_cache中缓存项目的有效信息.
- client_max_body_size 300m;
- 设定通过nginx上传文件的大小
- sendfile on;
- sendfile指令指定 nginx 是否调用sendfile 函数(zero copy 方式)来输出文件,对于普通应用,必须设为on。如果用来进行下载等应用磁盘IO重负载应用,可设置为off,以平衡磁盘与网络IO处理速度,降低系统uptime。
- tcp_nopush on;
- 此选项允许或禁止使用socke的TCP_CORK的选项,此选项仅在使用sendfile的时候使用
- proxy_connect_timeout 90;
- 后端服务器连接的超时时间_发起握手等候响应超时时间
- proxy_read_timeout 180;
- 连接成功后_等候后端服务器响应时间_其实已经进入后端的排队之中等候处理(也可以说是后端服务器处理请求的时间)
- proxy_send_timeout 180;
- 后端服务器数据回传时间_就是在规定时间之内后端服务器必须传完所有的数据
- proxy_buffer_size 256k;
- 设置从被代理服务器读取的第一部分应答的缓冲区大小,通常情况下这部分应答中包含一个小的应答头,默认情况下这个值的大小为指令proxy_buffers中指定的一个缓冲区的大小,不过可以将其设置为更小
- proxy_buffers 4 256k;
- 设置用于读取应答(来自被代理服务器)的缓冲区数目和大小,默认情况也为分页大小,根据操作系统的不同可能是4k或者8k
- proxy_busy_buffers_size 256k;
- proxy_temp_file_write_size 256k;
- 设置在写入proxy_temp_path时数据的大小,预防一个工作进程在传递文件时阻塞太长
- proxy_temp_path /data0/proxy_temp_dir;
- proxy_temp_path和proxy_cache_path指定的路径必须在同一分区
- proxy_cache_path /data0/proxy_cache_dir levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g;
- #设置内存缓存空间大小为200MB,1天没有被访问的内容自动清除,硬盘缓存空间大小为30GB。
- keepalive_timeout 120;
- keepalive超时时间。
- tcp_nodelay on;
- client_body_buffer_size 512k;
- 如果把它设置为比较大的数值,例如256k,那么,无论使用firefox还是IE浏览器,来提交任意小于256k的图片,都很正常。如果注释该指令,使用默认的client_body_buffer_size设置,也就是操作系统页面大小的两倍,8k或者16k,问题就出现了。
- 无论使用firefox4.0还是IE8.0,提交一个比较大,200k左右的图片,都返回500 Internal Server Error错误
- proxy_intercept_errors on;
- 表示使nginx阻止HTTP应答代码为400或者更高的应答。
- upstream bakend {
- server 127.0.0.1:8027;
- server 127.0.0.1:8028;
- server 127.0.0.1:8029;
- hash $request_uri;
- }
- nginx的upstream目前支持4种方式的分配
- 1、轮询(默认)
- 每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器down掉,能自动剔除。
- 2、weight
- 指定轮询几率,weight和访问比率成正比,用于后端服务器性能不均的情况。
- 例如:
- upstream bakend {
- server 192.168.0.14 weight=10;
- server 192.168.0.15 weight=10;
- }
- 2、ip_hash
- 每个请求按访问ip的hash结果分配,这样每个访客固定访问一个后端服务器,可以解决session的问题。
- 例如:
- upstream bakend {
- ip_hash;
- server 192.168.0.14:88;
- server 192.168.0.15:80;
- }
- 3、fair(第三方)
- 按后端服务器的响应时间来分配请求,响应时间短的优先分配。
- upstream backend {
- server server1;
- server server2;
- fair;
- }
- 4、url_hash(第三方)
- 按访问url的hash结果来分配请求,使每个url定向到同一个后端服务器,后端服务器为缓存时比较有效。
- 例:在upstream中加入hash语句,server语句中不能写入weight等其他的参数,hash_method是使用的hash算法
- upstream backend {
- server squid1:3128;
- server squid2:3128;
- hash $request_uri;
- hash_method crc32;
- }
- tips:
- upstream bakend{#定义负载均衡设备的Ip及设备状态}{
- ip_hash;
- server 127.0.0.1:9090 down;
- server 127.0.0.1:8080 weight=2;
- server 127.0.0.1:6060;
- server 127.0.0.1:7070 backup;
- }
- 在需要使用负载均衡的server中增加
- proxy_pass http://bakend/;
- 每个设备的状态设置为:
- 1.down表示单前的server暂时不参与负载
- 2.weight为weight越大,负载的权重就越大。
- 3.max_fails:允许请求失败的次数默认为1.当超过最大次数时,返回proxy_next_upstream模块定义的错误
- 4.fail_timeout:max_fails次失败后,暂停的时间。
- 5.backup: 其它所有的非backup机器down或者忙的时候,请求backup机器。所以这台机器压力会最轻。
- nginx支持同时设置多组的负载均衡,用来给不用的server来使用。
- client_body_in_file_only设置为On 可以讲client post过来的数据记录到文件中用来做debug
- client_body_temp_path设置记录文件的目录 可以设置最多3层目录
- location对URL进行匹配.可以进行重定向或者进行新的代理 负载均衡
- ##配置虚拟机
- server
- {
- listen 80;
- 配置监听端口
- server_name image.***.com;
- 配置访问域名
- location ~* \.(mp3|exe)$ {
- 对以“mp3或exe”结尾的地址进行负载均衡
- proxy_pass http://img_relay$request_uri;
- 设置被代理服务器的端口或套接字,以及URL
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- 以上三行,目的是将代理服务器收到的用户的信息传到真实服务器上
- }
- location /face {
- if ($http_user_agent ~* "xnp") {
- rewrite ^(.*)$ http://211.151.188.190:8080/face.jpg redirect;
- }
- proxy_pass http://img_relay$request_uri;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- error_page 404 502 = @fetch;
- }
- location @fetch {
- access_log /data/logs/face.log log404;
- rewrite ^(.*)$ http://211.151.188.190:8080/face.jpg redirect;
- }
- location /image {
- if ($http_user_agent ~* "xnp") {
- rewrite ^(.*)$ http://211.151.188.190:8080/face.jpg redirect;
- }
- proxy_pass http://img_relay$request_uri;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- error_page 404 502 = @fetch;
- }
- location @fetch {
- access_log /data/logs/image.log log404;
- rewrite ^(.*)$ http://211.151.188.190:8080/face.jpg redirect;
- }
- }
- ##其他举例
- server
- {
- listen 80;
- server_name *.***.com *.***.cn;
- location ~* \.(mp3|exe)$ {
- proxy_pass http://img_relay$request_uri;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- }
- location / {
- if ($http_user_agent ~* "xnp") {
- rewrite ^(.*)$ http://i1.***img.com/help/noimg.gif redirect;
- }
- proxy_pass http://img_relay$request_uri;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- #error_page 404 http://i1.***img.com/help/noimg.gif;
- error_page 404 502 = @fetch;
- }
- location @fetch {
- access_log /data/logs/baijiaqi.log log404;
- rewrite ^(.*)$ http://i1.***img.com/help/noimg.gif redirect;
- }
- }
- server
- {
- listen 80;
- server_name *.***img.com;
- location ~* \.(mp3|exe)$ {
- proxy_pass http://img_relay$request_uri;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- }
- location / {
- if ($http_user_agent ~* "xnp") {
- rewrite ^(.*)$ http://i1.***img.com/help/noimg.gif;
- }
- proxy_pass http://img_relay$request_uri;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- #error_page 404 http://i1.***img.com/help/noimg.gif;
- error_page 404 = @fetch;
- }
- #access_log off;
- location @fetch {
- access_log /data/logs/baijiaqi.log log404;
- rewrite ^(.*)$ http://i1.***img.com/help/noimg.gif redirect;
- }
- }
- server
- {
- listen 8080;
- server_name ngx-ha.***img.com;
- location / {
- stub_status on;
- access_log off;
- }
- }
- server {
- listen 80;
- server_name imgsrc1.***.net;
- root html;
- }
- server {
- listen 80;
- server_name ***.com w.***.com;
- # access_log /usr/local/nginx/logs/access_log main;
- location / {
- rewrite ^(.*)$ http://www.***.com/ ;
- }
- }
- server {
- listen 80;
- server_name *******.com w.*******.com;
- # access_log /usr/local/nginx/logs/access_log main;
- location / {
- rewrite ^(.*)$ http://www.*******.com/;
- }
- }
- server {
- listen 80;
- server_name ******.com;
- # access_log /usr/local/nginx/logs/access_log main;
- location / {
- rewrite ^(.*)$ http://www.******.com/;
- }
- }
- location /NginxStatus {
- stub_status on;
- access_log on;
- auth_basic "NginxStatus";
- auth_basic_user_file conf/htpasswd;
- }
- #设定查看Nginx状态的地址
- location ~ /\.ht {
- deny all;
- }
- #禁止访问.htxxx文件
- }
- 注释:变量
- Ngx_http_core_module模块支持内置变量,他们的名字和apache的内置变量是一致的。
- 首先是说明客户请求title中的行,例如$http_user_agent,$http_cookie等等。
- 此外还有其它的一些变量
- $args此变量与请求行中的参数相等
- $content_length等于请求行的“Content_Length”的值。
- $content_type等同与请求头部的”Content_Type”的值
- $document_root等同于当前请求的root指令指定的值
- $document_uri与$uri一样
- $host与请求头部中“Host”行指定的值或是request到达的server的名字(没有Host行)一样
- $limit_rate允许限制的连接速率
- $request_method等同于request的method,通常是“GET”或“POST”
- $remote_addr客户端ip
- $remote_port客户端port
- $remote_user等同于用户名,由ngx_http_auth_basic_module认证
- $request_filename当前请求的文件的路径名,由root或alias和URI request组合而成
- $request_body_file
- $request_uri含有参数的完整的初始URI
- $query_string与$args一样
- $sheeme http模式(http,https)尽在要求是评估例如
- Rewrite ^(.+)$ $sheme://example.com$; Redirect;
- $server_protocol等同于request的协议,使用“HTTP/或“HTTP/
- $server_addr request到达的server的ip,一般获得此变量的值的目的是进行系统调用。为了避免系统调用,有必要在listen指令中指明ip,并使用bind参数。
- $server_name请求到达的服务器名
- $server_port请求到达的服务器的端口号
- $uri等同于当前request中的URI,可不同于初始值,例如内部重定向时或使用index
三、 三 搭建nginx+tomcat代理服务器
- nginx对应一个tomcat
好了,说了怎么多,也引用了同行的经验,我们自己来搭建一个简单的nginx+tomcat代理服务吧。
一个tomcat的服务器使用nginx代理服务。在第一部分我们已经部署好了单独的nginx和tomcat服务器。现在修改nginx的配置文件,使nginx代理tomcat服务器转发请求。
修改nginx.conf文件中一下信息:
- listen ;
- server_name localhost:;
- location / {
- proxy_pass http://localhost:8080;
- }
配置文件修改好后重新加载配置文件:加载命令如下:
原因:没有启动nginx服务器,启动,重新执行命令:nginx -s reload。
在浏览器中打开nginx的访问地址:localhaost;有时候要加端口号的例如:localhaost:s80
一直没有响应怎么回事,明明我们在第一部分默认配置中已经可以看到nginx的欢迎页面了。过来一会就返回一个错误信息。
查看下错误日志文件,在/logs/error.txt文件中。
看日志中记录有个timed out。
分析:我们修改了nginx的配置文件,调整链接到http://localhost:8080,nginx就是一个代理代理转发请求,所以现在nginx请求的使http://localhost:8080这个地址。访问下这个地址http://localhost:8080。
使tomcat的原因。查看下tomcat。我这边的原因是没有启动。可能还有其它原因例如是部署在不同的服务器上,也有可能是服务器之间不通。
启动tomcat。http://localhost:8080地址无问题了。
通过nginx访问也好了。
这是一个最简单的部署了。
- nginx对应多个tomcat
我们在来一个nginx对应2个tomcat的情况。通用修改nginx.conf配置文件关键点:
upstream已经在第二部分讲过了。为了更直观现在代理情况,使用默认(轮询)访问模式。
现在我们再次访问nginx代理服务器:
再次刷新
tomcat版本变了。
无论是配置2个还是2个以上在upstream中添加就可以了。
nginx+tomcat负载均衡搭建的更多相关文章
- linux+nginx+tomcat负载均衡,实现session同步
linux+nginx+tomcat负载均衡,实现session同步 花了一个上午的时间研究nginx+tomcat的负载均衡测试,集群环境搭建比较顺利,但是session同步的问题折腾了几个小时才搞 ...
- nginx+tomcat负载均衡
最近练习nginx+tomcat负载均衡.根据一些资料整理了大体思路,最终实现了1个nginx+2个tomcat负载均衡. 安装JDK 1>进入安装目录,给所有用户添加可执行的权限 #chmod ...
- Nginx + Tomcat 负载均衡配置详解
Nginx常用操作指南一.Nginx 与 Tomcat 安装.配置及优化1. 检查和安装依赖项 yum -y install gcc pcre pcre-devel zlib zlib-devel o ...
- Nginx+Tomcat负载均衡、动静分离群集
Nginx+Tomcat负载均衡.动静分离群集 目录 Nginx+Tomcat负载均衡.动静分离群集 一.Tomcat 1. Tomcat简介 2. Tomcat重要目录 二.Nginx负载均衡原理 ...
- Nginx+tomcat负载均衡时静态页面报404
百度到的问题解决BLOG http://os.51cto.com/art/201204/326843.htm nginx+2台tomcat负载均衡,应用程序已部署,单独访问tomcat时,可以访问到所 ...
- Linux下Nginx+Tomcat负载均衡和动静分离配置要点
本文使用的Linux发行版:CentOS6.7 下载地址:https://wiki.centos.org/Download 一.安装Nginx 下载源:wget http://nginx.org/pa ...
- nginx+tomcat负载均衡策略
測试环境均为本地,測试软件为: nginx-1.6.0,apache-tomcat-7.0.42-1.apache-tomcat-7.0.42-2.apache-tomcat-7.0.42-3 利用n ...
- nginx+tomcat负载均衡和session复制
本文介绍下传统的tomcat负载均衡和session复制. session复制是基于JVM内存的,当然在当今的互联网大数据时代,有更好的替代方案,如将session数据保存在Redis中. 1.安装n ...
- nginx+tomcat负载均衡实验
导言: 本次实验,tomcat就直接使用录原生的主页,只是简单修改主页识别主机,nginx也是直接在欢迎页上面修改的,直接实现负载均衡. 主机1:192.168.100.156 nginx+tomca ...
随机推荐
- 还在用系统自带的?那你那就OUT了!
相信如今的APP10个里面有九个是有Tabbar的,可是非常多人甚是非常多公司都在用系统自带的tabbar.当然这也不是不能够,并且项目中就那几行代码.效果又一样. 可是,别忘了另一个可是.然并卵.这 ...
- 简洁方便的集合处理——Java 8 stream流
背景 java 8已经发行好几年了,前段时间java 12也已经问世,但平时的工作中,很多项目的环境还停留在java1.7中.而且java8的很多新特性都是革命性的,比如各种集合的优化.lambda表 ...
- 解决 三星Note3 桌面小部件不实时更新/不刷新 的问题
机型及问题描述:我的是三星note3 (国行 SM-N9008V),已ROOT,安装了LBE安全大师.在桌面小部件中,有些不会实时更新.比如有 滴答清单(办过的事项无法勾选),百度云音乐(歌曲播放更新 ...
- OpenOffice/LibreOffice的行距问题
OpenOffice和LibreOffice的默认行距(行间距)都很宽,可以通过以下方法设置. 格式 -> 页面 -> 文字网格 -> 不使用网格
- NFS网络文件系统服务(配置实战)
NFS网络文件系统服务(实战) NFS(Network File System)即网络文件系统,它允许网络中的计算机之间通过TCP/IP网络共享资源.让不同的主机系统(NFS的客户端)可以透明地读写位 ...
- Linux高并发应用类型对系统内核的优化
Linux操作系统内核参数优化 net.ipv4.tcp_max_tw_buckets = net.ipv4.ip_local_port_range = net.ipv4.tcp_tw_recycle ...
- 浅谈Java数据结构和算法
今天的突然看集合底层的时候发现了好多算法和数据结构.再次就比较一下和汇总一下. 数据结构分类:线性结构和非线性结构 问题一: 什么是线性和非线性: 我个人的理解是:数据结构中线性结构指的是数据元素之间 ...
- 值类型,Nullable类型
1. 值类型 比如说int吧,是值类型,是个struct,是这样声明的 public struct Int32 : IComparable, IFormattable, IConvertible, I ...
- CSU 1663: Tree(树链剖分)
1663: Tree Time Limit: 5 Sec Memory Limit: 128 MB Submit: 26 Solved: 11 [Submit][id=1663"> ...
- Linux tar包安装Nginx
1.首先安装依赖包(依赖包有点多.我们採用yum的方式来安装) yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel ...