zoukankan      html  css  js  c++  java
  • Nginx的平滑升级

    Nginx的平滑升级

    1、查看原先系统Nginx版本和编译参数并记录

    [root@localhost ~]# nginx -v
    nginx version: nginx/1.13.12
    
    [root@localhost ~]# nginx -V
    nginx version: nginx/1.13.12
    built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) 
    configure arguments: --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_addition_module --with-http_xslt_module --with-pcre
    

    2、下载最新版本Nginx并解压

    [root@localhost ~]# wget http://nginx.org/download/nginx-1.14.1.tar.gz
    --2018-11-15 02:24:36--  http://nginx.org/download/nginx-1.14.1.tar.gz
    Resolving nginx.org (nginx.org)... 95.211.80.227, 206.251.255.63, 2001:1af8:4060:a004:21::e3, ...
    Connecting to nginx.org (nginx.org)|95.211.80.227|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 1014040 (990K) [application/octet-stream]
    Saving to: ‘nginx-1.14.1.tar.gz’
    
    100%[==================================================================================================================================>] 1,014,040    117KB/s   in 7.6s   
    
    2018-11-15 02:24:44 (130 KB/s) - ‘nginx-1.14.1.tar.gz’ saved [1014040/1014040]
    
    [root@localhost ~]# tar -zxf nginx-1.14.1.tar.gz 
    

    3、编译Nginx 1.14.1

    [root@localhost ~]# cd nginx-1.14.1
    
    [root@localhost nginx-1.14.1]# ./configure --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_addition_module --with-http_xslt_module --with-pcre
    
    [root@localhost nginx-1.14.1]# make    #到make这一步即可,不需要执行make install
    
    

    4、备份原来的nginx启动脚本

    [root@localhost nginx-1.14.1]# cd /usr/local/nginx/sbin/
    
    [root@localhost sbin]# mv nginx nginx_old
    

    5、拷贝nginx-1.14.1目录下的obj目录下的nginx到nginx的sbin目录下

    [root@localhost sbin]# cp /root/nginx-1.14.1/objs/nginx /usr/local/nginx/sbin/
    

    6、回到nginx-1.14.1目录下执行make upgrade

    [root@localhost sbin]# cd /root/nginx-1.14.1
    
    [root@localhost nginx-1.14.1]# make upgrade  #这一步会将结束旧进程,并开启新的进程进行管理nginx的任务,从而达到平滑升级的效果
    /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
    kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
    sleep 1
    test -f /usr/local/nginx/logs/nginx.pid.oldbin
    kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`
    
    这里需要注意的是,使用make upgrade进行平滑升级时,会默认发送USR2信号到/usr/local/nginx/logs/nginx.pid,但是如果你的pid文件位置不一致,就会出现文件不存在的ERROR
    而我们需要做的是,放弃使用make upgrade,而是直接使用以下命令,假设nginx.pid的路径为:/var/run/nginx.pid
    [root@localhost nginx-1.14.1]# /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.14.1]# kill -USR2 `cat /var/run/nginx.pid`
    此时会在/var/run/下生成一个nginx.pid.oldbin的pid文件
    [root@localhost nginx-1.14.1]# kill -QUIT `cat /var/run/nginx.pid.oldbin`  #退出旧进程
    

    7、查看nginx的最新版本

    [root@localhost nginx-1.14.1]# nginx -v
    nginx version: nginx/1.14.1
    
    [root@localhost nginx-1.14.1]# nginx -V
    nginx version: nginx/1.14.1
    built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) 
    configure arguments: --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_addition_module --with-http_xslt_module --with-pcre
    
    
  • 相关阅读:
    轮询算法
    随机算法
    加权随机算法
    平滑加权轮询算法
    预训练模型与Keras.applications.models权重资源地址
    多通道卷积操作解析
    Squeeze-and-Excitation Networks
    实验数据集概况
    Keras-图片预处理
    Keras常用层
  • 原文地址:https://www.cnblogs.com/linuxk/p/9963916.html
Copyright © 2011-2022 走看看