美文网首页openresty
openresty+health_check+consul安装

openresty+health_check+consul安装

作者: allanYan | 来源:发表于2016-08-05 14:55 被阅读0次

    项目中经常要搭建nginx环境,记录下安装脚本,备忘;

    1. 安装依赖:

      yum install readline-devel pcre-devel openssl-devel gcc
      
    2. 下载依赖包:

      git clone https://github.com/xiaokai-wang/nginx_upstream_check_module.git
      wget --secure-protocol=TLSv1 --no-check-certificate https://openresty.org/download/openresty-1.11.2.5.tar.gz
      git clone https://github.com/weibocom/nginx-upsync-module.git
      git clone https://github.com/sumory/orange.git
      git clone https://github.com/sumory/lor.git
      
    3. 准备nginx_upstream_check_module模块,需要先对nginx打patch:

      tar -xvf openresty-1.11.2.5.tar.gz -C /data/exec/
      cd /data/exec/openresty-1.11.2.5/bundle/nginx-1.11.2
      

    patch -p0 < /data/exec/nginx_upstream_check_module/check_1.11.1+.patch
    ```

    1. 修改nginx-upsync-module模块ngx_http_upsync_module.c的1688行:

      node = cJSON_GetObjectItem(server_next, "Node")
      

    改为:

    ```
    node = cJSON_GetObjectItem(server_next, "Service")
    ```
    
    1. 安装openresty:

      ./configure --prefix=/data/exec/openresty --with-http_stub_status_module --add-module=/data/exec/nginx_upstream_check_module --add-module=/data/exec/nginx-upsync-module
      

    make & make install

    ```
    
    1. 安装Lor,默认安装到/usr/local目录:
    cd lor
    make install
    
    1. 安装orange
    cd orange
    make install
    
    1. 修改orange的配置文件,增加upstream:

      upstream xiu-relation-server {
              upsync 10.221.83.98:8500/v1/health/service/xiu-relation-server upsync_timeout=6m upsync_interval=500ms upsync_type=consul_health strong_dependency=on;
              upsync_dump_path /usr/local/openresty/nginx/conf/servers/servers_xiu_relation_server.conf;
              include /usr/local/openresty/nginx/conf/servers/servers_xiu_relation_server.conf;
      
              check interval=1000 rise=2 fall=2 timeout=3000 type=tcp default_down=false;
              #check_http_send "HEAD / HTTP/1.0\r\n\r\n";
              #check_http_expect_alive http_2xx http_3xx;
      
          }
      
    location = /upstream_show {
                upstream_show;
            }
    
            location = /upstream_status {
                check_status;
                access_log off;
            }
    
    
    1. 修改oragne的配置文件orange.conf,主要配置mysql的地址;

    2. 建立nginx的软链接:

    ln -s /data/exec/openresty/nginx/sbin/nginx /usr/local/bin/nginx
    
    1. 通过orange start/stop/restart管理应用,假设服务器ip为10.1.1.2,upstream相关指令放在80端口

    相关文章

      网友评论

        本文标题:openresty+health_check+consul安装

        本文链接:https://www.haomeiwen.com/subject/iaihsttx.html