码迷,mamicode.com
首页 > 其他好文 > 详细

012-大数据-高并发LVS2实验

时间:2020-07-12 22:44:57      阅读:82      评论:0      收藏:0      [点我收藏+]

标签:_for   netmask   source   ddr   flag   netstat   list   rem   配置   

高并发负载均衡实验

描述

node1

[root@MDNode01 ~]# ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:0C:29:BF:3A:BE  
          inet addr:192.168.25.50  Bcast:192.168.25.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:febf:3abe/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:135 errors:0 dropped:0 overruns:0 frame:0
          TX packets:62 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:11852 (11.5 KiB)  TX bytes:7444 (7.2 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
[root@MDNode01 ~]# 

node2

[root@MDNode02 ~]# ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:0C:29:A6:A5:1F  
          inet addr:192.168.25.51  Bcast:192.168.25.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fea6:a51f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:143 errors:0 dropped:0 overruns:0 frame:0
          TX packets:60 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:12448 (12.1 KiB)  TX bytes:7524 (7.3 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

node3

[root@MDNode03 ~]# ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:0C:29:BA:98:84  
          inet addr:192.168.25.52  Bcast:192.168.25.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:feba:9884/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:138 errors:0 dropped:0 overruns:0 frame:0
          TX packets:57 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:12148 (11.8 KiB)  TX bytes:7058 (6.8 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

[root@MDNode03 ~]# 

node4

[root@MDNode04 ~]# ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:0C:29:C8:97:80  
          inet addr:192.168.25.53  Bcast:192.168.25.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fec8:9780/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:118 errors:0 dropped:0 overruns:0 frame:0
          TX packets:51 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:10484 (10.2 KiB)  TX bytes:6270 (6.1 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

[root@MDNode04 ~]# 

配置node1为lvs服务器

配置一个VIP的网络模式

[root@MDNode01 ~]# ifconfig eth0:2 192.168.25.100/24
[root@MDNode01 ~]# ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:0C:29:BF:3A:BE  
          inet addr:192.168.25.50  Bcast:192.168.25.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:febf:3abe/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:357 errors:0 dropped:0 overruns:0 frame:0
          TX packets:147 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:29228 (28.5 KiB)  TX bytes:17202 (16.7 KiB)

eth0:2    Link encap:Ethernet  HWaddr 00:0C:29:BF:3A:BE  
          inet addr:192.168.25.100  Bcast:192.168.25.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
[root@MDNode01 ~]# cat /proc/sys/net/ipv4/ip_forward 
0
[root@MDNode01 ~]# echo 1 > /proc/sys/net/ipv4/ip_forward 
[root@MDNode01 ~]# cat /proc/sys/net/ipv4/ip_forward 
1

配置三台SR服务器

[root@MDNode03 ~]# echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore 
[root@MDNode03 ~]# echo 2 > /proc/sys/net/ipv4/conf/eth0/arp_announce 
[root@MDNode03 ~]# cat /proc/sys/net/ipv4/conf/eth0/arp_ignore 
1
[root@MDNode03 ~]# cat /proc/sys/net/ipv4/conf/eth0/arp_announce 
2
[root@MDNode03 ~]# echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore 
[root@MDNode03 ~]# echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce 
[root@MDNode03 ~]# cat /proc/sys/net/ipv4/conf/all/arp_announce 
2
[root@MDNode03 ~]# cat /proc/sys/net/ipv4/conf/all/arp_ignore 
1
[root@MDNode03 ~]# ifconfig lo:2 192.168.25.100 netmask 255.255.255.255
[root@MDNode03 ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:BA:98:84  
          inet addr:192.168.25.52  Bcast:192.168.25.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:feba:9884/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1530 errors:0 dropped:0 overruns:0 frame:0
          TX packets:731 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:132474 (129.3 KiB)  TX bytes:85442 (83.4 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

lo:2      Link encap:Local Loopback  
          inet addr:192.168.25.100  Mask:255.255.255.255
          UP LOOPBACK RUNNING  MTU:16436  Metric:1

[root@MDNode03 ~]# yum install httpd -y

配置服务器httpd服务

[root@MDNode03 ~]# vi /var/www/html/index.html
[root@MDNode03 ~]# cat /var/www/html/index.html
<h1>192.168.25.52</h1>
[root@MDNode03 ~]# service httpd start
Starting httpd: httpd: Could not reliably determine the server‘s fully qualif, using 192.168.25.52 for ServerName
                                                           [  OK  ]

返回LVS服务器中配置

安装:

[root@MDNode01 ~]# yum install ipvsadm -y

配置:

[root@MDNode01 ~]# ipvsadm -A -t 192.168.25.100:80 -s rr
[root@MDNode01 ~]# 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.25.100:80 rr
[root@MDNode01 ~]# ipvsadm -a -t 192.168.25.100:80 -r 192.168.25.51 -g
[root@MDNode01 ~]# ipvsadm -a -t 192.168.25.100:80 -r 192.168.25.52 -g
[root@MDNode01 ~]# ipvsadm -a -t 192.168.25.100:80 -r 192.168.25.53 -g
[root@MDNode01 ~]# 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.25.100:80 rr
  -> 192.168.25.51:80             Route   1      0          0         
  -> 192.168.25.52:80             Route   1      0          0         
  -> 192.168.25.53:80             Route   1      0          0         

查询日志:

ipvsadm -lnc

[root@MDNode01 ~]# ipvsadm -lnc
IPVS connection entries
pro expire state       source             virtual            destination
TCP 00:56  FIN_WAIT    192.168.25.54:34940 192.168.25.100:80  192.168.25.51:80
TCP 01:57  FIN_WAIT    192.168.25.1:11969 192.168.25.100:80  192.168.25.53:80
TCP 14:58  ESTABLISHED 192.168.25.1:11970 192.168.25.100:80  192.168.25.52:80
TCP 00:50  FIN_WAIT    192.168.25.54:34938 192.168.25.100:80  192.168.25.53:80
TCP 00:47  FIN_WAIT    192.168.25.54:34937 192.168.25.100:80  192.168.25.51:80
TCP 01:56  FIN_WAIT    192.168.25.1:11966 192.168.25.100:80  192.168.25.53:80
TCP 00:53  FIN_WAIT    192.168.25.54:34939 192.168.25.100:80  192.168.25.52:80
TCP 01:56  FIN_WAIT    192.168.25.1:11967 192.168.25.100:80  192.168.25.52:80
TCP 01:56  FIN_WAIT    192.168.25.1:11968 192.168.25.100:80  192.168.25.51:80

netstat -natp

[root@MDNode01 ~]# netstat -natp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN       
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN       
tcp        0     64 192.168.25.50:22            192.168.25.1:10753          ESTABLISHE   
tcp        0      0 :::22                       :::*                        LISTEN       
tcp        0      0 ::1:25                      :::*                        LISTEN   

其他的RS

[root@MDNode03 ~]# netstat -natp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             Sogram name   
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   Lhd            
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   Laster         
tcp        0     64 192.168.25.52:22            192.168.25.1:10757          Eshd           
tcp        0      0 :::80                       :::*                        Lttpd          
tcp        0      0 :::22                       :::*                        Lhd            
tcp        0      0 ::1:25                      :::*                        Laster         
tcp        0      0 ::ffff:192.168.25.100:80    ::ffff:192.168.25.1:12791   T              
tcp        0      0 ::ffff:192.168.25.100:80    ::ffff:192.168.25.1:12803   T              
tcp        0      0 ::ffff:192.168.25.100:80    ::ffff:192.168.25.1:12800   T              
tcp        0      0 ::ffff:192.168.25.100:80    ::ffff:192.168.25.1:12794   T              
tcp        0      0 ::ffff:192.168.25.100:80    ::ffff:192.168.25.1:12806   T              
tcp        0      0 ::ffff:192.168.25.100:80    ::ffff:192.168.25.1:12797   T              
tcp        0      0 ::ffff:192.168.25.100:80    ::ffff:192.168.25.1:12809   T

问题:

1、单点servce其中有一台挂机???

主备解决单点故障问题

高可用的提出>>

选择备用的选择???

? 备机加权

主机和备机之间的通讯???

? 主机广播的方式,备机分析

主机广播主机的运行状态,备机分析,主机挂机后,备机权值推荐。

012-大数据-高并发LVS2实验

标签:_for   netmask   source   ddr   flag   netstat   list   rem   配置   

原文地址:https://www.cnblogs.com/shaoyayu/p/13290114.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!