nginx diversion servicing update process

1, be sure to want to switch to use normal service.

2. Change the virtual host address of the proxy nginx.conf in, to read above the target service (possibly test may be other servers in the cluster online one).

Such as vim /opt/nginx/conf/nginx.conf

server {

    listen       80;
    server_name  testing.com www.google.com;

    #charset koi8-r;

    access_log off;
    #access_log  /home/google/logs/nginx/access.log  google;

    location / {
            #proxy_pass  http://127.0.0.1:8080;
            proxy_pass  http://192.168.1.99:80;

            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
            client_max_body_size       5m;
            proxy_connect_timeout      150;
            proxy_send_timeout         150;
            proxy_read_timeout         150;
            proxy_next_upstream        error timeout invalid_header http_500;
            proxy_buffer_size          32k;
            proxy_buffers              32 64k;
            proxy_busy_buffers_size    128k;
    }

}

Change the above proxy_pass http://192.168.1.99:80 destination server address as: proxy_pass http://192.168.1.100:80 .

Then perform / under opt / nginx / sbin / nginx -t test, if .... successfully words appear, the profile changes without problems.

Then execute / opt / nginx / sbin / nginx -s reload, this information will not be output.

At this time, all access requests resolve to www.google.com port 80 on the machine 99 by DNS, port 80 is transferred to all of the 100 machine.

Note: Why emphasize dns? If you configure 192.168.1.99:80 www.google.com in the local hosts file will not return after dns ip address, direct access 192.168.1.99:80 this address.

Why emphasis on port 80? Since setting up only 80 ports can be accessed on an external server, the request came, the local machine before they can access any of their ports, such as 8080,8081 ...

Traffic is switched success!

Execute ps -ef | grep nginx, nginx process of view the situation:

google 11366 32142 1 16:47 ? 00:00:06 nginx: worker process is shutting down

google 11367 32142 0 16:47 ? 00:00:00 nginx: worker process is shutting down

google 11368 32142 0 16:47 ? 00:00:03 nginx: worker process is shutting down

google 11369 32142 0 16:47 ? 00:00:05 nginx: worker process is shutting down

google 11370 32142 1 16:47 ? 00:00:06 nginx: worker process is shutting down

google 11371 32142 2 16:47 ? 00:00:15 nginx: worker process is shutting down

google 11372 32142 1 16:47 ? 00:00:07 nginx: worker process is shutting down

google 11373 32142 1 16:47 ? 00:00:07 nginx: worker process is shutting down

google 11787 32142 0 16:57 ? 00:00:00 nginx: worker process

google 11788 32142 0 16:57 ? 00:00:00 nginx: worker process

google 11789 32142 0 16:57 ? 00:00:00 nginx: worker process

google 11790 32142 0 16:57 ? 00:00:00 nginx: worker process

google 11791 32142 0 16:57 ? 00:00:00 nginx: worker process

google 11792 32142 3 16:57 ? 00:00:00 nginx: worker process

google 11793 32142 1 16:57 ? 00:00:00 nginx: worker process

google 11794 32142 0 16:57 ? 00:00:00 nginx: worker process

Implementation of the above opt / nginx / sbin when reload nginx starts and an equal number of the original process / / nginx -s, and then wait for the original test in the process of performing the operation shut down.

After all threads are shut down

Update Service began on 99 machines, before that, the original 99 code on the machine back up! ! ! Remember Remember, be sure to back up! ! ! ! Unforeseen circumstances can be rolled back quickly! ! !

Start to see the process start to see success.

In the local hosts configuration 192.168.1.99 www.google.com can be directly accessed without service dns 99 machine to see normal or services, if normal, then the above steps will flow cut back.

Reproduced in: https: //www.cnblogs.com/xu-thinking/p/3666874.html

Guess you like

Origin blog.csdn.net/weixin_34198762/article/details/93374831