zoukankan      html  css  js  c++  java
  • nginx负载均衡服务器搭建

    准备:每台服务器都需要安装nginx

    1、关闭防火墙
    service iptables stop
    2、关闭selinux
    setenforce 0
    3、安装基本依赖
    yum install -y gcc pcre-devel openssl-devel
    4、安装nginx
    useradd www -s /sbin/nologin #创建nginx运行账户www,不允许直接登录系统

    cd /lnmp/src/
    tar -zxvf nginx-1.11.5.tar.gz
    cd nginx-1.11.5

    ./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www
    --group=www --with-http_stub_status_module --with-http_ssl_module

    make && make install

    设置nginx开启启动
    cp /lnmp/src/nginx /etc/rc.d/init.d/ #拷贝启动文件
    chmod 755 /etc/rc.d/init.d/nginx #赋予文件执行权限
    cnkconfig nginx on #设置开机启动
    service nginx start #启动nginx
    5、配置nginx
    名称 IP 功能
    load balance: 10.0.166.17 负责任务的分配
    web server01: 10.0.166.18 实际提供web服务
    web server02: 10.0.166.19 实际提供web服务

    http {
    upstream lb { #连接池,存放提供web服务的服务器地址
    server 10.0.166.18 weight=5; #一台web服务器地址,权重5/6
    server 10.0.166.19 weight=1; #一台web服务器地址,权重1/6
    }

    server {
    location / {
    proxy_pass http://lb; #指定代理连接池
    proxy_set_header Host $host; #转发请求头信息
    proxy_set_header X-Forward-For $remote_addr; #转发请求IP地址
    }
    }
    }

  • 相关阅读:
    文字对战小游戏~~~
    面向对象--类库、委托、is和as运算符、泛型集合
    推箱子
    算法训练 K好数
    用memset设置无穷大无穷小
    算法训练 关联矩阵
    未名湖边的烦恼
    数字三角形
    算法训练 最大最小公倍数
    算法训练 区间k大数查询
  • 原文地址:https://www.cnblogs.com/huangcanbin/p/12574433.html
Copyright © 2011-2022 走看看