用户空间的命令行工具,用于管理集群服务;(即规则的增删查改)
//查看帮助
ipvsadm v1.31 2019/12/24 (compiled with popt and IPVS v1.2.1)
Usage:
  ipvsadm -A|E virtual-service [-s scheduler] [-p [timeout]] [-M netmask] [--pe persistence_engine] [-b sched-flags]
  ipvsadm -D virtual-service
  ipvsadm -C
  ipvsadm -R
  ipvsadm -S [-n]
  ipvsadm -a|e virtual-service -r server-address [options]
  ipvsadm -d virtual-service -r server-address
  ipvsadm -L|l [virtual-service] [options]
  ipvsadm -Z [virtual-service]
  ipvsadm --set tcp tcpfin udp
  ipvsadm --start-daemon {master|backup} [daemon-options]
  ipvsadm --stop-daemon {master|backup}
  ipvsadm -h
Commands:
Either long or short options are allowed.
  --add-service     -A        add virtual service with options
  --edit-service    -E        edit virtual service with options
  --delete-service  -D        delete virtual service
  --clear           -C        clear the whole table
  --restore         -R        restore rules from stdin
  --save            -S        save rules to stdout
  --add-server      -a        add real server with options
  --edit-server     -e        edit real server with options
  --delete-server   -d        delete real server
  --list            -L|-l     list the table
  --zero            -Z        zero counters in a service or all services
  --set tcp tcpfin udp        set connection timeout values
  --start-daemon              start connection sync daemon
  --stop-daemon               stop connection sync daemon
  --help            -h        display this help message
virtual-service:
  --tcp-service|-t  service-address   service-address is host[:port]
  --udp-service|-u  service-address   service-address is host[:port]
  --sctp-service    service-address   service-address is host[:port]
  --fwmark-service|-f fwmark          fwmark is an integer greater than zero
Options:
  --ipv6         -6                   fwmark entry uses IPv6
  --scheduler    -s scheduler         one of rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq|fo|ovf|mh,
                                      the default scheduler is wlc.
  --pe            engine              alternate persistence engine may be sip,
                                      not set by default.
  --persistent   -p [timeout]         persistent service
  --netmask      -M netmask           persistent granularity mask
  --real-server  -r server-address    server-address is host (and port)
  --gatewaying   -g                   gatewaying (direct routing) (default)
  --ipip         -i                   ipip encapsulation (tunneling)
  --masquerading -m                   masquerading (NAT)
  --tun-type      type                one of ipip|gue|gre,
                                      the default tunnel type is ipip.
  --tun-port      port                tunnel destination port
  --tun-nocsum                        tunnel encapsulation without checksum
  --tun-csum                          tunnel encapsulation with checksum
  --tun-remcsum                       tunnel encapsulation with remote checksum
  --weight       -w weight            capacity of real server
  --u-threshold  -x uthreshold        upper threshold of connections
  --l-threshold  -y lthreshold        lower threshold of connections
  --connection   -c                   output of current IPVS connections
  --timeout                           output of timeout (tcp tcpfin udp)
  --daemon                            output of daemon information
  --stats                             output of statistics information
  --rate                              output of rate information
  --exact                             expand numbers (display exact values)
  --thresholds                        output of thresholds information
  --persistent-conn                   output of persistent connection info
  --tun-info                          output of tunnel information
  --nosort                            disable sorting output of service/server entries
  --sort                              does nothing, for backwards compatibility
  --ops          -o                   one-packet scheduling
  --numeric      -n                   numeric output of addresses and ports
  --sched-flags  -b flags             scheduler flags (comma-separated)
Daemon Options:
  --syncid sid                        syncid for connection sync (default=255)
  --sync-maxlen length                Max sync message length (default=1472)
  --mcast-interface interface         multicast interface for connection sync
  --mcast-group address               IPv4/IPv6 group (default=224.0.0.81)
  --mcast-port port                   UDP port (default=8848)
  --mcast-ttl ttl                     Multicast TTL (default=1)
//语法
#下面的表格中有选项含义说明
ipvsadm -A|E -t|u|f service-address [-s scheduler][-p [timeout]][-M netmask]
//常见的service-address
  tcp:-t ip:port
  udp:-u ip:port
  fwm:-f mark
//选项-s scheduler
默认为wlc
//选项 -p [timeout]:
定义持久连接,timeout不指定时默认300妙
选项含义详情如下:
| 选项 | 含义 | 
|---|---|
| -A | 添加虚拟服务器 | 
| -E | 修改虚拟服务器 | 
| -D | 删除虚拟服务器 | 
| -C,--clear | 清除所有虚拟服务 | 
| -R,--restore | 从标准输入获取ipvsadm命令。一般结合下边的-S使用。 | 
| -S,--save | 从标准输出输出虚拟服务器的规则。可以将虚拟服务器的规则保存,在以后通过-R直接读入,以实现自动化配置。 | 
| -L,-l,--list | 列出虚拟服务表中的所有虚拟服务。可以指定地址。添加-c显示连接表 | 
| -Z,--zero | 将所有数据相关的记录清零,这些记录一般用于调度策略 | 
| --set tcp tcpfin udp | 修改协议的超时时间 | 
| --start-daemon state | 设置虚拟服务器的备服务器,用来实现主备服务器冗余(注:该功能只支持ipv4) | 
| --stop-daemon | 停止备服务器 | 
//语法
#下面的表格中有选项含义说明
ipvsadm -a|e -t|u|f service-address -r server-address [-g|i|m][-w weight][-x upper][-y lower]
ipvsadm -d -t|u|f service-address-r server-address
//查看
ipvsadm -L|l[options]
#选项内容、含义
options:
  -n:numeric,基于数字格式显示地址和端口
  -c:connecion,显示当前ipvs连接
  --stats:统计数据
  --rate:输出速率信息
  --exact:显示精确值,不做单位换算
选项含义详情如下:
| 选项 | 含义 | 
|---|---|
| -a | 添加真实服务器 | 
| -e | 修改真实服务器 | 
| -d | 删除真实服务器 | 
| -r | 指定真实服务器(Real Server)的地址 | 
| -m | 使用NAT模式 | 
| -g | 使用DR模式 | 
| -i | 使用TUN模式 | 
| -h,--help | 查看帮助 | 
| -t | 设置集群地址(VIP,Virtual IP) | 
| -s | 指定负载调度算法 | 
| -u,--udp-service service-address | 使用udp服务,其他同上 | 
| -w | 为节点服务器设置权重,默认为1,权重是0~65535的整数。如果将某个真实服务器的权重设置为0,那么它不会收到新的连接,但是已有连接还会继续维持(这点和直接把某个真实服务器删除时不同的),权重值越大表示性能越好,被调度的资源也会更多 | 
| -f,--fwmark-service integer | 用firewall mark取代虚拟地址来指定要被负载均衡的数据包,可以通过这个命令实现把不同地址、端口的虚拟地址整合成一个虚拟服务,可以让虚拟服务器同时截获处理去往多个不同地址的数据包。fwmark可以通过iptables命令指定。如果用在ipv6需要加上-6 | 
| -p,--persistent [timeout] | 设置持久连接,这个模式可以使来自客户的多个请求被送到同一个真实服务器,通常用于ftp或者ssl中 | 
| -M,--netmask netmask | 指定客户地址的子网掩码。用于将同属一个子网的客户的请求转发到相同服务器 | 
| -x,--u-threshold uthreshold | 设置一个服务器可以维持的连接上限。0~65535。设置为0表示没有上限 | 
| --syncid syncid | 指定syncid,同样用于主备服务器的同步 | 
| --mcast-interface interface | 指定使用备服务器时候的广播接口 | 
原文:https://www.cnblogs.com/leixixi/p/14738932.html