zoukankan      html  css  js  c++  java
  • verynginx +nginx_upstream_check_module模块,负载均衡检查模块。

    yum -y install git
    yum -y install patch
    yum -y install pcre-devel
    yum install -y zlib-devel
     
    mkdir /opt/nginx/ && cd /opt/nginx/
     
    wget https://openresty.org/download/openresty-1.9.15.1.tar.gz
    wget https://www.openssl.org/source/openssl-1.0.2l.tar.gz
    wget https://github.com/chaoslawful/lua-nginx-module/archive/v0.8.6.tar.gz
     
    tar xf xxx.tar.gz
     
    git clone https://github.com/yaoweibin/nginx_upstream_check_module.git
     
    cp -a nginx_upstream_check_module /opt/nginx/openresty-1.9.15.1/bundle/nginx-1.9.15/
    cd /opt/nginx/openresty-1.9.15.1/bundle/nginx-1.9.15/
    patch -p0 < /opt/nginx/openresty-1.9.15.1/bundle/nginx-1.9.15/nginx_upstream_check_module/check_1.9.2+.patch
     
     
    cd /opt/nginx/openresty-1.9.15.1/
    ./configure --prefix=/usr/local/verynginx --user=nginx --group=nginx --with-http_v2_module --with-http_sub_module --with-http_stub_status_module --with-luajit --with-openssl=/opt/nginx/openssl-1.0.2l --add-module=/opt/nginx/openresty-1.9.15.1/bundle/nginx-1.9.15/nginx_upstream_check_module/
    make -j 4
    make install
    cd .. &&  cp –a VeryNginx/veryNginx /usr/local/vnginx/  &&  chown -R nginx:nginx /usr/local/vnginx/verynginx
     
    vim nginx.conf
     
    1. user nginx;
    2. worker_processes auto;
    3. #daemon off;   #如果要在docker运行,加这个参数让nginx在前台运行
    4. error_log logs/error.log;
    5. error_log logs/error.log notice;
    6. error_log logs/error.log info;
    7. pid logs/nginx.pid;
    8. events {
    9. worker_connections 1024;
    10. }
    11. include /usr/local/verynginx/verynginx/nginx_conf/in_external.conf;
    12. http {
    13. include mime.types;
    14. default_type application/octet-stream;
    15. log_format access '$host $remote_addr - - $time_local "$request" "$http_referer" "$http_user_agent" $body_bytes_sent "$http_x_forwarded_for" $request_length $status $request_time';
    16. sendfile on;
    17. keepalive_timeout 65;
    18. client_body_buffer_size 128k;
    19. gzip on;
    20. include /usr/local/verynginx/verynginx/nginx_conf/in_http_block.conf;
    21. # include /usr/local/verynginx/nginx/conf/vhosts/*.conf;
    22. server {
    23. listen 80;
    24. include /usr/local/verynginx/verynginx/nginx_conf/in_server_block.conf;
    25. location = / {
    26. root html;
    27. index index.html index.htm;
    28. }
    29. }
    30. include /usr/local/verynginx/nginx/conf/vhosts/*.conf;
    31. }
     mkdir -p /usr/local/verynginx/nginx/conf/vhosts/
     
    vim t.conf
    upstream nsignature {
        server 127.0.0.1:9998 weight=1;
        server 127.0.0.1:9998 weight=1;
        check interval=3000 rise=2 fall=5 timeout=1000;
        check_http_send "GET /1 HTTP/1.0
    
    ";
        check_http_expect_alive http_2xx http_3xx;
        }
    server {
            listen  80;
            server_name test.xxx.cn;
            location /{
                    proxy_pass  http://nsignature;
                    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_set_header   X-Forwarded-Proto  $scheme;
            }
             location /nstatus {
                check_status;
                access_log   off;
                allow all;
                    }
            access_log  /var/log/test.log access;
    }
     
    vim /usr/local/verynginx/verynginx/nginx_conf/in_http_block.conf
    upstream vn_upstream{
    server 127.0.0.1;
    balancer_by_lua_file /usr/local/verynginx/verynginx/lua_script/on_banlance.lua;
    keepalive 1024; #Connection pool
    }
    lua_package_path '/usr/local/verynginx/verynginx/lua_script/?.lua;;/usr/local/verynginx/verynginx/lua_script/module/?.lua;;';
    lua_package_cpath '/usr/local/verynginx/verynginx/lua_script/?.so;;';
    lua_code_cache on;
    lua_shared_dict status 1m;
    lua_shared_dict frequency_limit 10m;
    lua_shared_dict summary_long 10m;
    lua_shared_dict summary_short 10m;
    init_by_lua_file /usr/local/verynginx/verynginx/lua_script/on_init.lua;
    rewrite_by_lua_file /usr/local/verynginx/verynginx/lua_script/on_rewrite.lua;
    access_by_lua_file /usr/local/verynginx/verynginx/lua_script/on_access.lua;
    log_by_lua_file /usr/local/verynginx/verynginx/lua_script/on_log.lua;
  • 相关阅读:
    每日一题:用一个SQL语句交换两条数据某一列的值
    String value(); String[] value(); 比较
    java.sql.SQLException: Unknown system variable 'tx_isolation'
    return; 用法
    Linux和UNIX的关系及区别(详解版)
    404
    Centos 7 修改YUM镜像源地址为阿里云镜像地址
    JVM面试必备
    秒杀优化迭代
    电商秒杀基础构建项目笔记2(优化效验准则和商品模型创建)
  • 原文地址:https://www.cnblogs.com/cp-miao/p/7382247.html
Copyright © 2011-2022 走看看