LVS build

3 hosts
A host acting as server LVS two network cards 66, 172.16.1.1
B acting as a web server host 67
C acting as a web host server 68
====================== ====
ipvsadn is used on the load balancer LVS cluster management tools, added by calling ip vs module, remove the server node, and run the view of the cluster.
rpm -q ipvsadm (not already installed)
the ipvsadm -v view the version
LVS cluster management including: creating a virtual server, add server nodes, see cluster node-like
state, delete the server node, saving load allocation strategy, the following were demonstrated using ipwsadm method of operating commands. .
1) Create a virtual server.
If the cluster VIP address 192. 168.200.254, providing services for the load shunt port TCP80, using transfer
of a polling algorithm, the corresponding operation command ipvsadm follows. For load balancing scheduler for, VIP must
be the machine actually enabled P address. .
[root @ localhost ~] # ipvsadm -A -t 192.168.200.254:80 -s rr
above-described operation, the option to add A represents a virtual server - specifies the VIP addresses and TCP ports, 8 to
specify a load scheduling algorithm Inquiry ([pi]). WRR (wm), least connection (le), the weighted minimum even (WE) and the like. .
2) Add a server node
192.168.200.254 virtual server to add four server nodes, IP addresses were 192.168.200.112,
192.168.200.113, ipvsadm command corresponding to the operation is as follows,
wishing to use the connector holder, should also add "-p60" option, wherein 60 the retention time (seconds). .
[the root @ localhost ~] # the ipvsadm -m -a -t 192.168.200.254:80 -R & lt 192.168.200.112:80. 1 -w
[the root @ localhost ~] # -R & lt 192.168.200.254:80 the ipvsadm -a -t 192.168. 200.113: 80 -m -w 1
above operation, the options. Represents add a server, ↓ specifies the VIP addresses and TCP ports, r specifies
RIP address and TCP port, -m NAT cluster indication mode (-gDR mode, iTUN mode), - w disposed to
the rear weight ( a weight of 0 means halt the node). .
 3) Check cluster node status.
L can view the list of options combined with LVS virtual server, you can view only a certain VIP address (the default is
to view all) in combination options - will display information in digital form address and port. .
[root @ localhost ~] # ipvsadm -Ln // Check node status
IP VirtualServer Version 1.2.1 (size = -4096) -
Prot LocalAddressPort Scheduler Flags
-> RemoteAddress: Port Forward Weight activeconn InActConn
. TCP 192.168.200.254:80rr
-> 192.168.200.112:80 Masq 1 0 0
-> 192.168.200.113:80 Masq 1 0 0
[root @ localhost ~] # Lnc the ipvsadm-// Check load connections.
IPVS connection entries.
The expire State Source virtualdestination Pro
the TCP 172.16.16.110:49712 192.168.200.254:80 the WAIT 192.168200112 the FIN 01:51: 80
the TCP 01:52 172.16.16.110:49720 192.168.200.254:80 the WAIT 192.168.200.113:80 the FIN,
the output results , MASG the corresponding column under masquerade Forward (masquerading), showing use of
a cluster mode NAT: If the Route, it indicates use of the DR cluster mode ..
 
4) delete the server node.
When the need to remove a node from a server pool, use the option d. Delete operation must target audiences,
including node addresses, virtual IP address. For example, the following sentence will LVS cluster node other in 192.168.200.254
192.168.200.115 ..
[root @ localhost ~] # ipvsadm -d -r 192.168.200.115:80-t 192.168.200.254:80
needed to remove the entire virtual server, and specify the use of Option D virtual IP addresses without the need to specify the node. Cases
Should the implementation of "ipwsadm-D -t 192. 168 200.254.80 ", then this virtual server to delete ..
 
5) Save the load allocation policy.
Use the Export / Import tool ipvsadm-save / ipwsadm-restore can be saved and restored LVS strategy. Of course, you can fast
speed to clear and rebuild load allocation policy. .
froot @ localhost ~] # ipysadm- save> / etc / sysconfig / ipvsadm // save the policy.
froot @ localhost ~] # cat / etc / sysconfg / ipvsadm // OK to save the result.
192.168.200.254:http-s -at
-a -t-Minion R & lt 192.168.200.254:htp One: W is HTTP. 1 -m
. 192.168.200.254:http a -t F. 192.168.200.113:http-m-w1 A
AT 192.168 .200.254: http- 192.168.200.114:http -mw 1.
[root @ localhost ~] # ytectitstop ipvsadm // stop service (purge policy).
[root @ localhost ~] # systemctistart ipvsadm // start service (reconstruction rule) D
 
===========================
Experiment 1:
[1 ] address translation mode (LVS-NAT)
in NAT mode focus group, LVS load balancer is all nodes to access the Internet gateway server, its external network address 172.16.1.1 as well as the VIP address the entire cluster,
LVS scheduler has two network card, are connected to external network.
---------------------------------------
all hosts turn off the firewall security
===== ====================
A host 66 the LVS
yum -Y the install the ipvsadm
the ipvsadm -v
CD / etc / sysconfig / Network-scripts /
CP-ens32 the ifcfg the ifcfg-ens34
Vim ifcfg-ens34
retain only IPADDR = 172.16.1.1
save and exit
reboot the network card
! ! As VMnet2 in which a card mode, modify the network adapter mode linux host A 2
modified Linux client windows NIC mode VMnet2
change the IP address of IPV4 Linux client windows, and it's IP address with LVS external network address in the same network segment.
For example, 172.16.1.2 to
be ping 172.16.1.1 pass line inside the terminal
IP A
~~~~~~~~~~~~
off the firewall security
~~~~
Vim // open route /etc/sysctl.conf forwarding (permanent)
the value of net.ipv4.ip_forward to 1
to save and exit
sysctl -p // take effect
ipvsadm -C // If you have a strategy before you use the command bar to all content cleared
~~~~~~ ~ ~ ~
the ipvsadm -A -s -t 172.16.1.1:80 // rr - A -t create the specified external network IP -s representation algorithm
ipvsadm -a -t 172.16.1.1:80 -r 192.168.200.67:80 -m -w 1 // -r -m specified node refers to net mode -w 1 represents the weight
the ipvsadm 172.16.1.1:80 -r -t -w 1 -a -m 192.168.200.68:80
the ipvsadm -Ln // View
 
=========================
B host web67
yum the install the httpd -Y
modify the gateway, the gateway = 192.168.200.66 // point scheduler gateway LVS
restart card
route -n // verify the gateway
~~~ ~~~
turn off the firewall security
~~~~~~~~~~~~~~
open service
systemctl Start httpd
~~~~~
write a test page
echo "11111111"> /var/www/html/index.html
=========================
C host web68
yum -y install httpd
modify the gateway, the gateway = 192.168.200.66 // LVS point scheduler gateway
route -n // verify gateway
restart card
~~~ ~~~
turn off the firewall security
~~~~~~~ ~~~~~~~
open service
systemctl Start httpd
~~~~~
write a test page
echo "2222222"> /var/www/html/index.html
=== ===== end of the experiment
visit 172.16.1.1 see poll results, says there is success in the client! ! ! ! ! ! 1
view policy information in LVS in
the ipvsadm -Ln 
the ipvsadm -Lnc
can also write a test
the while:
> do
> elinks --dump http://172.16.1.1
> SLEEP 1
> DONE
conducting View
ipvsadm -Ln // can see to value growth
-Lnc the ipvsadm
~~~~~~~~~~~~~~~~~~ complete! ! ! ! ! ! ! ! ! ! ~~~~~~~~~

Guess you like

Origin www.cnblogs.com/elin989898/p/11936898.html
LVS
LVS
lvs
LVS
LVS