1.1 负载均衡介绍

1.1.1 负载均衡的妙用

1.1.2 为什么要用lvs

那为什么要用lvs****呢?

1.2 LVS介绍

1.2.1 相关参考资料

LVS官网:http://www.linuxvirtualserver.org/index.html

相关中文资料

 

 

1.2.2 LVS内核模块ip_vs介绍

1.3 LVS集群搭建

1.3.1 集群环境说明

<td style="width: 18.32%; border-top: solid #4472C4 1.0pt; border-left: none; border-bottom: solid #4472C4 1.0pt; border-right: none; background: #4472C4; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top" width="18%">
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <strong><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; color: white;">IP</span></strong><strong><span style="font-size: 10.0pt; font-family: 宋体; times new roman"4times new roman";times new roman";color: white;">地址</span></strong>
  </p>
</td>

<td style="width: 25.36%; border-top: solid #4472C4 1.0pt; border-left: none; border-bottom: solid #4472C4 1.0pt; border-right: none; background: #4472C4; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top" width="25%">
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <strong><span style="font-size: 10.0pt; font-family: 宋体; times new roman"4times new roman";times new roman";color: white;">软件</span></strong>
  </p>
</td>

<td style="width: 46.46%; border-top: 1pt solid #4472c4; border-right: 1pt solid #4472c4; border-bottom: 1pt solid #4472c4; border-left: none; background: #4472c4; padding: 0cm 5.4pt;" valign="top" width="46%">
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <strong><span style="font-size: 10.0pt; font-family: 宋体; times new roman"4times new roman";times new roman";color: white;">系统版本</span></strong>
  </p>
</td>
<td style="width: 18.32%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top" width="18%">
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">10.0.0.15</span>
  </p>
</td>

<td style="width: 25.36%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top" width="25%">
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">lvs keepalived</span>
  </p>
</td>

<td style="width: 46.46%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top" width="46%">
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">CentOS Linux release 7.4.1708</span>
  </p>
</td>
<td style="width: 18.32%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top" width="18%">
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">10.0.0.16</span>
  </p>
</td>

<td style="width: 25.36%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top" width="25%">
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">lvs keepalived</span>
  </p>
</td>

<td style="width: 46.46%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top" width="46%">
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">CentOS Linux release 7.4.1708</span>
  </p>
</td>
<td style="width: 18.32%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top" width="18%">
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">10.0.0.18</span>
  </p>
</td>

<td style="width: 25.36%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top" width="25%">
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">tomcat</span>
  </p>
</td>

<td style="width: 46.46%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top" width="46%">
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">CentOS Linux release 7.4.1708</span>
  </p>
</td>
<td style="width: 18.32%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top" width="18%">
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">10.0.0.17</span>
  </p>
</td>

<td style="width: 25.36%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top" width="25%">
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">tomcat</span>
  </p>
</td>

<td style="width: 46.46%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top" width="46%">
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">CentOS Linux release 7.4.1708</span>
  </p>
</td>

主机说明

web__环境说明

  web服务器的搭建参照: Tomcat: http://www.cnblogs.com/clsn/p/7904611.html

               Nginx: http://www.cnblogs.com/clsn/p/7750615.html

1.3.2 安装ipvsadm管理工具

1.3.3 LVS集群搭建

命令集****

检查结果****

ipvsadm参数说明:(更多参照 man ipvsadm)

  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <span style="color: #ffffff;"><strong><em><span style="font-size: 10pt; font-family: 'Times New Roman', serif;">(</span></em></strong><strong><em><span style="font-size: 10.0pt; font-family: 宋体; times new roman"4times new roman";times new roman";color: white;">短格式</span></em></strong><strong><em><span style="font-size: 10pt; font-family: 'Times New Roman', serif;">)</span></em></strong></span>
  </p>
</td>

<td style="width: 31.18%; border-top: solid #4472C4 1.0pt; border-left: none; border-bottom: solid #4472C4 1.0pt; border-right: none; background: #4472C4; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <span style="color: #ffffff;"><strong><span style="font-size: 10.0pt; font-family: 宋体; times new roman"4times new roman";times new roman";color: white;">参数</span></strong></span>
  </p>
  
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <span style="color: #ffffff;"><strong><em><span style="font-size: 10pt; font-family: 'Times New Roman', serif;">(</span></em></strong><strong><em><span style="font-size: 10.0pt; font-family: 宋体; times new roman"4times new roman";times new roman";color: white;">长格式</span></em></strong><strong><em><span style="font-size: 10pt; font-family: 'Times New Roman', serif;">)</span></em></strong></span>
  </p>
</td>

<td style="width: 56.66%; border-top: 1pt solid #4472c4; border-right: 1pt solid #4472c4; border-bottom: 1pt solid #4472c4; border-left: none; background: #4472c4; padding: 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <span style="color: #ffffff;"><strong><span style="font-size: 10.0pt; font-family: 宋体; times new roman"4times new roman";times new roman";color: white;">参数说明</span></strong></span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--add-service</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">在内核的虚拟服务器表中添加一条新的虚拟服务器记录。也就是增加一台新的虚拟服务器。</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--edit-service</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">编辑内核虚拟服务器表中的一条虚拟服务器记录。</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--delete-service</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">删除内核虚拟服务器表中的一条虚拟服务器记录。</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--clear</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">清除内核虚拟服务器表中的所有记录。</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--restore</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">恢复虚拟服务器规则</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--save</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">保存虚拟服务器规则,输出为</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">-R </span><span style="font-size: 10.0pt; font-family: 宋体;">选项可读的格式</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--add-server</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">在内核虚拟服务器表的一条记录里添加一条新的真实服务器记录。也就是在一个虚拟服务器中增加一台新的真实服务器</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--edit-server</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">编辑一条虚拟服务器记录中的某条真实服务器记录</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--delete-server</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">删除一条虚拟服务器记录中的某条真实服务器记录</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--list</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">显示内核虚拟服务器表</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--zero</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">虚拟服务表计数器清零(清空当前的连接数量等)</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--set<em> tcp tcpfin udp</em></span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">设置连接超时值</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--start-daemon</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">启动同步守护进程。他后面可以是</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">master </span><span style="font-size: 10.0pt; font-family: 宋体;">或</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">backup</span><span style="font-size: 10.0pt; font-family: 宋体;">,用来说明</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">LVS Router </span><span style="font-size: 10.0pt; font-family: 宋体;">是</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">master </span><span style="font-size: 10.0pt; font-family: 宋体;">或是</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">backup</span><span style="font-size: 10.0pt; font-family: 宋体;">。在这个功能上也可以采用</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">keepalived </span><span style="font-size: 10.0pt; font-family: 宋体;">的</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">VRRP </span><span style="font-size: 10.0pt; font-family: 宋体;">功能。</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--stop-daemon</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">停止同步守护进程</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--help </span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">显示帮助信息</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--tcp-service <em>service-address [vip:port] or [real-server-ip:port]</em></span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">说明虚拟服务器提供的是</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">tcp </span><span style="font-size: 10.0pt; font-family: 宋体;">的服务</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--udp-service <em>service-address [vip:port] or [real-server-ip:port]</em></span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">说明虚拟服务器提供的是</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">udp </span><span style="font-size: 10.0pt; font-family: 宋体;">的服务</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--fwmark-service <em>fwmark</em></span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">说明是经过</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">iptables </span><span style="font-size: 10.0pt; font-family: 宋体;">标记过的服务类型。</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--scheduler <em>scheduler</em></span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">使用的调度算法,有这样几个选项</span>
  </p>
  
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq</span>
  </p>
  
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">默认的调度算法是:</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;"> wlc</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--persistent <em>[timeout]</em></span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">持久稳固的服务。这个选项的意思是来自同一个客户的多次请求,将被同一台真实的服务器处理。</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">timeout </span><span style="font-size: 10.0pt; font-family: 宋体;">的默认值为</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">300</span><span style="font-size: 10.0pt; font-family: 宋体;">秒。</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--netmask netmask</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">persistent granularity mask</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--real-server <em>server-address</em></span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">真实的服务器</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">[Real-Server:port]</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--gatewaying</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">指定</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">LVS </span><span style="font-size: 10.0pt; font-family: 宋体;">的工作模式为直接路由模式(也是</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">LVS </span><span style="font-size: 10.0pt; font-family: 宋体;">默认的模式)</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--ipip</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">指定</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">LVS </span><span style="font-size: 10.0pt; font-family: 宋体;">的工作模式为隧道模式</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--masquerading</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">指定</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">LVS </span><span style="font-size: 10.0pt; font-family: 宋体;">的工作模式为</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">NAT </span><span style="font-size: 10.0pt; font-family: 宋体;">模式</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--weight <em>weight</em></span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">真实服务器的权值</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--mcast-interface</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">interface </span><span style="font-size: 10.0pt; font-family: 宋体;">指定组播的同步接口</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--connection</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">显示</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">LVS </span><span style="font-size: 10.0pt; font-family: 宋体;">目前的连接</span> <span style="font-size: 10.0pt; font-family: 宋体;">如:</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">ipvsadm -L -c</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--timeout&nbsp;&nbsp;&nbsp; </span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">显示</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">tcp tcpfin udp </span><span style="font-size: 10.0pt; font-family: 宋体;">的</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">timeout </span><span style="font-size: 10.0pt; font-family: 宋体;">值</span> <span style="font-size: 10.0pt; font-family: 宋体;">如:</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">ipvsadm -L --timeout</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--daemon&nbsp;&nbsp;&nbsp;&nbsp; </span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">显示同步守护进程状态</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--stats&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">显示统计信息</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--rate&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">显示速率信息</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--sort&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">对虚拟服务器和真实服务器排序输出</span>
  </p>
</td>
<td style="width: 31.18%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="31%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">--numeric -n</span>
  </p>
</td>

<td style="width: 56.66%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="56%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">输出</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">IP </span><span style="font-size: 10.0pt; font-family: 宋体;">地址和端口的数字形式</span>
  </p>
</td>

1.3.4 web浏览器配置操作

命令集

cat »/etc/sysctl.conf<<EOF net.ipv4.conf.all.arp_ignore = 1 net.ipv4.conf.all.arp_announce = 2 net.ipv4.conf.lo.arp_ignore = 1 net.ipv4.conf.lo.arp_announce = 2 EOF sysctl -p

至此LVS集群配置完毕

1.3.5 进行访问测试

         命令行测试:

         抓包查看结果:

         arp__解析查看:

1.4 负载均衡(LVS)相关名词

1.4.1 LVS集群的工作模式–DR直接路由模式

DR__直接路由模式说明:

1.5 web端的操作有什么含义?

1.5.1 RealServer为什么要在lo接口上配置VIP

  在lo上配置vip能够完成接收包并将结果返回client

1.5.2 eth0网卡上配置VIP可以吗?

1.5.3 为什么要抑制ARP响应?

ARP__缓存表是把双刃剑

lvsDR模式下需要关闭arp功能

<td style="width: 87.84%; border-top: 1pt solid #4472c4; border-right: 1pt solid #4472c4; border-bottom: 1pt solid #4472c4; border-left: none; background: #4472c4; padding: 0cm 5.4pt;" valign="top" width="87%">
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <strong><span style="font-size: 10.0pt; font-family: 宋体; times new roman"4times new roman";times new roman";color: white;">含义</span></strong>
  </p>
</td>
<td style="width: 87.84%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top" width="87%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">在任意网络接口(</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">eth0,eth1</span><span style="font-size: 10.0pt; font-family: 宋体;">,</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">lo</span><span style="font-size: 10.0pt; font-family: 宋体;">)上的任何本地地址</span>
  </p>
</td>
<td style="width: 87.84%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top" width="87%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">尽量避免不在该网络接口子网段的本地地址做出</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">arp</span><span style="font-size: 10.0pt; font-family: 宋体;">回应</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">. </span><span style="font-size: 10.0pt; font-family: 宋体;">当发起</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">ARP</span><span style="font-size: 10.0pt; font-family: 宋体;">请求的源</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">IP</span><span style="font-size: 10.0pt; font-family: 宋体;">地址</span> <span style="font-size: 10.0pt; font-family: 宋体;">是被设置应该经由路由达到此网络接口的时候很有用</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">.</span><span style="font-size: 10.0pt; font-family: 宋体;">此时会检查来访</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">IP</span><span style="font-size: 10.0pt; font-family: 宋体;">是否为所有接口</span> <span style="font-size: 10.0pt; font-family: 宋体;">上的子网段内</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">ip</span><span style="font-size: 10.0pt; font-family: 宋体;">之一</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">.</span><span style="font-size: 10.0pt; font-family: 宋体;">如果改来访</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">IP</span><span style="font-size: 10.0pt; font-family: 宋体;">不属于各个网络接口上的子网段内</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">,</span><span style="font-size: 10.0pt; font-family: 宋体;">那么将采用级别</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">2</span><span style="font-size: 10.0pt; font-family: 宋体;">的方式来进行处理</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">.</span>
  </p>
</td>
<td style="width: 87.84%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" valign="top" width="87%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">对查询目标使用最适当的本地地址</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">.</span><span style="font-size: 10.0pt; font-family: 宋体;">在此模式下将忽略这个</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">IP</span><span style="font-size: 10.0pt; font-family: 宋体;">数据包的源地址并尝试</span> <span style="font-size: 10.0pt; font-family: 宋体;">选择与能与该地址通信的本地地址</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">.</span><span style="font-size: 10.0pt; font-family: 宋体;">首要是选择所有的网络接口的子网中外出访问子网中</span> <span style="font-size: 10.0pt; font-family: 宋体;">包含该目标</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">IP</span><span style="font-size: 10.0pt; font-family: 宋体;">地址的本地地址</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">. </span><span style="font-size: 10.0pt; font-family: 宋体;">如果没有合适的地址被发现</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">,</span><span style="font-size: 10.0pt; font-family: 宋体;">将选择当前的发送网络接口</span> <span style="font-size: 10.0pt; font-family: 宋体;">或其他的有可能接受到该</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">ARP</span><span style="font-size: 10.0pt; font-family: 宋体;">回应的网络接口来进行发送</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">.</span>
  </p>
</td>
<td style="width: 83.78%; border-top: 1pt solid #4472c4; border-right: 1pt solid #4472c4; border-bottom: 1pt solid #4472c4; border-left: none; background: #4472c4; padding: 0cm 5.4pt;" width="83%">
  <p style="margin-bottom: .0001pt; text-align: center;" align="center">
    <strong><span style="font-size: 10.0pt; font-family: 宋体; times new roman"4times new roman";times new roman";color: white;">含义</span></strong>
  </p>
</td>
<td style="width: 83.78%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="83%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">回应任何网络接口上对任何本地</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">IP</span><span style="font-size: 10.0pt; font-family: 宋体;">地址的</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">arp</span><span style="font-size: 10.0pt; font-family: 宋体;">查询请求</span>
  </p>
</td>
<td style="width: 83.78%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="83%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">只回答目标</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">IP</span><span style="font-size: 10.0pt; font-family: 宋体;">地址是来访网络接口本地地址的</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">ARP</span><span style="font-size: 10.0pt; font-family: 宋体;">查询请求</span>
  </p>
</td>
<td style="width: 83.78%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="83%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">只回答目标</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">IP</span><span style="font-size: 10.0pt; font-family: 宋体;">地址是来访网络接口本地地址的</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">ARP</span><span style="font-size: 10.0pt; font-family: 宋体;">查询请求</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">,</span><span style="font-size: 10.0pt; font-family: 宋体;">且来访</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">IP</span><span style="font-size: 10.0pt; font-family: 宋体;">必须在该网络接口的子网段内</span>
  </p>
</td>
<td style="width: 83.78%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="83%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">不回应该网络界面的</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">arp</span><span style="font-size: 10.0pt; font-family: 宋体;">请求,而只对设置的唯一和连接地址做出回应</span>
  </p>
</td>
<td style="width: 83.78%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; background: #D9E2F3; padding: 0cm 5.4pt 0cm 5.4pt;" width="83%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">保留未使用</span>
  </p>
</td>
<td style="width: 83.78%; border-top: none; border-left: none; border-bottom: solid #8EAADB 1.0pt; border-right: solid #8EAADB 1.0pt; padding: 0cm 5.4pt 0cm 5.4pt;" width="83%">
  <p style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体;">不回应所有(本地地址)的</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif;">arp</span><span style="font-size: 10.0pt; font-family: 宋体;">查询</span>
  </p>
</td>

1.6 LVS集群的工作模式

1.6.1 LVS集群的工作模式–NAT

NAT****方式的实现原理和数据包的改变

LVS-NAT**模型的特性**

1.6.2 LVS集群的工作模式隧道模式TUN

LVS-Tun模型特性

1.6.3 LVS集群的工作模式–FULLNAT

1.7 IPVS调度器实现了如下八种负载调度算法:

 

 

 

 

 

 

 

源地址散列"调度算法根据请求的源IP地址,作为散列键(Hash Key)从静态分配的散列表找出对应的服务器,若该服务器是可用的且未超载,将请求发送到该服务器,否则返回空。

1.8 LVS+Keepalived方案实现

1.8.1 keepalived功能

1.8.2 在负载器安装Keepalived软件

# 检查软件是否安装

1.8.3 修改配置文件

<p style="margin-left: 7.1pt;">
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <em><span style="text-decoration: underline;"><span style="background: yellow;">lb04</span></span></em><em><span style="text-decoration: underline;"><span style="font-family: 等线; background: yellow;">的</span><span style="background: yellow;">Keepalied</span></span></em><em><span style="text-decoration: underline;"><span style="font-family: 等线; background: yellow;">配置文件</span></span></em>
</p>

<div class="cnblogs_code" onclick="cnblogs_code_show('fadb947f-dcd8-4aa5-bdbf-6981fd152194')">
  <img id="code_img_closed_fadb947f-dcd8-4aa5-bdbf-6981fd152194" class="code_img_closed" src="https://clsn.io/wp-content/uploads/2018/03/ContractedBlock-14.gif" alt="高并发场景 LVS 安装及高可用实现" alt="" /><img id="code_img_opened_fadb947f-dcd8-4aa5-bdbf-6981fd152194" class="code_img_opened" style="display: none;" onclick="cnblogs_code_hide('fadb947f-dcd8-4aa5-bdbf-6981fd152194',event)" data-original="https://clsn.io/wp-content/uploads/2018/03/ExpandedBlockStart-14.gif" src="/wp-content/themes/clsn-003/img/blank.gif" alt="高并发场景 LVS 安装及高可用实现" alt="" /></p> 
  
  <div id="cnblogs_code_open_fadb947f-dcd8-4aa5-bdbf-6981fd152194" class="cnblogs_code_hide">
    <pre><span style="color: #008080;"> 1</span> [root@lb04 ~]<span style="color: #008000;">#</span><span style="color: #008000;"> cat /etc/keepalived/keepalived.conf</span>

2 global_defs { 3 router_id LVS_02 4 } 5 6 vrrp_instance VI_1 { 7 state BACKUP 8 interface eth0 9 virtual_router_id 51 10 priority 100 11 advert_int 1 12 authentication { 13 auth_type PASS 14 auth_pass 1111 15 } 16 virtual_ipaddress { 17 10.0.0.13/24 18 } 19 } 20 virtual_server 10.0.0.13 80 { 21 delay_loop 6
22 lb_algo wrr
23 lb_kind DR
24 nat_mask 255.255.255.0 25 persistence_timeout 50
26 protocol TCP
27 28 real_server 10.0.0.17 80 { 29 weight 1
30 TCP_CHECK { 31 connect_timeout 8
32 nb_get_retry 3 33 delay_before_retry 3 34 connect_port 80 35 } 36 } 37 38 real_server 10.0.0.18 80 { 39 weight 1
40 TCP_CHECK { 41 connect_timeout 8
42 nb_get_retry 3 43 delay_before_retry 3 44 connect_port 80 45 } 46 } 47 }

  <p>
    <span class="cnblogs_code_collapse">lb04 /etc/keepalived/keepalived.conf</span></div> 
    
    <p>
      <strong><em><span style="text-decoration: underline;">keepalived</span></em></strong> <strong>persistence_timeout</strong><strong><span style="font-family: 等线;">参数意义</span></strong> LVS Persistence <span style="font-family: 等线;">参数的作用</span>
    </p>
    
    <p style="text-indent: 15.75pt;">
      <em><span style="text-decoration: underline;">http://blog.csdn.net/nimasike/article/details/53911363 </span></em>
    </p>
    
    <h3>
      <span id="184_keepalived">1.8.4 <span style="font-family: '微软雅黑',sans-serif;">启动</span>keepalived<span style="font-family: '微软雅黑',sans-serif;">服务</span></span>
    </h3>
    
    <div class="cnblogs_code">
      <pre>[root@lb03 ~]<span style="color: #008000;">#</span><span style="color: #008000;"> systemctl restart  keepalived.service </span><span style="color: #008000;">

# 检查lvs状态 [root@lb03 ~]# ipvsadm -ln IP Virtual Server version 1.2.1 (size=4096) Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConn TCP 10.0.0.13:80 wrr persistent 50 -> 10.0.0.17:80 Route 1 0 0
-> 10.0.0.18:80 Route 1 0 0
# 检查虚拟ip [root@lb03 ~]# ip a s eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:de:7c:97 brd ff:ff:ff:ff:ff:ff inet 10.0.0.15/24 brd 10.0.0.255 scope global eth0 valid_lft forever preferred_lft forever inet 10.0.0.13/24 scope global secondary eth0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fede:7c97/64 scope link valid_lft forever preferred_lft forever

    <h3>
      <span id="185_web">1.8.5 <span style="font-family: '微软雅黑',sans-serif;">在</span>web<span style="font-family: '微软雅黑',sans-serif;">服务器上进行配置</span></span>
    </h3>
    
    <div class="cnblogs_code">
      <pre>(在web03/<span style="color: #000000;">web04同时操作下面步骤)

步骤1:在lo网卡绑定VIP地址(ip) 步骤2:修改内核参数抑制ARP响应 ip addr add 10.0.0.13/32 dev lo

cat »/etc/sysctl.conf<<EOF net.ipv4.conf.all.arp_ignore = 1 net.ipv4.conf.all.arp_announce = 2 net.ipv4.conf.lo.arp_ignore = 1 net.ipv4.conf.lo.arp_announce = 2 EOF sysctl -p

    <p>
      <strong><em><span style="font-family: 等线; color: red;">注意:</span><span style="color: red;">web</span></em></strong><strong><em><span style="font-family: 等线; color: red;">服务器上的配置为临时生效,可以将其写入</span><span style="color: red;">rc.local</span></em></strong><strong><em><span style="font-family: 等线; color: red;">文件,注意文件的执行权限。</span></em></strong>
    </p>
    
    <p>
      <span style="font-family: 等线;">使用</span>curl<span style="font-family: 等线;">命令进行测试</span>
    </p>
    
    <div class="cnblogs_code">
      <pre>[root@lb04 ~]<span style="color: #008000;">#</span><span style="color: #008000;"> curl 10.0.0.13</span>

web03

    <p>
      <strong><em><span style="text-decoration: underline;"><span style="font-family: 等线; background: yellow;">至此</span><span style="background: yellow;">keepalived+lvs</span></span></em></strong><strong><em><span style="text-decoration: underline;"><span style="font-family: 等线; background: yellow;">配置完毕</span></span></em></strong>
    </p>
    
    <h2>
      <span id="19_LVS">1.9 <span style="font-family: '微软雅黑',sans-serif;">常见</span>LVS<span style="font-family: '微软雅黑',sans-serif;">负载均衡高可用解决方案</span></span>
    </h2>
    
    <p style="margin-left: 33.0pt; text-indent: -21.0pt;">
      <span style="font-family: Wingdings;">&Oslash;&nbsp;</span><span style="font-family: '微软雅黑',sans-serif;">开发类似</span>keepalived<span style="font-family: '微软雅黑',sans-serif;">的脚本,早期的办法,现在不推荐使用。</span>
    </p>
    
    <p style="margin-left: 33.0pt; text-indent: -21.0pt;">
      <span style="font-family: Wingdings;">&Oslash;&nbsp;</span>heartbeat+lvs+ldirectord<span style="font-family: '微软雅黑',sans-serif;">脚本配置方案,复杂不易控制,不推荐使用</span>
    </p>
    
    <p style="margin-left: 33.0pt; text-indent: -21.0pt;">
      <span style="font-family: Wingdings;">&Oslash;&nbsp;</span>RedHat<span style="font-family: '微软雅黑',sans-serif;">工具</span>piranha<span style="font-family: '微软雅黑',sans-serif;">,一个</span>web<span style="font-family: '微软雅黑',sans-serif;">界面配置</span>LVS<span style="font-family: '微软雅黑',sans-serif;">。</span>
    </p>
    
    <p style="margin-left: 33.0pt; text-indent: -21.0pt;">
      <span style="font-family: Wingdings;">&Oslash;&nbsp;</span><span style="background: yellow;">LVS-DR+keepalived</span><span style="font-family: '微软雅黑',sans-serif; courier new"4courier new"; background: yellow;">方案,老师推荐最优方案,简单、易用、高效</span><span style="font-family: '微软雅黑',sans-serif;">。</span>
    </p>
    
    <h3>
      <span id="191_lvs">1.9.1 lvs<span style="font-family: '微软雅黑',sans-serif;">排错思路</span></span>
    </h3>
    
    <p style="text-align: center;">
      <span style="font-family: '微软雅黑',sans-serif;"><img data-original="https://clsn.io/wp-content/uploads/2018/03/1190037-20171129154800597-1843410323.png" src="/wp-content/themes/clsn-003/img/blank.gif" alt="高并发场景 LVS 安装及高可用实现" alt="" /></span>
    </p>
    
    <h3>
      <span id="192">1.9.2 <span style="font-family: '微软雅黑',sans-serif;">参考文档</span></span>
    </h3>
    
    <div class="cnblogs_Highlighter">
      <pre class="brush:python;gutter:true;">LVS项目介绍            http://www.linuxvirtualserver.org/zh/lvs1.html 

LVS集群的体系结构 http://www.linuxvirtualserver.org/zh/lvs2.html LVS集群中的IP负载均衡技术 http://www.linuxvirtualserver.org/zh/lvs3.html LVS集群的负载调度 http://www.linuxvirtualserver.org/zh/lvs4.html NAT模式安装详解 http://www.cnblogs.com/liwei0526vip/p/6370103.html 开发眼光看lvs http://blog.hesey.net/2013/02/introduce-to-load-balance-and-lvs-briefly.html lvs 介绍 http://www.it165.net/admin/html/201401/2248.html

    <p>
      &nbsp;
    </p>
    
    <p style="text-align: right;">
      <strong>&nbsp;本文出自&ldquo;惨绿少年&rdquo;,欢迎转载,转载请注明出处!http://blog.znix.top</strong>
    </p>
    
    <div id="toc_container" class="toc_white have_bullets">
      <ul class="toc_list">
        <li>
          <a href="#11">1.1 负载均衡介绍</a><ul>
            <li>
              <a href="#111">1.1.1 负载均衡的妙用</a>
            </li>
            <li>
              <a href="#112_lvs">1.1.2 为什么要用lvs</a>
            </li>
          </ul>
        </li>
        
        <li>
          <a href="#12_LVS">1.2 LVS介绍</a><ul>
            <li>
              <a href="#121">1.2.1 相关参考资料</a>
            </li>
            <li>
              <a href="#122_LVSip_vs">1.2.2 LVS内核模块ip_vs介绍</a>
            </li>
          </ul>
        </li>
        
        <li>
          <a href="#13_LVS">1.3 LVS集群搭建</a><ul>
            <li>
              <a href="#131">1.3.1 集群环境说明</a>
            </li>
            <li>
              <a href="#132_ipvsadm">1.3.2 安装ipvsadm管理工具</a>
            </li>
            <li>
              <a href="#133_LVS">1.3.3 LVS集群搭建</a>
            </li>
            <li>
              <a href="#134_web">1.3.4 在web浏览器配置操作</a>
            </li>
            <li>
              <a href="#135">1.3.5 进行访问测试</a>
            </li>
          </ul>
        </li>
        
        <li>
          <a href="#14_LVS">1.4 负载均衡(LVS)相关名词</a><ul>
            <li>
              <a href="#141_LVS--DR">1.4.1 LVS集群的工作模式--DR直接路由模式</a>
            </li>
          </ul>
        </li>
        
        <li>
          <a href="#15_web">1.5 在web端的操作有什么含义?</a><ul>
            <li>
              <a href="#151_RealServerloVIP">1.5.1 RealServer为什么要在lo接口上配置VIP?</a>
            </li>
            <li>
              <a href="#152_eth0VIP">1.5.2 在eth0网卡上配置VIP可以吗?</a>
            </li>
            <li>
              <a href="#153_ARP">1.5.3 为什么要抑制ARP响应?</a>
            </li>
          </ul>
        </li>
        
        <li>
          <a href="#16_LVS">1.6 LVS集群的工作模式</a><ul>
            <li>
              <a href="#161_LVS--NAT">1.6.1 LVS集群的工作模式--NAT</a>
            </li>
            <li>
              <a href="#nbsp">&nbsp;</a>
            </li>
            <li>
              <a href="#162_LVS--TUN">1.6.2 LVS集群的工作模式--隧道模式TUN</a>
            </li>
            <li>
              <a href="#163_LVS--FULLNAT">1.6.3 LVS集群的工作模式--FULLNAT</a>
            </li>
          </ul>
        </li>
        
        <li>
          <a href="#17_IPVS">1.7 IPVS调度器实现了如下八种负载调度算法:</a>
        </li>
        <li>
          <a href="#18_LVSKeepalived">1.8 LVS+Keepalived方案实现</a><ul>
            <li>
              <a href="#181_keepalived">1.8.1 keepalived功能</a>
            </li>
            <li>
              <a href="#182_Keepalived">1.8.2 在负载器安装Keepalived软件</a>
            </li>
            <li>
              <a href="#183">1.8.3 修改配置文件</a>
            </li>
            <li>
              <a href="#184_keepalived">1.8.4 启动keepalived服务</a>
            </li>
            <li>
              <a href="#185_web">1.8.5 在web服务器上进行配置</a>
            </li>
          </ul>
        </li>
        
        <li>
          <a href="#19_LVS">1.9 常见LVS负载均衡高可用解决方案</a><ul>
            <li>
              <a href="#191_lvs">1.9.1 lvs排错思路</a>
            </li>
            <li>
              <a href="#192">1.9.2 参考文档</a>
            </li>
          </ul>
        </li>
      </ul>
    </div>