Service Management --Nginx

Nginx - Upgrade

Upgrade test a .Nginx

Source Package Installation (Configuration 2. 3. Installation compiler)

 

1. First unzip the upgrade package 
[root @ vlnx251101 ~] # tar XF nginx-1.13.4.tar.gz 

2. Go to the upgrade package that directory 
[root @ vlnx251101 ~] # cd nginx-1.13.4 / 

3. specify a directory and other issues (prce-8.40) supports regular 
[root @ vlnx251101 nginx-1.13.4] # ./configure --prefix = / usr / local / nginx --user = nginx --group = nginx --with-http_ssl_module - File-http_stub_status_module --with-with-AIO---with-http_dav_module --with PCRE = .. / PCRE-8.40 

[@ vlnx251101 Nginx the root-1.13.4] the make # 
4. View the current version 
[root @ vlnx251101 nginx- 1.13.4] # / usr / local / nginx / sbin / nginx -v 
nginx Version: nginx / 1.12.1
5. The old backup of the previous 
[root @ mysqlb nginx-1.13.4] # mv / usr / local / nginx / sbin / nginx /usr/local/nginx/sbin/nginx.bak 

[root @ mysqlb nginx-1.13 .4] # LS 
Auto CHANGES.ru the configure HTML Makefile src objs 
the CHANGES conf contrib LICENSE man the README 
[root @ mysqlb nginx-1.13.4] # cp objs / nginx / usr / local / nginx / sbin / 

6. View the current version 
[ @ mysqlb nginx-1.13.4 root] # / usr / local / nginx / sbin / nginx -v 
nginx Version: nginx / 1.13.4

 method one:

[root@mysqlb nginx-1.13.4]# make upgrade

  Method Two:

1. Review of nginx pid

[root@mysqlb ~]# ps -ef | grep nginx
root      64600      1  0 16:47 ?        00:00:00 nginx: master process /usr/local/ngin
/sbin/nginxnginx     64601  64600  0 16:47 ?        00:00:00 nginx: worker process
root      70426  58718  0 17:21 pts/3    00:00:00 grep --color=auto nginx

2. Perform kill -USR2 pid

[root@mysqlb ~]# kill -USR2 64600
[root@mysqlb ~]# ps -ef | grep nginx
root      64600      1  0 16:47 ?        00:00:00 nginx: master process /usr/local/ngin
/sbin/nginxnginx     64601  64600  0 16:47 ?        00:00:00 nginx: worker process
root      70428  64600  0 17:22 ?        00:00:00 nginx: master process /usr/local/ngin
/sbin/nginxnginx     70429  70428  0 17:22 ?        00:00:00 nginx: worker process
root      70432  58718  0 17:23 pts/3    00:00:00 grep --color=auto nginx
At this point, nginx examples of old and new versions will run at the same time, co-processing request input to phase out the older version of nginx instance, must send WINCH signal to the old master process, then it will begin the process of work to close normal:

3. Perform kill -WINCH pid

[root@mysqlb ~]# kill -WINCH 64600
[root@mysqlb ~]# ps -ef | grep nginx
root      64600      1  0 16:47 ?        00:00:00 nginx: master process /usr/local/ngin
/sbin/nginxroot      70428  64600  0 17:22 ?        00:00:00 nginx: master process /usr/local/ngin
/sbin/nginxnginx     70429  70428  0 17:22 ?        00:00:00 nginx: worker process
root      70434  58718  0 17:24 pts/3    00:00:00 grep --color=auto nginx
If you try to upgrade successfully, but also want to keep the new server, send QUIT signal to the old master process it quits, leaving only the new server is running.

4. Perform kill -QUIT pid

[root@mysqlb ~]# kill -QUIT 64600
[root@mysqlb ~]# ps -ef | grep nginx
root      70428      1  0 17:22 ?        00:00:00 nginx: master process /usr/local/ngin
/sbin/nginxnginx     70429  70428  0 17:22 ?        00:00:00 nginx: worker process
root      70436  58718  0 17:26 pts/3    00:00:00 grep --color=auto nginx

 

The old version is not performed prior to the fourth step can also be restored

[root@vlnx251101 ~]# rm -rf /usr/local/nginx/sbin/nginx
[root@vlnx251101 ~]# cp /usr/local/nginx/sbin/nginx.bak /usr/local/nginx/sbin/nginx

[root@vlnx251101 ~]# kill -HUP 44610
[root@vlnx251101 ~]# ps -ef | grep nginx
root      44610      1  0 12:40 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
root      74746  44610  0 14:38 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx    74747  74746  0 14:38 ?        00:00:00 nginx: worker process
nginx    77990  44610  0 14:53 ?        00:00:00 nginx: worker process

[root@vlnx251101 ~]# kill -QUIT 74746
[root@vlnx251101 ~]# ps -ef | grep nginx
root      44610      1  0 12:40 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx    77990  44610  0 14:53 ?        00:00:00 nginx: worker process

 Two. LuaJIT i.e. using Lua code written in C language interpreter

1. Download LuaJIT

Install yum install wget

[root@mysqlb ~]# wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz

2. Compile, install

[root@mysqlb ~]# tar xf LuaJIT-2.0.5.tar.gz

[root@mysqlb ~]# cd LuaJIT-2.0.5/

[root@mysqlb LuaJIT-2.0.5]# make install  PREFIX=/usr/local/luajit

[root@mysqlb LuaJIT-2.0.5]# echo "/usr/local/luajit/lib/" > /etc/ld.so.conf.d/usr_local_luajit_lib.conf

[root@mysqlb LuaJIT-2.0.5]# ldconfig (刷新配置文件)

3. Set Environment Variables

[root@mysqlb LuaJIT-2.0.5]# export LUAJIT_LIB=/usr/local/luajit/lib

[root@mysqlb LuaJIT-2.0.5]# export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0

4.Lua program

[root@mysqlb LuaJIT-2.0.5]# vim hello.lua

[root@mysqlb LuaJIT-2.0.5]# cat hello.lua
print ("Hello World")

[root@mysqlb LuaJIT-2.0.5]# lua hello.lua
Hello World

[root@mysqlb LuaJIT-2.0.5]# lua
Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> 
> print ("Hello World")
Hello World
> 

5. Download NDK and Lua_module

[root@mysqlb ~]# tar xf ngx_devel_kit-0.3.0.tar 
[root@mysqlb ~]# tar xf lua-nginx-module-0.10.10.tar 
[root@mysqlb ~]# tar xf nginx-1.13.4.tar 
[root@mysqlb ~]# cd nginx-1.13.4
[root@mysqlb nginx-1.13.4]# make clean
rm -rf Makefile objs
[root@mysqlb nginx-1.13.4]# ./configure --prefix=/usr/local/nginx1134 --user=nginx --gro
up=nginx --with-http_ssl_module --with-http_stub_status_module --with-file-aio --with-http_dav_module --with-pcre=../pcre-8.40 --add-module=../ngx_devel_kit-0.3.0 --add-module=../lua-nginx-module-0.10.10
[root@mysqlb nginx-1.13.4]# make && make install

6. Change profile

[root@mysqlb nginx-1.13.4]# vim /usr/local/nginx1134/conf/nginx.conf

 


[root @ mysqlb nginx-1.13.4] # echo 'ngx.say ( "Hello World")'> /tmp/hello.lua 
do remember killing 80-port process

[root @ mysqlb nginx-1.13.4] # pkill Nginx

[@ mysqlb Nginx the root-1.13.4] # / usr / local / nginx1134 / sbin / Nginx -C / usr / local / nginx1134 / the conf
/nginx.conf

7. results

[root@mysqlb nginx-1.13.4]# curl 192.168.88.101/test1
Hello world
[root@mysqlb nginx-1.13.4]# curl 192.168.88.101/test2
Hello World

  

 

 

  

Guess you like

Origin www.cnblogs.com/MR-ws/p/11202711.html