分享

Ipvsadm参数详解(常用命令)

 笑观云卷云舒 2017-10-23
  1. [root@localhost ipvsadm]#  ipvsadm  -h  
  2. ipvsadm v1.24 2005/12/10 (compiled with popt and IPVS v1.2.1)  
  3. Usage:  
  4.   ipvsadm -A|E -t|u|f service-address [-s scheduler] [-p [timeout]] [-M netmask]  
  5.   ipvsadm -D -t|u|f service-address  
  6.   ipvsadm -C  
  7.   ipvsadm -R  
  8.   ipvsadm -S [-n]  
  9.   ipvsadm -a|e -t|u|f service-address -r server-address [options]  
  10.   ipvsadm -d -t|u|f service-address -r server-address  
  11.   ipvsadm -L|l [options]  
  12.   ipvsadm -Z [-t|u|f service-address]  
  13.   ipvsadm --set tcp tcpfin udp  
  14.   ipvsadm --start-daemon state [--mcast-interface interface] [--syncid sid]  
  15.   ipvsadm --stop-daemon state  
  16.   ipvsadm -h  
  17.   
  18. Commands:  
  19. Either long or short options are allowed.  
  20.   --add-service     -A        add virtual service with options  
  21.   --edit-service    -E        edit virtual service with options  
  22.   --delete-service  -D        delete virtual service  
  23.   --clear           -C        clear the whole table  
  24.   --restore         -R        restore rules from stdin  
  25.   --save            -S        save rules to stdout  
  26.   --add-server      -a        add real server with options  
  27.   --edit-server     -e        edit real server with options  
  28.   --delete-server   -d        delete real server  
  29.   --list            -L|-l     list the table  
  30.   --zero            -Z        zero counters in a service or all services  
  31.   --set tcp tcpfin udp        set connection timeout values  
  32.   --start-daemon              start connection sync daemon  
  33.   --stop-daemon               stop connection sync daemon  
  34.   --help            -h        display this help message  
  35.   
  36. Options:  
  37.   --tcp-service  -t service-address   service-address is host[:port]  
  38.   --udp-service  -u service-address   service-address is host[:port]  
  39.   --fwmark-service  -f fwmark         fwmark is an integer greater than zero  
  40.   --scheduler    -s scheduler         one of rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq,  
  41.                                       the default scheduler is wlc.  
  42.   --persistent   -p [timeout]         persistent service  
  43.   --netmask      -M netmask           persistent granularity mask  
  44.   --real-server  -r server-address    server-address is host (and port)  
  45.   --gatewaying   -g                   gatewaying (direct routing) (default)  
  46.   --ipip         -i                   ipip encapsulation (tunneling)  
  47.   --masquerading -m                   masquerading (NAT)  
  48.   --weight       -w weight            capacity of real server  
  49.   --u-threshold  -x uthreshold        upper threshold of connections  
  50.   --l-threshold  -y lthreshold        lower threshold of connections  
  51.   --mcast-interface interface         multicast interface for connection sync  
  52.   --syncid sid                        syncid for connection sync (default=255)  
  53.   --connection   -c                   output of current IPVS connections  
  54.   --timeout                           output of timeout (tcp tcpfin udp)  
  55.   --daemon                            output of daemon information  
  56.   --stats                             output of statistics information  
  57.   --rate                              output of rate information  
  58.   --exact                             expand numbers (display exact values)  
  59.   --thresholds                        output of thresholds information  
  60.   --persistent-conn                   output of persistent connection info  
  61.   --sort                              sorting output of service/server entries  
  62.   --numeric      -n                   numeric output of addresses and ports  

[plain] view plain copy
  1. --add-service     -A        add virtual service with option  
  2.   在内核的虚拟服务器表中添加一条新的虚拟服务器记录。也就是增加一台新的虚拟服务器  
  3.   --edit-service    -E        edit virtual service with options  
  4.   编辑内核虚拟服务器表中的一条虚拟服务器记录  
  5.   --delete-service  -D        delete virtual service  
  6.   删除内核虚拟服务器表中的一条虚拟服务器记录  
  7.   --clear           -C        clear the whole table  
  8.   清除内核虚拟服务器表中的所有记录  
  9.   --restore         -R        restore rules from stdin  
  10.   恢复虚拟服务器规则  
  11.   --save            -S        save rules to stdout  
  12.   保存虚拟服务器规则,输出为-R 选项可读的格式  
  13.   --add-server      -a        add real server with options  
  14.   在内核虚拟服务器表的一条记录里添加一条新的真实服务器  
  15.   --edit-server     -e        edit real server with options  
  16.   编辑一条虚拟服务器记录中的某条真实服务器记录  
  17.   --delete-server   -d        delete real server  
  18.   删除一条虚拟服务器记录中的某条真实服务器记录  
  19.   --list            -L|-l     list the table  
  20.   显示内核虚拟服务器表  
  21.   --zero            -Z        zero counters in a service or all services  
  22.   虚拟服务表计数器清零  
  23.   --set tcp tcpfin udp        set connection timeout values  
  24.   设置连接超时值  
  25.   --start-daemon              start connection sync daemon  
  26.   启动同步守护进程。他后面可以是master 或backup,用来说明LVS Router 是master 或是backup。在这个功能上也可以采keepalived 的VRRP 功能。  
  27.   --stop-daemon               stop connection sync daemon  
  28.   停止同步守护进程  
  29.   --help            -h        display this help message  
  30.   显示帮助信息  
  31.    
  32. Options:  
  33.    
  34.   --tcp-service  -t service-address   service-address is host[:port]  
  35.   说明虚拟服务器提供的是tcp 的服务[vip:port] or [real-server-ip:port]  
  36.   --udp-service  -u service-address   service-address is host[:port]  
  37.   说明虚拟服务器提供的是udp 的服务[vip:port] or [real-server-ip:port]  
  38.   --fwmark-service  -f fwmark         fwmark is an integer greater than zero  
  39.   说明是经过iptables 标记过的服务类型。  
  40.   --scheduler    -s scheduler         one of rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq,the default scheduler is wlc.  
  41.   使用的调度算法,有这样几个选项,默认的调度算法是: wlc.  
  42.   --persistent   -p [timeout]         persistent service  
  43.   持久稳固的服务。这个选项的意思是来自同一个客户的多次请求,将被同一台真实的服务器处理。timeout 的默认值为300 秒  
  44.   --netmask      -M netmask           persistent granularity mask  
  45.     
  46.   --real-server  -r server-address    server-address is host (and port)  
  47.   真实的服务器[Real-Server:port]  
  48.   --gatewaying   -g                   gatewaying (direct routing) (default)  
  49.   指定LVS 的工作模式为直接路由模式(也是LVS 默认的模式  
  50.   --ipip         -i                   ipip encapsulation (tunneling)  
  51.   指定LVS 的工作模式为隧道模式  
  52.   --masquerading -m                   masquerading (NAT)  
  53.   指定LVS 的工作模式为NAT 模式  
  54.   --weight       -w weight            capacity of real server  
  55.   真实服务器的权值  
  56.   --u-threshold  -x uthreshold        upper threshold of connections  
  57.     
  58.   --l-threshold  -y lthreshold        lower threshold of connections  
  59.    
  60.   --mcast-interface interface         multicast interface for connection sync  
  61.   指定组播的同步接口  
  62.   --syncid sid                        syncid for connection sync (default=255)  
  63.    
  64.   --connection   -c                   output of current IPVS connections  
  65.   显示LVS 目前的连接 如:ipvsadm -L -c  
  66.   --timeout                           output of timeout (tcp tcpfin udp)  
  67.   显示tcp tcpfin udp 的timeout 值 如:ipvsadm -L --timeout  
  68.   --daemon                            output of daemon information  
  69.   显示同步守护进程状态  
  70.   --stats                             output of statistics information  
  71.   显示统计信息  
  72.   --rate                              output of rate information  
  73.   显示速率信息  
  74.   --thresholds                        output of thresholds information  
  75.     
  76.   --persistent-conn                   output of persistent connection info  
  77.     
  78.   --sort                              sorting output of service/server entries  
  79.    对虚拟服务器和真实服务器排序输出  
  80.   --ops          -O                   one-packet scheduling  
  81.     
  82.   --numeric      -n                   numeric output of addresses and ports  
  83.   输出IP 地址和端口的数字形式  

有两种命令选项格式,长的和短的,具有相同的意思。在实际使用时,两种都可
以。
-A –add-service 在内核的虚拟服务器表中添加一条新的虚拟服务器记录。也
就是增加一台新的虚拟服务器。
-E –edit-service 编辑内核虚拟服务器表中的一条虚拟服务器记录。
-D –delete-service 删除内核虚拟服务器表中的一条虚拟服务器记录。
-C –clear 清除内核虚拟服务器表中的所有记录。
-R –restore 恢复虚拟服务器规则
-S –save 保存虚拟服务器规则,输出为-R 选项可读的格式
-a –add-server 在内核虚拟服务器表的一条记录里添加一条新的真实服务器
记录。也就是在一个虚拟服务器中增加一台新的真实服务器
-e –edit-server 编辑一条虚拟服务器记录中的某条真实服务器记录
-d –delete-server 删除一条虚拟服务器记录中的某条真实服务器记录
-L|-l –list 显示内核虚拟服务器表
-Z –zero 虚拟服务表计数器清零(清空当前的连接数量等)
–set tcp tcpfin udp 设置连接超时值
–start-daemon 启动同步守护进程。他后面可以是master 或backup,用来说
明LVS Router 是master 或是backup。在这个功能上也可以采用keepalived 的
VRRP 功能。
–stop-daemon 停止同步守护进程
-h –help 显示帮助信息
其他的选项:
-t –tcp-service service-address 说明虚拟服务器提供的是tcp 的服务
[vip:port] or [real-server-ip:port]
-u –udp-service service-address 说明虚拟服务器提供的是udp 的服务
[vip:port] or [real-server-ip:port]
-f –fwmark-service fwmark 说明是经过iptables 标记过的服务类型。
-s –scheduler scheduler 使用的调度算法,有这样几个选项
rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq,
默认的调度算法是: wlc.
-p –persistent [timeout] 持久稳固的服务。这个选项的意思是来自同一个客
户的多次请求,将被同一台真实的服务器处理。timeout 的默认值为300 秒。
-M –netmask netmask persistent granularity mask
-r –real-server server-address 真实的服务器[Real-Server:port]
-g –gatewaying 指定LVS 的工作模式为直接路由模式(也是LVS 默认的模式)
-i –ipip 指定LVS 的工作模式为隧道模式
-m –masquerading 指定LVS 的工作模式为NAT 模式
-w –weight weight 真实服务器的权值
–mcast-interface interface 指定组播的同步接口
-c –connection 显示LVS 目前的连接 如:ipvsadm -L -c
–timeout 显示tcp tcpfin udp 的timeout 值 如:ipvsadm -L –timeout
–daemon 显示同步守护进程状态
–stats 显示统计信息
–rate 显示速率信息
–sort 对虚拟服务器和真实服务器排序输出

–numeric -n 输出IP 地址和端口的数字形式

[plain] view plain copy
  1. --stat选项是统计自该条转发规则生效以来的包  
  2. 1. Conns    (connections scheduled)  已经转发过的连接数  
  3. 2. InPkts   (incoming packets)       入包个数  
  4. 3. OutPkts  (outgoing packets)       出包个数  
  5. 4. InBytes  (incoming bytes)         入流量(字节)    
  6. 5. OutBytes (outgoing bytes)         出流量(字节)  

[plain] view plain copy
  1. --rate选项是显示速率信息  
  2. 1. CPS      (current connection rate)   每秒连接数  
  3. 2. InPPS    (current in packet rate)    每秒的入包个数  
  4. 3. OutPPS   (current out packet rate)   每秒的出包个数  
  5. 4. InBPS    (current in byte rate)      每秒入流量(字节)  
  6. 5. OutBPS   (current out byte rate)      每秒入流量(字节)  

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多