Step by Step build LVS-DR model lb cluster (ii)

Source: Internet
Author: User

Persistent connection of LVS:

A persistent connection is a forwarding method that does not consider LVS, ensuring that all connections from the same user are forwarded to the same realserver

-P//indicates that this connection is a persistent connection
N//Indicates the time to maintain this persistent connection. The default is 6 minutes.


Types of persistent connections:

1.PCC (Persistent client connector, persistent user connection) all requests from the same user are located on the same realserver within the time-out range, when the port is specified with port 0, and all requests are forwarded.
All requests of the 2.PPC (persistent port connector) user are located on different RS within the timeout range according to the port.
3. Firewall tag: The associated port on the firewall with the same mark, the user access to the two associated services, will be located on the same realserver.


PCC instance

Ipvsadm-a-T 192.168.1.110:0-S RR-P 600

PPC is based on the different services, directed to different Realserver, in the directory to write a few more ipvsadm point, note that the port to distinguish between the line


Persistent connection for firewall tagging

Iptables-t mangle-a prerouting-d 192.168.1.110-p tcp--dport 80-j Mark--set-mark 10 destinations 1982.168.1.110:80 marked as 10ipvs Adm-a-F 10-s rr-p 60//Use the 10 defined above to define the Cluster service ipvsadm-a-F 10-r 192.168.1.116-g/For cluster definition realserveripvsadm-a-f 10-r 192.1 68.1.117-g

Simple back-Office RS Health Monitoring script

#!/bin/bash#vip=192.168.1.110cport=80fail_back=127.0.0.1fbstatus=0rs= ("192.168.1.116"   "192.168.1.117") Rstatus= ("1"   "1") rw= ("2"   "1") Rport=80type=gadd ()  {  ipvsadm -a -t  $VIP : $CPORT  -r $1: $RPORT  -$TYPE  -w $2  [ $? -eq 0 ]  && return 0 | |  return 1}del ()  {  ipvsadm -d -t  $VIP: $CPORT  -r $1: $RPORT   [ $? -eq 0 ] && return 0 | |  return 1}while :; do  let count=0  for i in ${rs[ *]}; do    if curl --connect-timeout 1 http://$I  &>  /dev/null; then      if [ ${rstatus[$COUNT]} -eq  0 ]; then         add  $I  ${rw[$COUNT]}          [ $? -eq 0 ] && rstatus[$COUNT] =1      fi    else      if  [ ${rstatus[$COUNT]} -eq 1 ]; then          del  $I          [ $? -eq 0 ]  && rstatus[$COUNT]=0      fi    fi     let count++  done  sleep 5done


This article is from the "Linux is belong to You" blog, make sure to keep this source http://jwh5566.blog.51cto.com/7394620/1664077

Step by Step build LVS-DR model lb cluster (ii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.