日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ipvsadm命令总结

發布時間:2024/3/26 编程问答 58 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ipvsadm命令总结 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

ipvsadm工具介紹

  從2.4版本開始,linux內核默認支持LVS。要使用LVS的能力,只需安裝一個LVS的管理工具:ipvsadm。

LVS的結構主要分為兩部分:

  • 工作在內核空間的IPVS模塊。LVS的能力實際上都是由IVPS模塊實現。
  • 工作在用戶空間的ipvsadm管理工具。其作用是向用戶提供一個命令接口,用于將配置的虛擬服務、真實服務等傳給IPVS模塊。

以下選項用于list命令:

?-c, --connection:列出當前的IPVS連接。
????--timeout:列出超時
????--daemon:?顯示同步守護進程狀態
????--stats:狀態信息
????--rate:傳輸速率
????--thresholds:列出閾值
????--persistent-conn:堅持連接
????--sor:把列表排序。
????--nosort:不排序
????-n, --numeric:不對ip地址進行dns查詢
????--exact:單位

查看統計

  • 查看當前配置的虛擬服務和各個RS的權重

  ipvsadm -Ln

  • 查看當前ipvs模塊中記錄的連接(可用于觀察轉發情況)

  ipvsadm -lnc

  • 查看ipvs模塊的轉發情況統計

  ipvsadm -Ln --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) ?????每秒入流量(字節)


1.使用NAT模式
添加地址為207.175.44.110:80的虛擬服務,指定調度算法為輪轉。
ipvsadm -A -t 207.175.44.110:80 -s rr
添加真實服務器,指定傳輸模式為NAT
ipvsadm -a -t 207.175.44.110:80 -r 192.168.10.1:80 -m
ipvsadm -a -t 207.175.44.110:80 -r 192.168.10.2:80 -m
ipvsadm -a -t 207.175.44.110:80 -r 192.168.10.3:80 -m
NAT模式是lvs的三種模式中最簡單的一種。此種模式下只需要保證調度服務器與真實服務器互通就可以運行。


2.使用DR模式
對于DR模式首先要配置真實服務器:
對于每臺真實服務器要進行以下操作:
a、設置真實服務器的lo接口不做ARP應答
echo 1 > /proc/sys/net/ipv4/conf/all/arg_ignore
echo 1 > /proc/sys/net/ipv4/conf/lo/arg_ignore
設置這個選項可以使得各個接口只對本接口上的地址進行響應
還需要設置arp_announce選項為2,設置方法同上


b、在真實服務器上添加虛擬IP
ifconfig lo:0 192.168.10.10 boradcast 207.175.44.110 netmask 255.255.255.255
ip r add 192.168.10.10 dev lo
接著添加ipvs規則:
添加地址為192.168.10.10:80的虛擬服務,指定調度算法為輪轉。
ipvsadm -A -t 192.168.10.10:80 -s rr
添加真實服務器,指定傳輸模式為DR
ipvsadm -a -t 192.168.10.10:80 -r 192.168.10.1:80 -g
ipvsadm -a -t 192.168.10.10:80 -r 192.168.10.2:80 -g
ipvsadm -a -t 192.168.10.10:80 -r 192.168.10.3:80 -g
注意:此處的例子中客戶、調度服務器、真實服務器都是位于同一網段的

Usage:
命令?

./ipvsadm -A|E -t|u|q|f service-address [-s scheduler] [-j eanble/disable] [-p [timeout]] [-M netmask] [--pe persistence_engine]

ipvsadm -A|E -t|u|f <集群服務地址> [-s <調度算法>] [-p <超時時間>] [-M <掩碼>] [-b <標志>]

./ipvsadm -D -t|u|q|f service-address

?ipvsadm -D -t|u|f <集群服務地址>

./ipvsadm -C

?

./ipvsadm -R

?

./ipvsadm -S [-n]

?

./ipvsadm -P|Q -t|u|q|f service-address -z local-address

?

./ipvsadm -G -t|u|q|f service-address

?

./ipvsadm -U|V -t|u|q|f service-address -k blacklist-address

?

./ipvsadm -a|e -t|u|q|f service-address -r server-address [options]

?ipvsadm -a|e -t|u|f <集群服務地址> -r <真實服務器地址> [選項]

./ipvsadm -d -t|u|q|f service-address -r server-address

?ipvsadm -d -t|u|f <集群服務地址> -r <真實服務器地址>

./ipvsadm -L|l [options]

?ipvsadm -L|l [options]

./ipvsadm -Z [-t|u|q|f service-address]

ipvsadm -Z [-t|u|f <集群服務地址>]

./ipvsadm --set tcp tcpfin udp

ipvsadm --set <超時時間>

./ipvsadm --start-daemon state [--mcast-interface interface] [--syncid sid]

ipvsadm --start-daemon <主或備> [--mcast-interface <組播接口>] [--syncid <SID>]

./ipvsadm --stop-daemon state

?ipvsadm --stop-daemon <主或備>

./ipvsadm -h

?

?

Commands:
完整命令縮寫命令解釋中文解釋

--add-service

-Aadd 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

從標準輸入中恢復策略規則

--add-laddr

-P

add local address

?

--del-laddr

-Q

del local address

?

--get-laddr

-G

get local address

?

--add-blklst

-U

add blacklist address

?

--del-blklst

-V

del blacklist address

?

--get-blklst

-B

get blacklist address

?

--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

設置TCP、TCPFIN(TCP關閉連接狀態)、UDP連接超時時間,用于 會話保持。一般情況下TCP和UDP超時時間保持默認就好,TCPFIN 可以根據情況設定,指定它則用戶請求連接關閉,該連接則會變 為非活躍(InActive)空閑等待狀態,在空閑等待時間內,如果 來自同一源IP的請求,則還會轉發給后端的同一臺真實服務器上

--start-daemon

?

start connection sync daemon

開啟連接同步守護進程。在選項后面指定自己是Master(主)還 是backup(備),主負載調度器會同步所有策略及連接狀態到備 負載調度器,當主故障,備可以接替其工作

--stop-daemon

?

stop connection sync daemon

停止連接同步守護進程

--help

-h

display this help message

顯示幫助信息
Options:

--tcp-service? ? ? -t? service-address

service-address is host[:port]

<集群服務地址> 允許集群服務使用的傳輸協議為TCP

--udp-service? ? -u service-address

service-address is host[:port]<集群服務地址> 允許集群服務使用的傳輸協議為UDP

--icmp-service? ? -q service-address

service-address is host[:port]?

--icmpv6-service? ?-1 service-address

service-address is host[:port]?

--fwmark-service? ? -f fwmark

fwmark is an integer greater than zero

使用一個整數值來防火墻標識集群服務,而不是地址、 端口和協議使用它,我們可以通過結合IPtables將多 個以調度器為目標的端口定義成一個防火墻標識,由 ipvsdam通過此項關聯標識,則可以實現對一個IP多 端口調度,即實現后端服務器可以開放多個服務

--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.

指定集群服務使用的調度算法:rr|wrr|lc|wlc|lblc |lblcr|dh|sh|sed|nq,默認為wlc

--pe engine

alternate persistence engine may be sip,

not set by default.

?

--persistent? ? ?-p [timeout]

persistent service

<超時時間> 開啟持久化服務,開啟它則表示在指定時間內,來自同 一IP的請求都會轉發到后端同一臺真實服務器上

--netmask? ? ? -M netmask

persistent granularity mask

<網絡掩碼> 使用網絡掩碼來屏蔽持久化來源IP的地址范圍,默認值 為255.255.255.255,即所有來源IP請求都會享受持久 化服務

--real-server? ? ?-r server-address

server-address is host (and port)<真實服務器地址> 指定真實服務器的主機IP與端口

--gatewaying? ? -g

gatewaying (direct routing) (default)指定真實服務器轉發工作模式,使用DR模式,默認

--ipip? ? -i

ipip encapsulation (tunneling)指定真實服務器轉發工作模式,使用TUN模式

--fullnat? ? ? -b

fullnat mode?

--snat? ? ??-J

SNAT mode?

--masquerading? ? ? -m

masquerading (NAT)

指定真實服務器轉發工作模式,使用NAT模式

--weight? ? ? ? -w weight

capacity of real server

<權重值> 指定真實服務器的權重值

--u-threshold? ? ? ?-x uthreshold

upper threshold of connections<上閥值> 設置轉發請求的最大上連接閥值,范圍為0~65535,當 當連接數超過指定上限時,LVS則不會轉發請求

--l-threshold? ? ? ? -y lthreshold

lower threshold of connections設置轉發請求的下連接閥值,范圍為0~65535,當連接 數降低至指定值時,LVS則繼續提供服務,默認值為0

--mcast-interface interface

multicast interface for connection sync

設置用于連接同步守護進程的組播接口

--syncid sid

syncid for connection sync (default=255)設置連接同步守護進程的SID號,用于標識,范圍0~255

--connection? ? ? ?-c

output of current IPVS connections顯示連接信息,一般與"-l"連用

--timeout

output of timeout (tcp tcpfin udp)顯示TCP、TCPFIN、UDP超時時間信息,一般與"-l"連用

--daemon

output of daemon information顯示連接同步守護信息,一般與"-l"連用

--stats

output of statistics information顯示統計信息,一般與"-l"連用

--rate

output of rate information顯示轉發速率信息,一般與"-l"連用

--exact

expand numbers (display exact values)顯示數據包和字節計數器的確切值,擴大字符長度

--thresholds

output of thresholds information顯示閥值信息,一般與"-l"連用

--persistent-conn

output of persistent connection info顯示持久化連接信息,一般與"-l"連用

--sockpair

output connection info of specified socket pair (proto:sip:sport:tip:tport)

?

?

總結

以上是生活随笔為你收集整理的ipvsadm命令总结的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。