[root@chen ~]# ipvsadm -help
ipvsadm v1.26 2008/5/15 (compiled with popt and IPVS v1.2.1)
Usage:
ipvsadm -A|E -t|u|f service-address [-s scheduler] [-p [timeout]] [-M netmask] [--pe persistence_engine]
ipvsadm -D -t|u|f service-address
ipvsadm -C
ipvsadm -R
ipvsadm -S [-n]
ipvsadm -a|e -t|u|f service-address -r server-address [options]
ipvsadm -d -t|u|f service-address -r server-address
ipvsadm -L|l [options]
ipvsadm -Z [-t|u|f service-address]
ipvsadm --set tcp tcpfin udp
ipvsadm --start-daemon state [--mcast-interface interface] [--syncid sid]
ipvsadm --stop-daemon state
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
Options:
--tcp-service -t service-address service-address is host[:port]
--udp-service -u service-address service-address is host[:port]
--fwmark-service -f fwmark fwmark is an integer greater than zero
--ipv6 -6 fwmark entry uses IPv6
--scheduler -s scheduler one of rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq,
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)
--weight -w weight capacity of real server
--u-threshold -x uthreshold upper threshold of connections
--l-threshold -y lthreshold lower threshold of connections
--mcast-interface interface multicast interface for connection sync
--syncid sid syncid for connection sync (default=255)
--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
--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
ipvsadm有兩種命令選項格式,長的和短的,具有相同的意思。在實際使用時,兩種都可以。-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 地址和端口的數字形式