• nginx+tomcat负载均衡


    <Connector port="30001" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="30043" />

    1.nginx编译安装

    ./configure --prefix=/usr/local/nginx --with-pcre=../pcre-8.36#【--with-pcre=/usr/local/pcre不可以,/opt/pcre-8.36,是pcre加压后的路径】。

    make

    make install

    启动后

    [root@centos1 conf]# netstat -antpl|grep nginx
    tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      2022/nginx   

    vim /usr/local/nginx

    #user www www;  
    worker_processes 8;
    #pid /usr/local/nginx/nginx.pid;  
    worker_rlimit_nofile 102400;
    events
    {
    use epoll;
    worker_connections 102400;
    }
    http
    {
      include       mime.types;
      default_type  application/octet-stream;
      fastcgi_intercept_errors on;
      charset  utf-8;
      server_names_hash_bucket_size 128;
      client_header_buffer_size 4k;
      large_client_header_buffers 4 32k;
      client_max_body_size 300m;
      sendfile on;
      tcp_nopush     on;

      keepalive_timeout 60;

      tcp_nodelay on;
      client_body_buffer_size  512k;

      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 128k;

      gzip on;
      gzip_min_length  1k;
      gzip_buffers     4 16k;
      gzip_http_version 1.1;
      gzip_comp_level 2;
      gzip_types       text/plain application/x-javascript text/css application/xml;
      gzip_vary on;

    ###2012-12-19 change nginx logs  
    log_format  main  '$http_x_forwarded_for - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent"  $request_time $remote_addr';

    upstream web_app {
    server 127.0.0.1:30001 weight=1 max_fails=2 fail_timeout=30s;
    server 127.0.0.1:40001 weight=1 max_fails=2 fail_timeout=30s;
    }

    ####chinaapp.sinaapp.com  
    server {
        listen 80;
        server_name  chinaapp.sinaapp.com;
        index index.jsp index.html index.htm;
        #发布目录/data/www  
        root  /data/www;

        location /
        {
        proxy_next_upstream http_502 http_504 error timeout invalid_header;
        proxy_set_header Host  $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://web_app;
        expires      3d;
        }

      }

    }

    2.tomcat 的配置文件

    修改两个tomcat的配置文件中三个端口号

    vim /usr/local/TC7_A/conf/server.xml

    修改shutdown端口号

    <Server port="30005" shutdown="SHUTDOWN">

    修改http端口号

    <Connector port="30001" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="30043" />

    修改ajp端口号

    <Connector port="30009" protocol="AJP/1.3" redirectPort="30043" />

  • 相关阅读:
    使用SpringMVC的crud操作时,进行数据修改,但是修改成功后,页面无法显示lastName属性值(被修改的那条记录)
    使用SpringMVC时报错HTTP Status 405
    使用springmvc时报错org.springframework.beans.NullValueInNestedPathException: Invalid property 'department' of bean class [com.atguigu.springmvc.crud.entities.Employee]:
    快速傅里叶变换应用之二 hdu 4609 3-idiots
    离散傅立叶变换与快速傅立叶变换(DFT与FFT)
    深度优先搜索(DFS)递归形式改为非递归形式
    模拟题组
    STL--自定义类型的排序
    多关键字的快速排序
    二叉树的前序和中序得到后序 hdu1710
  • 原文地址:https://www.cnblogs.com/stay-sober/p/4231497.html
Copyright © 2020-2023  润新知