nginx 부 드 러 운 업그레이드 와 스크롤 백
[root@localhost ~]# yum install -y gcc gcc-c++ pcre-devel openssl-devel zlib-devel
[root@localhost ~]# tar xzf nginx-1.6.3.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local/nginx-1.6.3
[root@localhost nginx-1.6.3]# ./configure --prefix=/usr/local/nginx --user=nginx -group=nginx --with-http_stub_status_module
[root@localhost nginx-1.6.3]# make && make install
[root@localhost nginx-1.6.3]# useradd -M -s /sbin/nologin nginx
[root@localhost nginx-1.6.3]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost nginx-1.6.3]# /usr/local/nginx/sbin/nginx
2. 버 전과 모듈 보기
[root@localhost nginx-1.6.3]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.6.3 built
by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --withhttp_stub_status_module
3. 액세스 인증
[root@localhost nginx-1.6.3]# echo "nginx1.6" > /usr/local/nginx/html/index.html
[root@localhost nginx-1.6.3]# yum install -y elinks
[root@localhost nginx-1.6.3]# elinks 10.0.105.189
4. nginx 승급
nginx 버 전 을 업그레이드 하고 업무 에 영향 을 주지 않 는 상태 에서 SSL 과 pcre 모듈 을 추가 합 니 다.
[root@localhost ~]# tar xzf nginx-1.12.2.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local/nginx-1.12.2/
[root@localhost nginx-1.12.2]# ./configure --prefix=/usr/local/nginx --user=nginx -group=ngiinx --with-http_stub_status_module --with-http_ssl_module --with-pcre
[root@localhost nginx-1.12.2]# make
[root@localhost nginx-1.12.2]# cd
[root@localhost ~]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx_lod
[root@localhost ~]# cp /usr/local/nginx-1.12.2/objs/nginx /usr/local/nginx/sbin/
[root@localhost ~]# ps -ef | grep nginx
root 6324 1 0 09:06 ? 00:00:00 nginx: master process /usr/local/nginx-1.12.2/sbin/nginx
nobody 6325 6324 0 09:06 ? 00:00:00 nginx: worker process
root 6338 1244 0 09:11 pts/0 00:00:00 grep --color=auto nginx
[root@localhost ~]# kill -USR2 6324 # master
[root@localhost ~]# ls /usr/local/nginx/logs/ # .pid .oldbin
access.log error.log nginx.pid nginx.oldbin
[root@localhost ~]# cat /usr/local/nginx/logs/nginx.pid
6340
[root@localhost ~]# ps -ef | grep nginx
root 6324 1 0 09:06 ? 00:00:00 nginx: master process /usr/local/nginx-1.12.2/sbin/nginx
nobody 6325 6324 0 09:06 ? 00:00:00 nginx: worker process
root 6340 6324 0 09:12 ? 00:00:00 nginx: master process /usr/local/nginx-1.12.2/sbin/nginx
nobody 6341 6340 0 09:12 ? 00:00:00 nginx: worker process
root 6343 1244 0 09:12 pts/0 00:00:00 grep --color=auto nginx
이 때 두 nginx 인 스 턴 스 가 동시에 실행 되 고 입력 요청 을 함께 처리 합 니 다.오래된 인 스 턴 스 를 점차 중단 하려 면 오래된 메 인 프로 세 스에 WINCH 신 호 를 보 내야 합 니 다. 그리고 작업 프로 세 스 가 여 유 롭 게 닫 힐 것 입 니 다.
[root@nginx ~]# kill -WINCH 6324
[root@nginx ~]# ps -ef | grep nginx
root 6324 1 0 09:06 ? 00:00:00 nginx: master process /usr/local/nginx-1.12.2/sbin/nginx
root 6340 6324 0 09:12 ? 00:00:00 nginx: master process /usr/local/nginx-1.12.2/sbin/nginx
nobody 6341 6340 0 09:12 ? 00:00:00 nginx: worker process
root 6346 1244 0 09:14 pts/0 00:00:00 grep --color=auto nginx
한 동안 오래된 작업 프로 세 스 가 연 결 된 모든 요청 을 처리 하고 종료 하면 입력 한 요청 만 새 작업 프로 세 스 로 처리 합 니 다. 오래된 워 커 는 사 라 졌 지만 오래된 master 는 스크롤 백 을 준비 하고 있 습 니 다.
현재 nginx 상태 보기
[root@localhost ~]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre
버 전 업그레이드 가 완료 되면 문제 가 없 으 면 오래된 master 프로 세 스 를 닫 아야 합 니 다.
5. 스크롤 백
오래된 master 프로 세 스 는 항상 존재 합 니 다. 수 동 으로 닫 히 기 전에 스스로 닫 히 지 않 습 니 다. 이런 디자인 은 좋 은 점 이 있 습 니 다. 새로운 버 전 을 업그레이드 한 후에 문제 가 발생 하면 신속하게 이전 안정 적 인 버 전 으로 돌아 갈 수 있 습 니 다.
[root@localhost ~]# ps aux | grep nginx
root 12264 0.0 0.0 24860 956 ? Ss 16:31 0:00 nginx: master process /usr/local/nginx/sbin/nginx
root 20083 0.0 0.1 45936 3260 ? S 16:38 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 20084 0.0 0.1 46384 2128 ? S 16:38 0:00 nginx: worker process
root 27488 0.0 0.0 112708 984 pts/0 R+ 16:47 0:00 grep --color=auto nginx
[root@localhost ~]# kill -HUP 12264 # HUP -
[root@localhost ~]# ps aux | grep nginx
root 12264 0.0 0.0 24860 956 ? Ss 16:31 0:00 nginx: master process /usr/local/nginx/sbin/nginx
root 20083 0.0 0.1 45936 3260 ? S 16:38 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 20084 0.0 0.1 46384 2128 ? S 16:38 0:00 nginx: worker process
nginx 28108 0.0 0.0 25284 1460 ? S 16:47 0:00 nginx: worker process
root 28154 0.0 0.0 112708 980 pts/0 R+ 16:47 0:00 grep --color=auto nginx
[root@localhost ~]# kill -QUIT 20083 # QUIT ,
[root@localhost ~]# ps aux | grep nginx
root 12264 0.0 0.0 24860 956 ? Ss 16:31 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 28108 0.0 0.0 25284 1460 ? S 16:47 0:00 nginx: worker process
root 28933 0.0 0.0 112708 984 pts/0 R+ 16:48 0:00 grep --color=auto nginx
새 주 프로 세 스 가 종료 되 지 않 았 다 면 TERM 신 호 를 새 주 프로 세 스에 보 내 서 종료 하도록 합 니 다.
kill -TERM 20083
어떤 이유 로 새 작업 프로 세 스 를 종료 할 수 없 으 면 KILL 신 호 를 보 냅 니 다.
kill -9 20083
새 메 인 프로 세 스 가 종료 되면 오래된 메 인 프로 세 스 는. oldbin 접 두 사 를 제거 하고. pid 파일 로 복 구 됩 니 다. 그러면 모든 것 이 업그레이드 전 으로 복 구 됩 니 다.
[root@localhost ~]# ls /usr/local/nginx/logs/
access.log error.log nginx.pid
[root@localhost ~]# cat /usr/local/nginx/logs/nginx.pid
12264
업그레이드 에 성공 하면 새 서버 를 유지 하고 싶 을 때 QUIT 신 호 를 오래된 메 인 프로 세 스에 보 내 서 새 서버 만 실행 하도록 합 니 다.
kill -QUIT 12264
참고:https://blog.csdn.net/mingongge/article/details/88097055 https://blog.csdn.net/u011085172/article/details/71515745
Nginx 재 컴 파일 새 모듈 추가
https://www.jianshu.com/p/0309cb5e7e76 https://www.jianshu.com/p/695af00ee857
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.