lvs management tools -ipvsadm
A, ipvsadm tool introduced
Starting version 2.4, linux kernel by default support LVS. The ability to use LVS, LVS simply install a management tool: ipvsadm.
LVS structure is divided into two parts:
- Work in kernel space IPVS modules. LVS capabilities are actually implemented by IVPS module.
- Work in user space ipvsadm management tools. Its role is to provide a command interface to the user for configuring a virtual service, real service to pass IPVS modules.
Two, ipvsadm installation tool
ipvsadm rpm installation tool support, you can compile the source code installation. download link:
Three, ipvsadm tools
ipvsadm tool commonly used parameters options are:
-A --add-service | Add a new virtual service |
-E-service --edit | Edit virtual service |
-D --delete-service | Delete Virtual Services |
-C --clear | Clear all the virtual service rules |
-R --restore | Restore virtual service rules |
-a --add-server | Add a new server in a virtual reality service |
-e --edit-server | Edit a real server |
-d --delete-server | To remove a real server |
-L | -l --list | Display kernel virtual service rules |
-n --numeric | Display IP port in digital form |
-c --connection | Display ipvs existing connection can also be used to analyze scheduling of |
-Z --zero | Forwarding the message clears statistics |
-p --persistent | Configuring persistence time |
--set tcp tcpfin udp | Configuration three timeout (tcp / tcpfin / udp) |
-t | -u | TCP / UDP protocol virtual service |
-g | -m | -i | LVS mode: DR | NAT | TUN |
-w | The right to re-configure the real server |
-s | Configure load balancing algorithms, such as: rr, wrr, lc, etc. |
--timeout | Display configuration tcp / tcpfin / udp timeout |
--stats | Statistics show the history of forwarding messages (accumulated value) |
--rate | Forwarding display rate information (instantaneous value) |
Example:
1. Virtual Service Management
- Add a virtual service 192.168.1.100:80, polling algorithm
ipvsadm -A -t 192.168.1.100:80 -s rr
- Modify virtual service algorithm is weighted round-robin
ipvsadm -E -t 192.168.1.100:80 -s wrr
- Delete Virtual Services
ipvsadm -D -t 192.168.1.100:80
2. Management real service
- Add a real server 192.168.1.123, use DR mode, the weight 2
ipvsadm -a -t 192.168.1.100:80 -r 192.168.1.123 -g -w 2
- Modify real server weight
ipvsadm -a -t 192.168.1.100:80 -r 192.168.1.123 -g -w 5
- Delete real server
ipvsadm -d -t 192.168.1.100:80 -r 192.168.1.123
3. View Statistics
- View virtual services and the current configuration of each RS weight
ipvsadm -Ln
- See ipvs module records the current connection (the case can be used to observe the forward)
ipvsadm -lnc
- View ipvs forwarding statistics module
ipvsadm -Ln --stats | --rate
In addition, - stats and --rate statistics often used in the analysis of the problem, the output of meaning:
--stat option package since the statistics from that article forwarding rules take effect
1. Conns (connections scheduled) has forwarded the number of connections
2. InPkts (incoming packets) into a number of packets
3. OutPkts (outgoing packets) the packet number
4. InBytes (incoming bytes) into the flow (bytes)
5. OutBytes (outgoing bytes) the flow (bytes)
-------------------------------------------------------------------
--rate option is to display rate information
1. CPS (current connection rate) per second connector
2. InPPS (current in packet rate) the number of packets per second
3. OutPPS (current out packet rate) the number of packets per second
4. InBPS (current in byte rate) into the flow (bytes) per second
5. OutBPS (current out byte rate) into the second flow (bytes)
Starting version 2.4, linux kernel by default support LVS. The ability to use LVS, LVS simply install a management tool: ipvsadm.
LVS structure is divided into two parts:
- Work in kernel space IPVS modules. LVS capabilities are actually implemented by IVPS module.
- Work in user space ipvsadm management tools. Its role is to provide a command interface to the user for configuring a virtual service, real service to pass IPVS modules.
Two, ipvsadm installation tool
ipvsadm rpm installation tool support, you can compile the source code installation. download link:
Three, ipvsadm tools
ipvsadm tool commonly used parameters options are:
-A --add-service | Add a new virtual service |
-E-service --edit | Edit virtual service |
-D --delete-service | Delete Virtual Services |
-C --clear | Clear all the virtual service rules |
-R --restore | Restore virtual service rules |
-a --add-server | Add a new server in a virtual reality service |
-e --edit-server | Edit a real server |
-d --delete-server | To remove a real server |
-L | -l --list | Display kernel virtual service rules |
-n --numeric | Display IP port in digital form |
-c --connection | Display ipvs existing connection can also be used to analyze scheduling of |
-Z --zero | Forwarding the message clears statistics |
-p --persistent | Configuring persistence time |
--set tcp tcpfin udp | Configuration three timeout (tcp / tcpfin / udp) |
-t | -u | TCP / UDP protocol virtual service |
-g | -m | -i | LVS mode: DR | NAT | TUN |
-w | The right to re-configure the real server |
-s | Configure load balancing algorithms, such as: rr, wrr, lc, etc. |
--timeout | Display configuration tcp / tcpfin / udp timeout |
--stats | Statistics show the history of forwarding messages (accumulated value) |
--rate | Forwarding display rate information (instantaneous value) |
Example:
1. Virtual Service Management
- Add a virtual service 192.168.1.100:80, polling algorithm
ipvsadm -A -t 192.168.1.100:80 -s rr
- Modify virtual service algorithm is weighted round-robin
ipvsadm -E -t 192.168.1.100:80 -s wrr
- Delete Virtual Services
ipvsadm -D -t 192.168.1.100:80
2. Management real service
- Add a real server 192.168.1.123, use DR mode, the weight 2
ipvsadm -a -t 192.168.1.100:80 -r 192.168.1.123 -g -w 2
- Modify real server weight
ipvsadm -a -t 192.168.1.100:80 -r 192.168.1.123 -g -w 5
- 删除真实服务器
ipvsadm -d -t 192.168.1.100:80 -r 192.168.1.123
3. 查看统计
- 查看当前配置的虚拟服务和各个RS的权重
ipvsadm -Ln
- 查看当前ipvs模块中记录的连接(可用于观察转发情况)
ipvsadm -lnc
- 查看ipvs模块的转发情况统计
ipvsadm -Ln --stats | --rate
另外,--stats和--rate统计在分析问题时经常用到,输出各项的含义:
--stat选项是统计自该条转发规则生效以来的包
1. Conns (connections scheduled) 已经转发过的连接数
2. InPkts (incoming packets) 入包个数
3. OutPkts (outgoing packets) 出包个数
4. InBytes (incoming bytes) 入流量(字节)
5. OutBytes (outgoing bytes) 出流量(字节)
-------------------------------------------------------------------
--rate选项是显示速率信息
1. CPS (current connection rate) 每秒连接数
2. InPPS (current in packet rate) 每秒的入包个数
3. OutPPS (current out packet rate) 每秒的出包个数
4. InBPS (current in byte rate) 每秒入流量(字节)
5. OutBPS (current out byte rate) 每秒入流量(字节)