openresty+health_check + consul 설치

2821 단어
프로젝트 에 nginx 환경 을 구축 하고 설치 스 크 립 트 를 기록 하 며 메모 해 야 합 니 다.
  • 설치 의존:
    yum install readline-devel pcre-devel openssl-devel gcc
    
  • 다운로드 의존 패키지:
    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
    
  • 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 ```
  • nginx - upsync - module 모듈 수정 ngxhttp_upsync_module. c 의 1688 줄:
    node = cJSON_GetObjectItem(server_next, "Node")
    
  • 다음으로 변경:
    ```
    node = cJSON_GetObjectItem(server_next, "Service")
    ```
    
  • 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
    ```
    
  • Lor 를 설치 하고 기본 값 으로 / usr / local 디 렉 터 리 에 설치 합 니 다.
  • cd lor
    make install
    
  • 오렌지 설치
  • cd orange
    make install
    
  • 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
    \r
    "; #check_http_expect_alive http_2xx http_3xx; }
  • 추가
    location = /upstream_show {
                upstream_show;
            }
    
            location = /upstream_status {
                check_status;
                access_log off;
            }
    
    
  • oragne 의 프로필 orange. conf 를 수정 하고 mysql 의 주 소 를 설정 합 니 다.
  • nginx 의 소프트 링크 구축:
  • ln -s /data/exec/openresty/nginx/sbin/nginx /usr/local/bin/nginx
    
  • 오렌지 start / stop / restart 관리 응용 을 통 해 서버 ip 이 10.1.1.2 라 고 가정 하고 upstream 관련 명령 을 80 포트
  • 에 놓 습 니 다.
  • 관리 인터페이스:http://10.1.1.2:9999/
  • upstream 설정 보기:http://10.1.1.2/upstream_status
  • upstream 상태 보기:http://10.1.1.2/upstream_show
  • 좋은 웹페이지 즐겨찾기