Get the App
SLTechnology News&Howtos  ›  Servers  › 

Nginx hot deployment upgrad

Shulou Source: shulou.com Published: 2022-06-02 21:17:18 09月28日 Update

I. Hot upgrade process

1. Replace the old nginx file with the new nginx binary file (pay attention to backup)

2. Send USR2 signal to master process

3. The master process modifies the pid file name with the suffix. oldbin

4. The master process starts the new master process after using the new nginx file

5. Send WINCH signal to the old master process to shut down the old worker process.

6. Rollback: send HUP signal to the old master and QUIT to the new master

II. Upgrade process

# version

Nginx version: nginx/1.12.2

1. View nginx status

2. To upgrade the nginx version is to upgrade the binaries

Path: / nginx/sbin/nginx

1) back up the original files and replace the new nginx binaries

# cp sbin/nginx sbin/nginx.old

2) after compiling the new version to make, copy the binary nginx file (remember to compile to the same directory)

# cd nginx-1.14.2/

#. / configure-prefix=/usr/local/nginx12

3make

# cp-r objs/nginx / usr/local/nginx12/sbin/-f

3) View binaries

Cd / usr/local/nginx/sbin/

4) send an upgrade signal to the process number

# kill-USR2 1501 # master thread

5) gracefully close the old thread

# kill-WINCH 1501

Note: keep the old master thread, which can be used for rollback. If you confirm that you don't need it, you can kill it.

4) View version

Note: if we have a problem after the upgrade, we can take the next step to roll back.

3. Rollback operation

1) back up files again

# cp-f / usr/local/nginx12/sbin/nginx.old / usr/local/nginx12/sbin/nginx

2) perform smoothing to generate a new process

# kill-HUP 4197

# kill-QUIT 4197

The master process is rolled back to 1501 and the worker process is also regenerated. Check the website and complete the rollback operation here.

3) View version

Tags: Files processes upgrades binaries signals versions backups threads comments issues checks generation compilation elegance smoothing suffixes file names processes status directories Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Technology Huawei Shulou Tech Info NVidia