大数据linux tools

LVS、nginx反向代理

2019-04-15  本文已影响37人  请叫我飘哥

1、LVS实现nat,dr

* 搭建过程
    * 在VS服务器上安装ipvsadm命令行工具(Centos默认开启了ipvs模块)
    `yum -y install ipvsadm`
    * 创建集群
    ```
    ipvsadm -A -t 10.192.1.170:80 -s rr
    ipvsadm -a -t 10.192.1.170:80 -r 10.192.1.163 -g
    ipvsadm -a -t 10.192.1.170:80 -r 10.192.1.164 -g
    ```
   * 查看集群
   ```
   [root@vs ~]# ipvsadm -ln
  IP Virtual Server version 1.2.1 (size=4096)
  Prot LocalAddress:Port Scheduler Flags
    -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
  TCP  10.192.1.170:80 rr
    -> 10.192.1.163:80              Route   1      0          0         
    -> 10.192.1.164:80              Route   1      0          0         
  [root@vs ~]# 

   ```
  * 在RS服务器上安装并配置nginx静态test.html页面
  * curl测试访问
  ```
  [root@yum ~]# for i in {1..10};do curl 10.192.1.170/test.html;done
  <h1> RS1 10.192.1.164 <h1>
  <h1> RS2 10.192.1.163 <h1>
  <h1> RS1 10.192.1.164 <h1>
  <h1> RS2 10.192.1.163 <h1>
  <h1> RS1 10.192.1.164 <h1>
  <h1> RS2 10.192.1.163 <h1>
  <h1> RS1 10.192.1.164 <h1>
  <h1> RS2 10.192.1.163 <h1>
  <h1> RS1 10.192.1.164 <h1>
  <h1> RS2 10.192.1.163 <h1>
  [root@yum ~]# 
  在VS查看
  [root@vs ~]# ipvsadm -ln
  IP Virtual Server version 1.2.1 (size=4096)
  Prot LocalAddress:Port Scheduler Flags
    -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
  TCP  10.192.1.170:80 rr
    -> 10.192.1.163:80              Route   1      0          5         
    -> 10.192.1.164:80              Route   1      0          5   
  ```      

2、nginx反向代理,虚拟主机

上一篇 下一篇

猜你喜欢

热点阅读