13. nginx,lvs之一

来源:https://www.cnblogs.com/mylinuxroad/archive/2018/08/21/9447112.html
-Advertisement-
Play Games

1、詳細描述常見nginx常用模塊和模塊的使用示例 2、簡述Linux集群類型、系統擴展方式及調度方法 3、簡述lvs四種集群特點及使用場景 4、描述LVS-NAT、LVS-DR的工作原理並實現配置 ...


摘要:

1、詳細描述常見nginx常用模塊和模塊的使用示例 
2、簡述Linux集群類型、系統擴展方式及調度方法 
3、簡述lvs四種集群有點及使用場景 
4、描述LVS-NAT、LVS-DR的工作原理並實現配置

 

1、詳細描述常見nginx常用模塊和模塊的使用示例 

 

Nginx的代碼由一個核心和一系列的模塊組成。

核心(core functionality)主要用於提供全局應用的基本功能,創建必要的運行時環境及確保不同模塊之間平滑地進行交互等,對應於配置文件的main段和event段。核心涉及的指令官方文檔:http://nginx.org/en/docs/ngx_core_module.html

還有很多功能都通過模塊實現,nginx是高度模塊化程式。如web相關的功能模塊有"ngx_http_*_module",和mail相關的功能模塊有"ngx_mail_*_module",和tcp代理、負載均衡相關的功能模塊有"ngx_stream_*_module",這些類別的模塊中又分為很多類別的模塊,如http類別的模塊中有基本核心模塊、事件類模塊、緩存類模塊、SSL相關模塊、負載均衡類模塊upstream等等。

以下是http功能模塊類中常見的模塊。

http類模塊名模塊功能說明
ngx_http_core_module http核心模塊,對應配置文件中的http段,包含很多指令,如location指令
ngx_http_access_module 訪問控制模塊,控制網站用戶對nginx的訪問,對應於配置文件中的allow和deny等指令
ngx_http_auth_basic_module 通過用戶名和密碼認證的訪問控制,如訪問站點時需要數據用戶名和密碼,指令包括auth_basic和auth_basic_user_file
ngx_http_charset_module 設置網頁顯示字元集。指令之一為charset,如charset utf-8
ngx_http_fastcgi_module fastcgi模塊,和動態應用相關。該模塊下有非常多的子模塊。
ngx_http_flv_module 支持flv視頻流的模塊,如邊下邊播
ngx_http_mp4_module 同flv模塊
ngx_http_gzip_module 壓縮模塊,用來壓縮nginx返回的響應報文。一般只壓縮純文本內容,因為壓縮比例非常大,而圖片等不會去壓縮
ngx_http_image_filter_module 和圖片裁剪、縮略圖相關模塊,需要安裝gd-devel才能編譯該模塊
ngx_http_index_module 定義將要被作為預設主頁的文件,對應指令為index。"index index.html,index.php"
ngx_http_autoindex_module 當index指令指定的主頁文件不存在時,交給autoindex指令,將自動列出目錄中的文件autoindex {on/off}  
ngx_http_log_module 和訪問日誌相關的模塊,指令包括log_format和access_log
ngx_http_memcached_module 和memcached相關的模塊,用於從memcached伺服器中獲取相應響應數據
ngx_http_proxy_module 和代理相關,允許傳送請求到其它伺服器
ngx_http_realip_module 當nginx在反向代理的後端提供服務時,獲取到真正的客戶端地址,否則獲取的是反向代理的IP地址
ngx_http_referer_module 實現防盜鏈功能的模塊
ngx_http_rewrite_module 和URL地址重寫相關的模塊,需要安裝pcre-devel才能編譯安裝該模塊
ngx_http_scgi_module simple cgi,是cgi的替代品,和fastcgi類似,但更簡單
ngx_http_ssl_module 提供ssl功能的模塊,即實現HTTPS
ngx_http_stub_status_module 獲取nginx運行狀態信息
ngx_http_upstream 和負載均衡相關模塊

下麵只介紹三個模塊:

ngx_http_access module          實現基於IP地址的訪問控制

ngx_http_auth_basic_module   實現基於用戶的訪問控制,使用basic認證機制認證

ngx_http_stub_status_module   用於輸出nginx的基本狀態信息

 

1.1  在伺服器上配置/etc/nginx/conf.d/vhost.conf文件

[root@bogon conf.d]# cat vhost.conf
server {
listen 80;
server_name www.danlee.io;
root /data/nginx/vhost;

location / {
deny 192.168.1.11;
allow all;
}

location ~* ^/(admin|login) {
auth_basic "admin area or login url";
auth_basic_user_file /etc/nginx/.ngxpasswd;
}

location /ngxstatus {
stub_status;
}
}

[root@bogon conf.d]# tree /data
/data
└── nginx
└── vhost
├── admin
│   └── index.html
└── index.html

3 directories, 2 files
[root@bogon conf.d]# cat /data/nginx/vhost/index.html
<h1>www.danlee.io, mainpage</h1>
[root@bogon conf.d]# cat /data/nginx/vhost/admin/index.html
<h1>Admin area</h1>

[root@bogon conf.d]#htpasswd -c -m /etc/nginx/.ngxpasswd tom

[root@bogon conf.d]#htpasswd -m /etc/nginx/.ngxpasswd jerry

[root@bogon conf.d]# cat /etc/nginx/.ngxpasswd
tom:$apr1$nYfn6I3F$NmKnqGEwLtOySxkNljc9P1
jerry:$apr1$2sa3N.Kg$Ju1tJ8IcMX4lmgS8qzOKo.

 

[root@bogon conf.d]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@bogon conf.d]# nginx -s reload

 

 1.2 在兩個客戶端驗證

首先在兩個客戶端上都編輯/etc/hosts文件添加伺服器IP and server name.

192.168.1.21   www.danlee.io

客戶端192.168.1.22上 驗證:

 1 [root@bogon ~]# curl http://www.danlee.io/ngxstatus
 2 Active connections: 1 
 3 server accepts handled requests
 4  7 7 11 
 5 Reading: 0 Writing: 1 Waiting: 0 
 6 [root@bogon ~]# curl http://www.danlee.io
 7 <h1>www.danlee.io, mainpage</h1>
 8 [root@bogon ~]# curl http://www.danlee.io/index.html
 9 <h1>www.danlee.io, mainpage</h1>
10 [root@bogon ~]# cat /etc/hosts
11 127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
12 ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
13 192.168.1.21  www.danlee.io

 

 

客戶端192.168.1.11上 驗證:

 1 [root@localhost ~]# curl http://www.danlee.io
 2 <html>
 3 <head><title>403 Forbidden</title></head>
 4 <body bgcolor="white">
 5 <center><h1>403 Forbidden</h1></center>
 6 <hr><center>nginx/1.12.2</center>
 7 </body>
 8 </html>
 9 [root@localhost ~]# curl http://www.danlee.io/ngxstatus
10 Active connections: 1 
11 server accepts handled requests
12  14 14 18 
13 Reading: 0 Writing: 1 Waiting: 0 
14 [root@localhost ~]# curl http://www.danlee.io/admin
15 <html>
16 <head><title>401 Authorization Required</title></head>
17 <body bgcolor="white">
18 <center><h1>401 Authorization Required</h1></center>
19 <hr><center>nginx/1.12.2</center>
20 </body>
21 </html>
22 [root@localhost ~]# 

 

 備註: 因為沒有在伺服器端對ngxstatus模塊配置驗證,此客戶端依然可以訪問該頁面數據。

 


2、簡述Linux集群類型、系統擴展方式及調度方法

Linux Cluster類型:
LB:Load Balancing,負載均衡;
HA:High Availiablity,高可用;
A=MTBF/(MTBF+MTTR)
(0,1):90%, 95%, 99%, 99.5%, 99.9%, 99.99%, 99.999%, 99.9999%
HP:High Performance,高性能;

 

系統擴展方式:
Scale UP:向上擴展
Scale Out:向外擴展

 

ipvs scheduler:
根據其調度時是否考慮各RS當前的負載狀態,可分為靜態方法和動態方法兩種:

靜態方法:僅根據演算法本身進行調度;
RR:roundrobin,輪詢;
WRR:Weighted RR,加權輪詢;
SH:Source Hashing,實現session sticky,源IP地址hash;將來自於同一個IP地址的請求始終發往第一次挑中的RS,從而實現會話綁定;
DH:Destination Hashing;目標地址哈希,將發往同一個目標地址的請求始終轉發至第一次挑中的RS,典型使用場景是正向代理緩存場景中的負載均衡;

動態方法:主要根據每RS當前的負載狀態及調度演算法進行調度;
Overhead=負載值

LC:least connections
Overhead=activeconns*256+inactiveconns
WLC:Weighted LC
Overhead=(activeconns*256+inactiveconns)/weight
SED:Shortest Expection Delay
Overhead=(activeconns+1)*256/weight
NQ:Never Queue

LBLC:Locality-Based LC,動態的DH演算法;
LBLCR:LBLC with Replication,帶複製功能的LBLC;


3、簡述lvs四種集群特點及使用場景 

 

lvs集群的類型:
lvs-nat:修改請求報文的目標IP;多目標IP的DNAT;
lvs-dr:操縱封裝新的MAC地址;
lvs-tun:在原請求IP報文之外新加一個IP首部;
lvs-fullnat:修改請求報文的源和目標IP;

 

lvs-nat:
多目標IP的DNAT,通過將請求報文中的目標地址和目標埠修改為某挑出的RS的RIP和PORT實現轉發;

(1)RIP和DIP必須在同一個IP網路,且應該使用私網地址;RS的網關要指向DIP; (DIP是內網,VIP是外網?)
(2)請求報文和響應報文都必須經由Director轉發;Director易於成為系統瓶頸;
(3)支持埠映射,可修改請求報文的目標PORT;
(4)vs必須是Linux系統,rs可以是任意系統;

lvs-dr:
Direct Routing,直接路由;
通過為請求報文重新封裝一個MAC首部進行轉發,源MAC是DIP所在的介面的MAC,
目標MAC是某挑選出的RS的RIP所在介面的MAC地址;源IP/PORT,以及目標IP/PORT均保持不變;

Director和各RS都得配置使用VIP;
(1) 確保前端路由器將目標IP為VIP的請求報文發往Director:
(a) 在前端網關做靜態綁定;
(b) 在RS上使用arptables;
(c) 在RS上修改內核參數以限制arp通告及應答級別;
arp_announce
arp_ignore
(2) RS的RIP可以使用私網地址,也可以是公網地址;RIP與DIP在同一IP網路;RIP的網關不能指向DIP,以確保響應報文不會經由Director;
(3) RS跟Director要在同一個物理網路;
(4) 請求報文要經由Director,但響應不能經由Director,而是由RS直接發往Client;
(5) 不支持埠映射;

 

 

lvs-tun:
轉發方式:不修改請求報文的IP首部(源IP為CIP,目標IP為VIP),而是在原IP報文之外再封裝一個IP首部(源IP是DIP,目標IP是RIP),
將報文發往挑選出的目標RS;RS直接響應給客戶端(源IP是VIP,目標IP是CIP);

(1) DIP, VIP, RIP都應該是公網地址;
(2) RS的網關不能,也不可能指向DIP;
(3) 請求報文要經由Director,但響應不能經由Director;
(4) 不支持埠映射;
(5) RS的OS得支持隧道功能;

lvs-fullnat:
通過同時修改請求報文的源IP地址和目標IP地址進行轉發;
CIP <--> DIP
VIP <--> RIP

(1) VIP是公網地址,RIP和DIP是私網地址,且通常不在同一IP網路;因此,RIP的網關一般不會指向DIP;
(2) RS收到的請求報文源地址是DIP,因此,只能響應給DIP;但Director還要將其發往Client;
(3) 請求和響應報文都經由Director;
(4) 支持埠映射;

註意:此類型預設不支持;


總結:
lvs-nat, lvs-fullnat:請求和響應報文都經由Director;
lvs-nat:RIP的網關要指向DIP;
lvs-fullnat:RIP和DIP未必在同一IP網路,但要能通信;
lvs-dr, lvs-tun:請求報文要經由Director,但響應報文由RS直接發往Client;
lvs-dr:通過封裝新的MAC首部實現,通過MAC網路轉發;
lvs-tun:通過在原IP報文之外封裝新的IP首部實現轉發,支持遠距離通信;


4、描述LVS-NAT、LVS-DR的工作原理並實現配置

lvs-nat:
多目標IP的DNAT,通過將請求報文中的目標地址和目標埠修改為某挑出的RS的RIP和PORT實現轉發;
(1)RIP和DIP必須在同一個IP網路,且應該使用私網地址;RS的網關要指向DIP;
(2)請求報文和響應報文都必須經由Director轉發;Director易於成為系統瓶頸;
(3)支持埠映射,可修改請求報文的目標PORT;
(4)vs必須是Linux系統,rs可以是任意系統;

 

1)準備:
1. 關閉selinux, 清空iptables, 同步dr, rs1, rs2上的時間
2. 在rs1, rs2上分別安裝nginx, telnet-server
在dr上安裝nginx, ipvsadm
3. dr調度器:
                   DIP: 192.168.1.6
                   VIP: 127.16.1.7
rs1伺服器1 RIP1:127.16.1.8
rs2伺服器2 RIP2: 127.16.1.9
如果是dr, rs在同一臺電腦上的虛擬機上,dip, rip都需要改為僅主機模式vmnet1。調整網路前先安裝必要的軟體包。
VIP, RIP需要使用私網地址。
Director要打開核心轉發功能sysctl -w net.ipv4.ip_forward=1
如何在虛擬機中添加一個新的網卡,可以參考(實際步驟會不相同)https://blog.csdn.net/qq_21383435/article/details/51126577

2)配置:

在RS1上:

# vim /usr/share/nginx/html/test1.html        添加內容<h1>RS1, ####172.16.1.8</h1>
# systemctl start nginx.service

# ss -tnl                       檢查80埠是否打開

在RS2上:

# vim /usr/share/nginx/html/test1.html        添加內容<h1>RS2, ####172.16.1.9</h1>

# systemctl start nginx.service

# ss -tnl                       檢查80埠是否打開

在DR上:

[root@bogon ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.6 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::fb51:8e3:4aa5:5358 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:37:ff:fd txqueuelen 1000 (Ethernet)
RX packets 7072 bytes 5524007 (5.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3960 bytes 354712 (346.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

ens37: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.1.7 netmask 255.255.0.0 broadcast 172.16.255.255
inet6 fe80::20c:29ff:fe37:ff07 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:37:ff:07 txqueuelen 1000 (Ethernet)
RX packets 717 bytes 85009 (83.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 133 bytes 15590 (15.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

 

[root@bogon ~]# ipvsadm -A -t 192.168.1.6:80 -s rr           #註意此處為VIP

[root@bogon ~]# ipvsadm -a -t 192.168.1.6:80 -r 172.16.1.9 -m
[root@bogon ~]# ipvsadm -a -t 192.168.1.6:80 -r 172.16.1.8 -m
[root@bogon ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.1.6:80 rr
-> 172.16.1.8:80 Masq 1 0 0
-> 172.16.1.9:80 Masq 1 0 0

在客戶端上:

[root@stephen ~]# curl http://192.168.1.6/test1.html
<h1>RS1, ####172.16.1.8</h1>
[root@stephen ~]# curl http://192.168.1.6/test1.html
<h1>RS2,###172.16.1.9</h1>

[root@stephen ~]# for i in {1..10}; do curl http://192.168.1.6/test1.html; done
<h1>RS1, ####172.16.1.8</h1>
<h1>RS2,###172.16.1.9</h1>
<h1>RS1, ####172.16.1.8</h1>
<h1>RS2,###172.16.1.9</h1>
<h1>RS1, ####172.16.1.8</h1>
<h1>RS2,###172.16.1.9</h1>
<h1>RS1, ####172.16.1.8</h1>
<h1>RS2,###172.16.1.9</h1>
<h1>RS1, ####172.16.1.8</h1>
<h1>RS2,###172.16.1.9</h1>

 

LVS-DR模型:

Direct Routing,直接路由;

通過為請求報文重新封裝一個MAC首部進行轉發,源MAC是DIP所在的介面的MAC,
目標MAC是某挑選出的RS的RIP所在介面的MAC地址;源IP/PORT,以及目標IP/PORT均保持不變;

Director和各RS都得配置使用VIP;
(1) 確保前端路由器將目標IP為VIP的請求報文發往Director:
(a) 在前端網關做靜態綁定;
(b) 在RS上使用arptables;
(c) 在RS上修改內核參數以限制arp通告及應答級別;
arp_announce
arp_ignore
(2) RS的RIP可以使用私網地址,也可以是公網地址;RIP與DIP在同一IP網路;RIP的網關不能指向DIP,以確保響應報文不會經由Director; 他們的網關相同可以嗎?
(3) RS跟Director要在同一個物理網路;
(4) 請求報文要經由Director,但響應不能經由Director,而是由RS直接發往Client;
(5) 不支持埠映射;

 

1)準備:

1. 關閉selinux, 清空iptables, 同步dr, rs1, rs2上的時間

2. 在rs1, rs2上分別安裝httpd 在dr上安裝ipvsadm

3.dr, rs都是橋接

dr調度器: 
                   DIP: 192.168.1.6 
                   VIP: 192.16.1.99  在ens33:0上
rs1伺服器1 RIP1:192.168.1.4

                  VIP: 192.168.1.99   在lo:0上
rs2伺服器2 RIP2: 192.168.1.5
                  VIP: 192.168.1.99   在lo:0上

思考: vip要和rip在同一網段中嗎? 

            當VIP全部設置為VIP: 172.16.0.99,結果失敗,地址0改為1後就成功了。

2)配置:

在RS1上:

# vim /var/www/html/test1.html        添加內容<h1> RS1, 192.168.1.4 </h1>

[root@bogon ~]# vim setparam.sh
[root@bogon ~]# cat setparam.sh
#!/bin/bash
#
vip='192.168.1.99'
mask='255.255.255.255'
iface='lo:0'

case $1 in
start)
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce

ifconfig $iface $vip netmask $mask broadcast $vip up
route add -host $vip dev $iface
;;
stop)
ifconfig $iface down

echo 0 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 0 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 0 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 0 > /proc/sys/net/ipv4/conf/lo/arp_announce

;;
*)
echo "Usage $(basename $0) start|stop"
exit 1
;;
esac

[root@bogon ~]# bash -n setparam.sh
[root@bogon ~]# bash -x setparam.sh start
+ vip=192.168.1.99
+ mask=255.255.255.255
+ iface=lo:0
+ case $1 in
+ echo 1
+ echo 1
+ echo 2
+ echo 2
+ ifconfig lo:0 192.168.1.99 netmask 255.255.255.255 broadcast 172.16.0.99 up
+ route add -host 192.168.1.99 dev lo:0

# scp setparam.sh 192.168.1.5:/root/

# systemctl start httpd.service

# ss -tnl                           檢查80埠是否打開

 

在RS2上:

[root@bogon ~]# ls
anaconda-ks.cfg setparam.sh
[root@bogon ~]# bash -x setparam.sh start
+ vip=192.168.1.99
+ mask=255.255.255.255
+ iface=lo:0
+ case $1 in
+ echo 1
+ echo 1
+ echo 2
+ echo 2
+ ifconfig lo:0 192.168.1.99 netmask 255.255.255.255 broadcast 192.168.1.99 up
+ route add -host 192.168.1.99 dev lo:0
[root@bogon ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.5 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::8b7:c57a:ebbd:80b7 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:9e:a5:df txqueuelen 1000 (Ethernet)
RX packets 15795 bytes 17043985 (16.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8126 bytes 786863 (768.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 4 bytes 336 (336.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4 bytes 336 (336.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo:0: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 192.168.1.99 netmask 255.255.255.255
loop txqueuelen 1000 (Local Loopback)

# vim /var/www/html/test1.html        添加內容<h1> RS2, 192.168.1.5 </h1>

# systemctl start httpd.service

# ss -tnl                       檢查80埠是否打開

 

在DR上:

[root@bogon network-scripts]# curl http://192.168.1.4/test1.html
<h1> RS1, 192.168.1.4 </h1>
[root@bogon network-scripts]# curl http://192.168.1.5/test1.html
<h1> RS2, 192.168.1.5 </h1>

[root@bogon network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.6 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::fb51:8e3:4aa5:5358 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:37:ff:fd txqueuelen 1000 (Ethernet)
RX packets 2310 bytes 241192 (235.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 476 bytes 42028 (41.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

[root@bogon network-scripts]# ifconfig ens33:0 192.168.1.99 netmask 255.255.255.255 broadcast 192.168.1.99 up

[root@bogon network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.6 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::fb51:8e3:4aa5:5358 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:37:ff:fd txqueuelen 1000 (Ethernet)
RX packets 2513 bytes 259088 (253.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 602 bytes 56844 (55.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

ens33:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.99 netmask 255.255.255.255 broadcast 172.16.0.99
ether 00:0c:29:37:ff:fd txqueuelen 1000 (Ethernet)

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

 

 

在客戶端上:

[root@stephen ~]# curl http://192.168.1.99/test1.html
<h1> RS1, 192.168.1.4 </h1>
[root@stephen ~]# curl http://192.168.1.99/test1.html
<h1> RS2, 192.168.1.5 </h1>
[root@stephen ~]# for i in {1..15}; do curl http://192.168.1.99/test1.html; done
<h1> RS1, 192.168.1.4 </h1>
<h1> RS2, 192.168.1.5 </h1>
<h1> RS1, 192.168.1.4 </h1>
<h1> RS2, 192.168.1.5 </h1>
<h1> RS1, 192.168.1.4 </h1>
<h1> RS2, 192.168.1.5 </h1>
<h1> RS1, 192.168.1.4 </h1>
<h1> RS2, 192.168.1.5 </h1>
<h1> RS1, 192.168.1.4 </h1>
<h1> RS2, 192.168.1.5 </h1>
<h1> RS1, 192.168.1.4 </h1>
<h1> RS2, 192.168.1.5 </h1>
<h1> RS1, 192.168.1.4 </h1>
<h1> RS2, 192.168.1.5 </h1>
<h1> RS1, 192.168.1.4 </h1>

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • RD命令: // 描述: 刪除目錄或子目錄。同 rmdir // 語法: rd [<drive:>]<path> /s /q /? // 參數: /s: (subdirectory) 刪除時連同其子目錄下的所有文件都刪除 /q: (quiet) 安靜模式刪除。刪除時沒有提示。 /?: 幫助信息。 / ...
  • 1、cd命令 這是一個非常基本,也是大家經常需要使用的命令,它用於切換當前目錄,它的參數是要切換到的目錄的路徑,可以是絕對路徑,也可以是相對路徑。如: cd /root/Docements # 切換到目錄/root/Docements cd /root/Docements # 切換到目錄/root/ ...
  • MD命令: // 描述: (Make Directory) 創建一個目錄或子目錄。 // 語法: md [<Drive>:]<Path> // 參數: [<Drive:>] : 指定要在其上創建新目錄的驅動器。 <Path> : 指定新目錄的名稱和位置。 任何單個路徑的最大長度由文件系統確定。 /? ...
  • DIR 命令: // 描述: (Directory) 顯示目錄的文件和子目錄的列表。 // 語法: dir [<Drive>:][<Path>][<FileName>] [...] [/p] [/q] [/w] [/d] [/a[[:]<Attributes>]][/o[[:]<SortOrder> ...
  • taskkill 命令: // 描述: 結束一個或多個任務或流程。 // 語法: taskkill [/s <computer> [/u [<Domain>\]<UserName> [/p [<Password>]]]] {[/fi <Filter>] [...] [/pid <ProcessID> ...
  • IDEA切換項目時,如果前一個項目處於調試和運行狀態,8080埠將被占用,處理如下:1.netstat -ano|findstr 80802.taskkill /f /t /im 597448 ...
  • 自己動手改下註冊表就行 文件打開關聯被改了但是在這裡面卻不能選擇系統預設的打開方式 改下註冊表就能恢復預設了 開始--運行--regedit 打開註冊表 找到鍵HKEY_CURRENT_USER\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\F ...
  • 這裡以centos6為例: 第一步:先將系統重新啟動,在讀秒的時候按下任意鍵就會出現如下圖的菜單界面: 第二步:按下『e』就能夠進入grub的編輯模式,如圖: 第三步:將游標移動到kernel那一行,再按一次『 e 』進入kernel該行的編輯畫面中, 然後在出現的畫面當中,在最後輸入 single ...
一周排行
    -Advertisement-
    Play Games
  • 示例項目結構 在 Visual Studio 中創建一個 WinForms 應用程式後,項目結構如下所示: MyWinFormsApp/ │ ├───Properties/ │ └───Settings.settings │ ├───bin/ │ ├───Debug/ │ └───Release/ ...
  • [STAThread] 特性用於需要與 COM 組件交互的應用程式,尤其是依賴單線程模型(如 Windows Forms 應用程式)的組件。在 STA 模式下,線程擁有自己的消息迴圈,這對於處理用戶界面和某些 COM 組件是必要的。 [STAThread] static void Main(stri ...
  • 在WinForm中使用全局異常捕獲處理 在WinForm應用程式中,全局異常捕獲是確保程式穩定性的關鍵。通過在Program類的Main方法中設置全局異常處理,可以有效地捕獲並處理未預見的異常,從而避免程式崩潰。 註冊全局異常事件 [STAThread] static void Main() { / ...
  • 前言 給大家推薦一款開源的 Winform 控制項庫,可以幫助我們開發更加美觀、漂亮的 WinForm 界面。 項目介紹 SunnyUI.NET 是一個基於 .NET Framework 4.0+、.NET 6、.NET 7 和 .NET 8 的 WinForm 開源控制項庫,同時也提供了工具類庫、擴展 ...
  • 說明 該文章是屬於OverallAuth2.0系列文章,每周更新一篇該系列文章(從0到1完成系統開發)。 該系統文章,我會儘量說的非常詳細,做到不管新手、老手都能看懂。 說明:OverallAuth2.0 是一個簡單、易懂、功能強大的許可權+可視化流程管理系統。 有興趣的朋友,請關註我吧(*^▽^*) ...
  • 一、下載安裝 1.下載git 必須先下載並安裝git,再TortoiseGit下載安裝 git安裝參考教程:https://blog.csdn.net/mukes/article/details/115693833 2.TortoiseGit下載與安裝 TortoiseGit,Git客戶端,32/6 ...
  • 前言 在項目開發過程中,理解數據結構和演算法如同掌握蓋房子的秘訣。演算法不僅能幫助我們編寫高效、優質的代碼,還能解決項目中遇到的各種難題。 給大家推薦一個支持C#的開源免費、新手友好的數據結構與演算法入門教程:Hello演算法。 項目介紹 《Hello Algo》是一本開源免費、新手友好的數據結構與演算法入門 ...
  • 1.生成單個Proto.bat內容 @rem Copyright 2016, Google Inc. @rem All rights reserved. @rem @rem Redistribution and use in source and binary forms, with or with ...
  • 一:背景 1. 講故事 前段時間有位朋友找到我,說他的窗體程式在客戶這邊出現了卡死,讓我幫忙看下怎麼回事?dump也生成了,既然有dump了那就上 windbg 分析吧。 二:WinDbg 分析 1. 為什麼會卡死 窗體程式的卡死,入口門檻很低,後續往下分析就不一定了,不管怎麼說先用 !clrsta ...
  • 前言 人工智慧時代,人臉識別技術已成為安全驗證、身份識別和用戶交互的關鍵工具。 給大家推薦一款.NET 開源提供了強大的人臉識別 API,工具不僅易於集成,還具備高效處理能力。 本文將介紹一款如何利用這些API,為我們的項目添加智能識別的亮點。 項目介紹 GitHub 上擁有 1.2k 星標的 C# ...