Tecnologia da Informação - TI : Lv

Total de visualizações de página

Mostrando postagens com marcador Lv. Mostrar todas as postagens
Mostrando postagens com marcador Lv. Mostrar todas as postagens

segunda-feira, 25 de abril de 2016

LVS + Keepalived


LVS + Keepalived
2015/06/10
 
This is the Redundant configuration for LVS + Keepalived Server itself.
This example is based on the environment below.
                              |
             +----------------+-----------------+
             |                                  |
 192.168.0.30|eth0 --- VIP:192.168.0.29 --- eth0|192.168.0.31
     +-------+--------+                +--------+-------+
     | LVS+Keepalived |                | LVS+Keepalived |
     +-------+--------+                +--------+-------+
    10.0.0.30|eth1 ----- VIP:10.0.0.29 ---- eth1|10.0.0.31
             |                                  |
             +----------------+-----------------+
                              |
    +------------+            |             +------------+
    |  Backend01 |10.0.0.51   |    10.0.0.52|  Backend02 |
    | Web Server +------------+-------------+ Web Server |
    |            |eth0                  eth0|            |
    +------------+                          +------------+


 
HTTP packets to the eth0 on LVS Server are forwarded to Backend01 and Backend02 Servers with NAT.
Change the default gateway to internal IP address of LVS on both Backend Web Servers first. (it's 10.0.0.29 on the example)
[1]Install ipvsadm and keepalived.
[root@dlp ~]# 
yum -y install ipvsadm keepalived
# enable IP forward

[root@dlp ~]# 
echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf 

[root@dlp ~]# 
sysctl -p
[root@dlp ~]# 
touch /etc/sysconfig/ipvsadm 

[root@dlp ~]# 
systemctl start ipvsadm 

[root@dlp ~]# 
systemctl enable ipvsadm 
[2]Configure Keepalived.
It's OK to configure the same settings except one setting on both backend servers. 
(but only for the "priority" section, Change it on both backend server.)
[root@dlp ~]# 
mv /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.org 

[root@dlp ~]# 
vi /etc/keepalived/keepalived.conf
# create new

global_defs {
    notification_email {
        root@dlp.server.world
    }
    notification_email_from root@dlp.server.world
    smtp_server 127.0.0.1
    smtp_connect_timeout 30
    router_id LVS_Server
}
vrrp_instance VI_1 {
    state BACKUP
    # monitored interface
    interface eth0
    # virtual router's ID
    virtual_router_id 51
    # set priority (change this value on each server)
    # (large number means priority is high)
    priority 100
    nopreempt
    # VRRP sending interval
    advert_int 1
    # authentication info between Keepalived servers
    authentication {
        auth_type PASS
        auth_pass password
    }

    virtual_ipaddress {
        # virtual IP address
        192.168.0.29 dev eth0
        10.0.0.29/24 dev eth1
    }
}
virtual_server 192.168.0.29 80 {
    # monitored interval
    delay_loop 3
    # distribution method
    lvs_sched rr
    # routing method
    lvs_method NAT
    protocol TCP

    # backend server#1
    real_server 10.0.0.51 80 {
        weight 1
        HTTP_GET {
            url {
                # monitored path
                path /
                # status code for normally state
                status_code 200
            }
            # timeout(sec)
            connect_timeout 3
        }
    }
    # backend server#2
    real_server 10.0.0.52 80 {
        weight 1
        HTTP_GET {
            url {
                path /
                status_code 200
            }
            connect_timeout 3
        }
    }
}

[root@dlp ~]# 
systemctl start keepalived 

[root@dlp ~]# 
systemctl enable keepalived 
[3]
It's OK, Access to the Service IP address and make sure it works normally. 

Configure LVS (Linux Virtual Server)


Configure LVS (Linux Virtual Server)
2015/06/10
 
Configure LVS (Linux Virtual Server) to build a load barancer.
This example is based on the environment below.
                          |
                          |
                      eth0|192.168.0.30
                    +----------+
--------------------|    LVS   |----------------------
                    +-----+----+
                      eth1|10.0.0.30
                          |
+------------+            |             +------------+
|  Backend01 |10.0.0.51   |    10.0.0.52|  Backend02 |
| Web Server +------------+-------------+ Web Server |
|            |eth0                  eth0|            |
+------------+                          +------------+

 
HTTP packets to the eth0 on LVS Server are forwarded to Backend01 and Backend02 Servers with NAT.
Change the default gateway to internal IP address of LVS on both Backend Web Servers first. (it's 10.0.0.30 on the example)
[1]Install ipvsadm.
[root@dlp ~]# 
yum -y install ipvsadm
# enable IP forward

[root@dlp ~]# 
echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf 

[root@dlp ~]# 
sysctl -p
[root@dlp ~]# 
touch /etc/sysconfig/ipvsadm 

[root@dlp ~]# 
systemctl start ipvsadm 

[root@dlp ~]# 
systemctl enable ipvsadm 
[2]Configure Load Balancing.
# clear tables

[root@dlp ~]# 
ipvsadm -C
# add virtual service

# [ ipvsadm -A -t (Service IP:Port) -s (Distribution method) ]

[root@dlp ~]# 
ipvsadm -A -t 192.168.0.30:80 -s wlc 
# add backend real servers

# [ ipvsadm -a -t (Service IP:Port) -r (Real Server's IP:Port) -m ] ("m" means masquerading (NAT))

[root@dlp ~]# 
ipvsadm -a -t 192.168.0.30:80 -r 10.0.0.51:80 -m 

[root@dlp ~]# 
ipvsadm -a -t 192.168.0.30:80 -r 10.0.0.52:80 -m 
# confirm tables

[root@dlp ~]# 
ipvsadm -l 

IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  dlp.server.world:http wlc
  -> 10.0.0.51:http               Masq    1      0          0
  -> 10.0.0.52:http               Masq    1      0          0
[3]It's OK, Access to the Service IP address and make sure it works normally.
By the way, there are some Distribution method like follows. 
MethodDescription
rrRobin Robin
distributes jobs equally amongst the available real servers.
wrrWeighted Round Robin
assigns jobs to real servers propor-tionally to there real servers’ weight. Servers with higher weights receive new jobs first and get more jobs than servers with lower weights. Servers with equal weights get an equal dis-tribution of new jobs.
lcLeast-Connection
assigns more jobs to real servers with fewer active jobs.
wlcWeighted Least-Connection
assigns more jobs to servers with fewer jobs and relative to the real servers' weight (Ci/Wi). This is the default.
lblcLocality-Based Least-Connection
assigns jobs destined for the same IP address to the same server if the server is not overloaded and available, otherwise assign jobs to servers with fewer jobs, and keep it for future assignment.
lblcrLocality-Based Least-Connection with Replication
assigns jobs destined for the same IP address to the least-con- nection node in the server set for the IP address. If all the node in the server set are over loaded, it picks up a node with fewer jobs in the cluster and adds it in the sever set for the target. If the server set has not been modified for the speci-fied time, the most loaded node is removed from the server set, in order to avoid high degree of replication.
dhDestination Hashing
assigns jobs to servers through looking up a statically assigned hash table by their destination IP addresses.
shSource Hashing
assigns jobs to servers through looking up a statically assigned hash table by their source IP addresses.
sedShortest Expected Delay
assigns an incoming job to the server with the shortest expected delay. The expected delay that the job will experience is (Ci + 1) / Ui if sent to the ith server, in which Ci is the number of jobs on the the ith server and Ui is the fixed service rate (weight) of the ith server.
nqNever Queue
assigns an incoming job to an idle server if there is, instead of waiting for a fast one, if all the servers are busy, it adopts the Shortest Expected Delay policy to assign the job.

Console Sony Playstation 5 Edição Slim Disk 1tb Branco + Controle Sem Fio Dualsense Ps5 Branco

https://meli.la/1pJv7oL LINK ->  https://meli.la/1pJv7oL  Características do produto Capacidade 1 TB Com Wi-Fi Sim Tipo de console De ...