zoukankan      html  css  js  c++  java
  • 原创:Nginx*实战部署

    均衡负载服务器 10.0.0.9

    [root@web03 conf]# vim nginx.conf

    worker_processes  1;

                events {

                    worker_connections  1024;

                }

                http {

                    include       mime.types;

                    default_type  application/octet-stream;

                    sendfile        on;

                    keepalive_timeout  65;

                    upstream server_pools {

               ## ip_hash;

               server 10.0.0.7:80 weight=1 max_fails=3 fail_timeout=10;

               server 10.0.0.8:80 weight=1        

               max_fails=3 fail_timeout=10 ;

                    }

                    server {

                        listen 80;

                        server_name bbs.etiantian.org;

                        location / {

                            proxy_pass http://server_pools;

                        }

                      }

               }

    hosts

    [root@web03 conf]# cat /etc/hosts

    127.0.0.1    localhost localhost.localdomain localhost4 localhost4.localdomain4

    ::1          localhost localhost.localdomain localhost6 localhost6.localdomain6

    172.16.1.5     lb01

    172.16.1.6     lb02

    172.16.1.7     web02

    172.16.1.9     web03

    172.16.1.8     web01 bbs.etiantian.org www.etiantian.org

    172.16.1.51     db01 db01.etiantian.org

    172.16.1.31     nfs01

    172.16.1.41     backup

    172.16.1.61     m01

      web服务器1   10.0.0.7

                               [root@web02 conf]# cat nginx.conf

    worker_processes  1;

          events {

              worker_connections  1024;

          }

          http {

              include       mime.types;

              default_type  application/octet-stream;

              sendfile        on;

              keepalive_timeout  65;

              log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                                '$status $body_bytes_sent "$http_referer" '

                                '"$http_user_agent" "$http_x_forwarded_for"';

              server {

                  listen       80;

                  server_name  bbs.etiantian.org;

                  location / {

                      root   html/bbs;

                      index  index.html index.htm;

                  }

      access_log  logs/access_bbs.log  main;

              }  

              server {

                  listen       80;

                  server_name  www.etiantian.org;

                  location / {

                      root   html/www;

                      index  index.html index.htm;

                  }

                  access_log  logs/access_www.log  main;

              }

    }

    hosts

    [root@web02 conf]# cat /etc/hosts

    127.0.0.1    localhost localhost.localdomain localhost4 localhost4.localdomain4

    ::1          localhost localhost.localdomain localhost6 localhost6.localdomain6

    172.16.1.5     lb01

    172.16.1.6     lb02

    172.16.1.7     web02 bbs.etiantianorg www.etiantian.org blog.etiantian.org

    172.16.1.9     web03

    172.16.1.8     web01

    172.16.1.51     db01 db01.etiantian.org

    172.16.1.31     nfs01

    172.16.1.41     backup

    172.16.1.61     m01

    10.0.0.9       bbs.etiantianorg www.etiantian.org blog.etiantian.org

    web服务器2 10.0.0.8

    [root@web01 conf]# cat nginx.conf

     worker_processes  1;

          events {

              worker_connections  1024;

          }

          http {

              include       mime.types;

              default_type  application/octet-stream;

              sendfile        on;

              keepalive_timeout  65;

              log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                                '$status $body_bytes_sent "$http_referer" '

                                '"$http_user_agent" "$http_x_forwarded_for"';

              server {

                  listen       80;

                  server_name  bbs.etiantian.org;

                  location / {

                      root   html/bbs;

                      index  index.html index.htm;

                  }

      access_log  logs/access_bbs.log  main;

              }  

              server {

                  listen       80;

                  server_name  www.etiantian.org;

                  location / {

                      root   html/www;

                      index  index.html index.htm;

                  }

                  access_log  logs/access_www.log  main;

              }

    }

    hosts

    [root@web01 conf]# cat /etc/hosts

    127.0.0.1    localhost localhost.localdomain localhost4 localhost4.localdomain4

    ::1          localhost localhost.localdomain localhost6 localhost6.localdomain6

    172.16.1.5     lb01

    172.16.1.6     lb02

    172.16.1.7     web02

    #172.16.1.8     web01   www.etiantian.org bbs.etiantian.org blog.etiantian.org

    #172.16.1.9     web03

    172.16.1.51     db01 db01.etiantian.org

    172.16.1.31     nfs01

    172.16.1.41     backup

    172.16.1.61     m01

    10.0.0.9     www.etiantian.org bbs.etiantian.org blog.etiantian.org etiantian.org

    总结

    1 两个web服务器的nginx.conf 必须是一样的

    2两个web都解析负载均衡服务器

    3本地win hosts解析负载均衡服务器

                  

  • 相关阅读:
    Pytest中参数化之Excel文件实战
    PyCharm 专业版 2018激活(pycharm-professional-2018.2.4.exe)
    python语言编写一个接口测试的例子,涉及切割获取数据,读取表格数据,将结果写入表格中
    webdriver之UI界面下拉框的选择
    git的安装与详细应用
    安装jenkins
    python对数据库mysql的操作(增删改查)
    批量执行测试用例
    面向对象中多态的讲解+工厂设计模式的应用与讲解
    面向对象
  • 原文地址:https://www.cnblogs.com/dsab/p/7522545.html
Copyright © 2011-2022 走看看