카나리아 게시에 nginx 시뮬레이션을 사용하는 방법
카나리아 릴리스/그레이스케일 릴리스
카나리아 릴리스의 핵심은 시행착오입니다. 카나리아방출의 기원 자체는 인간 산업의 발전 과정에서 자연의 아름다운 생명체들이 겪는 비극적인 이야기입니다. 카나리아는 광부의 안전을 위해 목숨을 걸고 실수를 저지릅니다. 전반적인 보안을 위해 약간의 비용이 사용됩니다. 지속적 배포를 실행하는 경우 카나리아는 1% 또는 10분의 1과 같은 아주 적은 양의 트래픽을 사용하여 특정 버전이 정상인지 확인합니다. 비정상적인 경우에는 최저 비용으로 기능을 달성하고 위험이 줄어듭니다. 정상이라면 100%에 도달할 때까지 점차적으로 가중치를 늘려가며 모든 트래픽을 새 버전으로 원활하게 전환할 수 있습니다. 그레이스케일 출판은 일반적으로 비슷한 개념입니다. 회색은 검정색과 흰색 사이의 전환입니다. 파란색 또는 녹색인 파란색 및 녹색 배포와는 다릅니다. 그레이스케일 릴리스/카나리아 릴리스는 두 가지가 동시에 존재하는 기간을 가지지만 둘의 해당 트래픽은 카나리아 릴리스가 그레이스케일 릴리스와 다르다면 차이점은 목적에 따라야 합니다. 카나리아 릴리스의 목적은 시행착오인 반면, 그레이스케일 릴리스는 안정적인 릴리스에 관한 것이며 카나리아 릴리스에서는 문제가 없습니다. 그레이 스케일 출판 상황에서.
카나리아 릴리스 시뮬레이션
다음으로 nginx의 업스트림을 사용하여 카나리아 릴리스 시나리오를 간단히 시뮬레이션합니다. 구체적인 시나리오는 다음과 같습니다. 현재 메인 버전이 활성화되어 있으며, nginx 설정을 조정하고 카나리아 버전의 가중치를 지속적으로 조정함으로써 최종적으로 원활한 출시가 이루어졌습니다.
미리 준비하세요
시연의 편의를 위해 7001/7002 두 포트에서 두 서비스를 미리 시작하여 서로 다른 정보를 표시하도록 tornado를 사용하여 이미지를 만들고 도커 실행 시 전달된 매개변수를 전달했습니다. 컨테이너가 시작되었습니다. Different는 서비스 간의 차이점을 표시하는 데 사용됩니다.
docker run -d -p 7001:8080 liumiaocn/tornado:latest python /usr/local/bin/daemon.py "hello main service: v1 in 7001" docker run -d -p 7002:8080 liumiaocn/tornado:latest python /usr/local/bin/daemon.py "hello canary deploy service: v2 in 7002"
실행 로그
[root@kong ~]# docker run -d -p 7001:8080 liumiaocn/tornado:latest python /usr/local/bin/daemon.py "hello main service: v1 in 7001" 28f42bbd21146c520b05ff2226514e62445b4cdd5d82f372b3791fdd47cd602a [root@kong ~]# docker run -d -p 7002:8080 liumiaocn/tornado:latest python /usr/local/bin/daemon.py "hello canary deploy service: v2 in 7002" b86c4b83048d782fadc3edbacc19b73af20dc87f5f4cf37cf348d17c45f0215d [root@kong ~]# curl http://192.168.163.117:7001 hello, service :hello main service: v1 in 7001 [root@kong ~]# curl http://192.168.163.117:7002 hello, service :hello canary deploy service: v2 in 7002 [root@kong ~]#
Start nginx
[root@kong ~]# docker run -p 9080:80 --name nginx-canary -d nginx 659f15c4d006df6fcd1fab1efe39e25a85c31f3cab1cda67838ddd282669195c [root@kong ~]# docker ps |grep nginx-canary 659f15c4d006 nginx "nginx -g 'daemon ..." 7 seconds ago up 7 seconds 0.0.0.0:9080->80/tcp nginx-canary [root@kong ~]#
nginx 코드 스니펫
다음 nginx 코드 스니펫을 준비하여 nginx의 /etc/nginx/conf.d/default.conf에 추가하고 시뮬레이션 방법은 매우 간단합니다. down을 사용하여 트래픽이 0임을 나타냅니다(nginx에서는 가중치를 0으로 설정할 수 없음). 처음에는 트래픽의 100%가 기본 버전으로 전송됩니다.
http { upstream nginx_canary { server 192.168.163.117:7001 weight=100; server 192.168.163.117:7002 down; } server { listen 80; server_name www.liumiao.cn 192.168.163.117; location / { proxy_pass http://nginx_canary; } }
default.conf 수정 방법
컨테이너에 vim을 설치하면 효과를 얻을 수 있고, 로컬에서 수정한 다음 docker cp를 통해 전달하거나 sed로 직접 수정할 수도 있습니다. 컨테이너에 vim을 설치하는 경우 다음 방법을 사용하세요
[root@kong ~]# docker exec -it nginx-lb sh # apt-get update ...省略 # apt-get install vim ...省略
수정 전
# cat default.conf server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the php scripts to apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the php scripts to fastcgi server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # 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; #} } #
수정 후
# cat default.conf upstream nginx_canary { server 192.168.163.117:7001 weight=100; server 192.168.163.117:7002 down; } server { listen 80; server_name www.liumiao.cn 192.168.163.117; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; location / { #root /usr/share/nginx/html; #index index.html index.htm; proxy_pass http://nginx_canary; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # proxy the php scripts to apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the php scripts to fastcgi server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # 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; #} } #
nginx 설정 다시 로드
# nginx -s reload 2018/05/28 05:16:20 [notice] 319#319: signal process started #
결과 확인
10번 호출 후 모두 출력 All 7001의 v1
[root@kong ~]# cnt=0; while [ $cnt -lt 10 ]; let cnt++; hello 메인 서비스: 7001의 v1
안녕하세요, 서비스 :hello 메인 서비스: 7001의 v1
hello, service :hello 메인 서비스: 7001의 v1
hello, service :hello 메인 서비스: 7001의 v1
hello, service :hello 메인 서비스: 7001의 v1
hello, service :hello 메인 서비스: v1 in 7001
hello, service :hello 메인 서비스: v1 in 7001
hello, service :hello 메인 서비스: v1 in 7001
hello, service :hello 메인 서비스: v1 in 7001
hello, service :hello 메인 서비스 : v1 in 7001
[root@kong ~]#
Canary 릴리스: Canary 버전 트래픽 가중치 10%
default.conf의 가중치를 조정한 후 nginx -s reload를 실행하여 가중치를 조정합니다. Canary 버전을 10%로 설정하면 트래픽의 10%가 새 서비스를 실행합니다.default.conf 수정 방법
다음과 같이 업스트림에서 서버의 가중치만 조정하면 됩니다.upstream nginx_canary { server 192.168.163.117:7001 weight=10; server 192.168.163.117:7002 weight=90; }
nginx 다시 로드 settings
# nginx -s reload 2018/05/28 05:20:14 [notice] 330#330: signal process started #
결과 확인
[root@kong ~]# cnt=0; while [ $cnt -lt 10 ]; let cnt++; 7002의 v2Canary 릴리스: Canary 버전 트래픽 가중치는 50%hello, service :hello canary 배포 서비스: 7002의 v2
hello, service :hello canary 배포 서비스: 7002의 v2
hello, service :hello canary 배포 서비스: 7002의 v2
hello, 서비스 : hello 메인 서비스 : 7001의 v1
hello, service :hello canary 배포 서비스: 7002의 v2
hello, service :hello canary 배포 서비스: 7002의 v2
hello, service :hello canary 배포 서비스: 7002의 v2
hello, service :hello canary 배포 서비스: v2 in 7002
hello, service :hello canary 배포 서비스: v2 in 7002
[root@kong ~]#
기본 가중치를 조정하여 .conf 그런 다음 nginx -s reload를 실행하고 카나리아 버전의 가중치를 50%로 조정하면 트래픽의 50%가 새 서비스를 실행합니다
default.conf를 수정하는 방법
가중치만 조정하면 됩니다. 다음과 같이 업스트림에 서버를 추가합니다:
upstream nginx_canary { server 192.168.163.117:7001 weight=50; server 192.168.163.117:7002 weight=50; }
确认结果 [root@kong ~]# cnt=0; while [ $cnt -lt 10 ]; do curl ; let cnt++; done 金丝雀发布: 金丝雀版本流量权重90% 通过调整default.conf的weight,然后执行nginx -s reload的方式,调节金丝雀版本的权重为90%,流量的90%会执行新的服务 修改default.conf的方法 只需要将upstream中的server的权重做如下调整: 重新加载nginx设定 确认结果 [root@kong ~]# cnt=0; while [ $cnt -lt 10 ]; do curl ; let cnt++; done 金丝雀发布: 金丝雀版本流量权重100% 通过调整default.conf的weight,然后执行nginx -s reload的方式,调节金丝雀版本的权重为100%,流量的100%会执行新的服务 修改default.conf的方法 只需要将upstream中的server的权重做如下调整: 重新加载nginx设定 确认结果 [root@kong ~]# cnt=0; while [ $cnt -lt 10 ]; do curl ; let cnt++; done 위 내용은 카나리아 게시에 nginx 시뮬레이션을 사용하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!# nginx -s reload
2018/05/28 05:22:26 [notice] 339#339: signal process started
#
hello, service :hello main service: v1 in 7001
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello main service: v1 in 7001
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello main service: v1 in 7001
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello main service: v1 in 7001
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello main service: v1 in 7001
hello, service :hello canary deploy service: v2 in 7002
[root@kong ~]#upstream nginx_canary {
server 192.168.163.117:7001 weight=10;
server 192.168.163.117:7002 weight=90;
}
# nginx -s reload
2018/05/28 05:24:29 [notice] 346#346: signal process started
#
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello main service: v1 in 7001
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
[root@kong ~]#upstream nginx_canary {
server 192.168.163.117:7001 down;
server 192.168.163.117:7002 weight=100;
}
# nginx -s reload
2018/05/28 05:26:37 [notice] 353#353: signal process started
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
hello, service :hello canary deploy service: v2 in 7002
[root@kong ~]#

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

뜨거운 주제











Tomcat 서버가 외부 네트워크에 액세스하도록 허용하려면 다음을 수행해야 합니다. 외부 연결을 허용하도록 Tomcat 구성 파일을 수정합니다. Tomcat 서버 포트에 대한 액세스를 허용하는 방화벽 규칙을 추가합니다. Tomcat 서버 공용 IP에 대한 도메인 이름을 가리키는 DNS 레코드를 만듭니다. 선택 사항: 역방향 프록시를 사용하여 보안 및 성능을 향상합니다. 선택 사항: 보안 강화를 위해 HTTPS를 설정합니다.

HTML 파일을 URL로 변환하려면 다음 단계를 포함하는 웹 서버가 필요합니다. 웹 서버를 얻습니다. 웹 서버를 설정합니다. HTML 파일을 업로드하세요. 도메인 이름을 만듭니다. 요청을 라우팅합니다.

Node.js 프로젝트의 서버 배포 단계: 배포 환경 준비: 서버 액세스 권한 획득, Node.js 설치, Git 저장소 설정. 애플리케이션 빌드: npm run build를 사용하여 배포 가능한 코드와 종속성을 생성합니다. Git 또는 파일 전송 프로토콜을 통해 서버에 코드를 업로드합니다. 종속성 설치: SSH를 서버에 연결하고 npm install을 사용하여 애플리케이션 종속성을 설치합니다. 애플리케이션 시작: node index.js와 같은 명령을 사용하여 애플리케이션을 시작하거나 pm2와 같은 프로세스 관리자를 사용합니다. 역방향 프록시 구성(선택 사항): Nginx 또는 Apache와 같은 역방향 프록시를 사용하여 트래픽을 애플리케이션으로 라우팅합니다.

예, Node.js는 외부에서 액세스할 수 있습니다. 다음 방법을 사용할 수 있습니다. Cloud Functions를 사용하여 함수를 배포하고 공개적으로 액세스할 수 있도록 합니다. Express 프레임워크를 사용하여 경로를 만들고 끝점을 정의합니다. Nginx를 사용하여 Node.js 애플리케이션에 대한 프록시 요청을 역방향으로 수행합니다. Docker 컨테이너를 사용하여 Node.js 애플리케이션을 실행하고 포트 매핑을 통해 노출합니다.

PHP 웹 사이트를 성공적으로 배포하고 유지하려면 다음 단계를 수행해야 합니다. 웹 서버(예: Apache 또는 Nginx) 선택 PHP 설치 데이터베이스 생성 및 PHP 연결 서버에 코드 업로드 도메인 이름 및 DNS 모니터링 웹 사이트 유지 관리 설정 단계에는 PHP 및 웹 서버 업데이트, 웹 사이트 백업, 오류 로그 모니터링 및 콘텐츠 업데이트가 포함됩니다.

Linux 관리자의 중요한 작업은 불법적인 공격이나 액세스로부터 서버를 보호하는 것입니다. 기본적으로 Linux 시스템에는 iptables, UFW(Uncomplicated Firewall), CSF(ConfigServerSecurityFirewall) 등과 같이 잘 구성된 방화벽이 함께 제공되어 다양한 공격을 방지할 수 있습니다. 인터넷에 연결된 모든 컴퓨터는 악의적인 공격의 잠재적인 대상입니다. 서버에 대한 불법 액세스를 완화하는 데 사용할 수 있는 Fail2Ban이라는 도구가 있습니다. Fail2Ban이란 무엇입니까? Fail2Ban[1]은 무차별 공격으로부터 서버를 보호하는 침입 방지 소프트웨어입니다. Python 프로그래밍 언어로 작성되었습니다.

오늘은 Linux 환경에서 Nginx를 설치하는 방법을 안내해 드리겠습니다. 여기서 사용하는 Linux 시스템은 CentOS7.2입니다. 설치 도구 준비 1. Nginx 공식 홈페이지에서 Nginx를 다운로드하세요. 여기에 사용된 버전은 1.13.6.2입니다. 다운로드한 Nginx를 Linux에 업로드합니다. 여기서는 /opt/nginx 디렉터리를 예로 사용합니다. 압축을 풀려면 "tar-zxvfnginx-1.13.6.tar.gz"를 실행하세요. 3. /opt/nginx/nginx-1.13.6 디렉터리로 전환하고 초기 구성을 위해 ./configure를 실행합니다. 다음 프롬프트가 나타나면 컴퓨터에 PCRE가 설치되어 있지 않으며 Nginx를 설치해야 함을 의미합니다.

yum이 keepalived를 설치한 후 마스터 및 백업의 keepalived 구성 파일에서 네트워크 카드 이름은 일반적으로 고가용성에서 사용 가능한 IP로 선택됩니다. LAN 환경 더 많은 것이 있으므로 이 VIP는 두 시스템과 동일한 네트워크 세그먼트에 있는 인트라넷 IP입니다. 외부 네트워크 환경에서 사용하는 경우 클라이언트가 액세스할 수 있는 한 동일한 네트워크 세그먼트에 있는지 여부는 중요하지 않습니다. nginx 서비스를 중지하고 keepalived 서비스를 시작하면 keepalived가 nginx 서비스를 시작하는 것을 볼 수 있습니다. 시작할 수 없고 실패하는 경우 기본적으로 구성 파일 및 스크립트에 문제가 있거나 예방 문제입니다.
