Nginx平滑升級

環境準備

  • 準備已經安裝好的nginx-1.6.3版本,另需nginx-1.10.3的安裝包
[root@nginx application]# ll
總用量 896
-rw-r--r--  1 root root 911509 1月  31 2017 nginx-1.10.3.tar.gz
drwxr-xr-x 16 1001 1001   4096 4月  25 13:38 nginx-1.6.3

查看nginx-1.6.3

[root@nginx application]# /application/nginx-1.6.3/sbin/nginx -V
nginx version: nginx/1.6.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) 
configure arguments: --prefix=/application/nginx-1.6.3 --conf-path=/application/nginx-1.6.3/nginx.conf --user=www --group=www --with-http_stub_status_module

安裝nginx-1.10.3

tar xf nginx-1.10.3.tar.gz && cd nginx-1.10.3
./configure --prefix=/application/nginx-1.10.3 --conf-path=/application/nginx-1.10.3/nginx.conf --user=www --group=www --with-http_stub_status_module  --with-http_ssl_module
make && make install
  • 爲了驗證是否升級成功,將修改nginx-1.10.3主頁文件
echo 'hello'>/application/nginx-1.10.3/html/index.html

對舊版本的nginx啓動文件進行備份,並將新的啓動文件複製過來

mv /application/nginx-1.6.3/sbin/nginx /application/nginx-1.6.3/sbin/nginx.old
 mv /application/nginx-1.10.3/objs/nginx /application/nginx-1.6.3/sbin/

進行平滑升級操作

[root@nginx application]# ps -aux|grep nginx
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root       4072  0.0  0.0  23832   832 ?        Ss   13:38   0:00 nginx: master process /application/nginx-1.6.3/sbin/nginx
www        4073  0.0  0.1  24256  1512 ?        S    13:38   0:00 nginx: worker process              
root      10417  0.0  0.0 103348   852 pts/0    S+   14:52   0:00 grep nginx
[root@nginx application]#kill -USR2 
[root@nginx nginx-1.10.3]# kill -WINCH `cat /application/nginx-1.6.3/logs/nginx.pid.oldbin`
[root@nginx nginx-1.10.3]# kill -QUIT `cat /application/nginx-1.6.3/logs/nginx.pid.oldbin`

驗證

[root@nginx application]# curl localhost
hello
[root@nginx application]# /application/nginx-1.6.3/sbin/nginx -V
nginx version: nginx/1.10.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) 
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/application/nginx-1.10.3 --conf-path=/application/nginx-1.10.3/nginx.conf --user=www --group=www --with-http_stub_status_module --with-http_ssl_module
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章