1. Manage Cluster service
(1) Create or modify
ipvsadm-a| E-t|u|f Service-address [-S scheduler]
-A add
-E Modification
The-t-hosted application-layer protocol is a protocol that provides services based on the TCP protocol, and its server-address format is "Vip:port", such as 172.16.100.6:80
The-U-hosted Application-layer protocol provides services based on the UDP protocol, with the server-address format "Vip:port", 172.16.100.6:53
The-F-Hosted application-layer protocol is a protocol that provides services based on TCP or UDP protocols, but such messages are tagged by iptables/netfilter, which means that their server-address format is "FWM" for the firewall, such as "10"
-S scheduler indicates the scheduling method, which defaults to WLC
(2) Delete
ipvsadm-d-t|u|f service-address
2. Manage the RS on the Cluster service
(1) Add or modify
Ipvsadm-a|e-t|u|f Service-address-r server-address
[-g|i|m] [-W weight] [-X Upper] [-y Lower]
-R server-address: Indicates that the rs,server-address format is generally "ip[:P ort]" and only LVS that support port mappings define the port here
For example,-R 192.168.10.7:80
[-g|i|m]: Indicates the type of LVS
-g:gateway, meaning Dr type
-i:ipip, meaning Tun type
-m:masquerade means NAT sentencing.
[-W Weight]:rs weights
Note: Weights are only meaningful for scheduler that support weighted scheduling
(2) Delete:
ipvsadm-d-t|u|f service-address-r server-address
(3) Clear the definition of all cluster services
Ipvsadm-c
(4) Save and restore rules
1) Save:
Ipvsadm-s >/etc/sysconfig/ipvsadm
Ipvsadm-save >/etc/sysconfig/ipvsadm
Server Ipvsadm Save
2) Recovery
Ipvsadm-r </etc/sysconfig/ipvsadm
Ipvsadm-restore </etc/sysconfig/ipvsadm
Server Ipvsadm Restart
3. View Rules
ipvsadm-l|l [Options]
-C: List all connections
#ipvsadm-ln-c//View status information
--stats: Listing Statistics
--rate: Rate Statistics
#ipvsadm-ln--stats
-N,--Numeric: Digital display IP and port
--exact: List exact values
4. Empty the counter
Ipvsadm-z [-t|u|f service-address]
Case: Lvs-nat type Web server cluster
Architecture Environment:
System: CentOS 6.6 x86_64
Tools: VMware Workstation 11
Requirements: There are three servers, respectively, as Director (Scheduler), real Server1, real server2. Requires the cluster type to be Lvs-nat and accesses the VIP through external access to the real server in a scheduled way
The topology diagram looks like this:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6D/55/wKiom1VhM3KCNOdtAAEmhqqZkwY961.jpg "title=" Ipvsadm.jpg "alt=" Wkiom1vhm3kcnodtaaemhqqzkwy961.jpg "/>
Ideas:
1, new three virtual host, host name is Node1 (as director), Node2 (real Server1), Node3 (real Server2)
2, the director set two network cards, one for the bridge, one for the host only, VIP set to 172.16.21.110,dip set to 192.168.91.70
3. Real Server1 NIC is set to host only, RIP is set to 192.168.91.80
4. Real Server2 NIC is set to host only, RIP is set to 192.168.91.90
5, real server in the/var/www/html set the home page, the gateway is pointed to the dip
6, testing on the physical machine
Note: To ensure the test results, you need to close iptables and SELinux, and the native has configured Yum source ok
#yum info ipvsadm //View ipvsadm information #grep -i "Ipvs" -A 5 /boot/config-2.6.32-504.e16.x86_64 //See if Ipvs supports various protocols (TCP,UDP, etc.) #yum install ipvsadm -y //Installing ipvsadm node1 #ipconfig eth0 172.16.21.110/16 up //This machine is only test, set IP as temporary IP, reboot will change #ipconfig eht1 192.168.91.70/24 up node2 #ipconfig eth0 192.168.91.80/24 up node3 #ipconfig eth0 192.168.91.90/24 up node1 #ping 192.168.91.80 // Test on director whether Ping can real server #ping 192.168.91.90 node2 #vim /var/www/html/index.html
This article is from "snail" blog, please be sure to keep this source http://linuxkingdom.blog.51cto.com/6334977/1654637
Ipvsadm command and Lvs-nat type Web server cluster