Linux学习-集群
Posted 丢爸
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux学习-集群相关的知识,希望对你有一定的参考价值。
DR模型
内核参数:
arp_ignore:定义接收到ARP请求时的响应级别
0(默认级别):只要本地配置的有相应地址,就予以响应
1:仅在请求的目标地址配置请求到达的接口上的时候,才给予响应
2:
3:
arp_announce:定义将自己地址向外通告时的通告级别
0(默认级别):将本地任何接口上的任何地址向外通告
1:试图仅向目标网络通告与其网络匹配的地址
2:仅将与本地接口匹配的网络进行通告
DR模型配置
使用虚拟机进行模拟实现,三台虚拟机网络配置都使用桥接模式,三台虚拟机的简单规划如下图
客户请求通过路由设备发送至内网交换机,由交换机将请求发送至Director,Director收到请求后,根据算法决定将请求发送至指定的RS,指定RS收到请求后,对请求进行响应,并直接将响应结果回送至Client。
#将Director的VIP以eth0的别名形式进行添加
[root@mail ~]# ifconfig eth0:0 192.168.0.100/24
[root@mail ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:78:18:40
inet addr:192.168.0.103 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe78:1840/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1015 errors:0 dropped:0 overruns:0 frame:0
TX packets:272 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:82164 (80.2 KiB) TX bytes:32897 (32.1 KiB)
eth0:0 Link encap:Ethernet HWaddr 00:0C:29:78:18:40
inet addr:192.168.0.100 Bcast:192.168.0.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:65536 Metric:1
RX packets:2 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:200 (200.0 b) TX bytes:200 (200.0 b)
[root@mail ~]# route add -host 192.168.0.100 dev eth0:0
#RS1的配置
[root@lotus ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:38:28:64
inet addr:192.168.0.109 Bcast:192.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::20c:29ff:fe38:2864/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:472 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:36486 (35.6 KiB) TX bytes:7037 (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:65536 Metric:1
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:700 (700.0 b) TX bytes:700 (700.0 b)
#设定RS1的网络配置参数
[root@lotus ~]# cd /proc/sys/net/ipv4/conf/
[root@lotus conf]# ls
all default eth0 lo
[root@lotus conf]# ls all
accept_local arp_accept arp_ignore disable_policy forwarding medium_id proxy_arp_pvlan secure_redirects src_valid_mark
accept_redirects arp_announce arp_notify disable_xfrm log_martians promote_secondaries route_localnet send_redirects tag
accept_source_route arp_filter bootp_relay force_igmp_version mc_forwarding proxy_arp rp_filter shared_media
[root@lotus conf]# ls eth0
accept_local arp_accept arp_ignore disable_policy forwarding medium_id proxy_arp_pvlan secure_redirects src_valid_mark
accept_redirects arp_announce arp_notify disable_xfrm log_martians promote_secondaries route_localnet send_redirects tag
accept_source_route arp_filter bootp_relay force_igmp_version mc_forwarding proxy_arp rp_filter shared_media
[root@lotus conf]# ls lo
accept_local arp_accept arp_ignore disable_policy forwarding medium_id proxy_arp_pvlan secure_redirects src_valid_mark
accept_redirects arp_announce arp_notify disable_xfrm log_martians promote_secondaries route_localnet send_redirects tag
accept_source_route arp_filter bootp_relay force_igmp_version mc_forwarding proxy_arp rp_filter shared_media
[root@lotus conf]# sysctl -w net.ipv4.conf.eth0.arp_announce=2
net.ipv4.conf.eth0.arp_announce = 2
[root@lotus conf]# sysctl -w net.ipv4.conf.all.arp_announce=2
net.ipv4.conf.all.arp_announce = 2
[root@lotus conf]# echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore
[root@lotus conf]# echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
[root@lotus conf]# cat /proc/sys/net/ipv4/conf/all/arp_ignore
1
#配置RS1的VIP
[root@lotus ~]# ifconfig lo:0 192.168.0.100/24 broadcast 192.168.0.100 netmask 255.255.255.255 up
#配置路由,由VIP响应的请求通过lo:0出去
[root@lotus ~]# route add -host 192.168.0.100 dev lo:0
#RS2的配置同RS1
[root@lotus ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:D3:6A:50
inet addr:192.168.0.110 Bcast:192.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::20c:29ff:fed3:6a50/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:644 errors:0 dropped:0 overruns:0 frame:0
TX packets:89 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:52928 (51.6 KiB) TX bytes:8715 (8.5 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:65536 Metric:1
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:700 (700.0 b) TX bytes:700 (700.0 b)
[root@lotus ~]# echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
[root@lotus ~]# echo 2 > /proc/sys/net/ipv4/conf/eth0/arp_announce
[root@lotus ~]# echo 1 > /proc/sys/net/ipv4/conf/eth0/arp_ignore
[root@lotus ~]# echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
[root@lotus ~]# ifconfig lo:0 192.168.0.100/24 broadcast 192.168.0.100 netmask 255.255.255.255 up
[root@lotus ~]# route add -host 192.168.0.100 dev lo:0
#对VIP连接进行测试
#删除arp解析记录
C:\\Windows\\system32>arp -d *
#显示解析记录
C:\\Windows\\system32>arp -a
接口: 192.168.88.1 --- 0xa
Internet 地址 物理地址 类型
224.0.0.22 01-00-5e-00-00-16 静态
239.255.255.250 01-00-5e-7f-ff-fa 静态
接口: 192.168.0.105 --- 0xe
Internet 地址 物理地址 类型
192.168.0.1 48-0e-ec-69-7c-b8 动态
224.0.0.22 01-00-5e-00-00-16 静态
226.174.214.27 01-00-5e-2e-d6-1b 静态
236.195.203.182 01-00-5e-43-cb-b6 静态
237.128.203.115 01-00-5e-00-cb-73 静态
239.255.255.250 01-00-5e-7f-ff-fa 静态
接口: 192.168.241.1 --- 0x11
Internet 地址 物理地址 类型
224.0.0.22 01-00-5e-00-00-16 静态
239.255.255.250 01-00-5e-7f-ff-fa 静态
C:\\Windows\\system32>ping 192.168.0.100
正在 Ping 192.168.0.100 具有 32 字节的数据:
来自 192.168.0.100 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.0.100 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.0.100 的回复: 字节=32 时间<1ms TTL=64
192.168.0.100 的 Ping 统计信息:
数据包: 已发送 = 3,已接收 = 3,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 0ms,最长 = 0ms,平均 = 0ms
Control-C
^C
C:\\Windows\\system32>arp -a
接口: 192.168.88.1 --- 0xa
Internet 地址 物理地址 类型
224.0.0.22 01-00-5e-00-00-16 静态
226.174.214.27 01-00-5e-2e-d6-1b 静态
237.128.203.115 01-00-5e-00-cb-73 静态
239.255.255.250 01-00-5e-7f-ff-fa 静态
接口: 192.168.0.105 --- 0xe
Internet 地址 物理地址 类型
192.168.0.1 48-0e-ec-69-7c-b8 动态
**192.168.0.100 00-0c-29-78-18-40 动态**
224.0.0.22 01-00-5e-00-00-16 静态
226.174.214.27 01-00-5e-2e-d6-1b 静态
236.195.203.182 01-00-5e-43-cb-b6 静态
237.128.203.115 01-00-5e-00-cb-73 静态
239.255.255.250 01-00-5e-7f-ff-fa 静态
接口: 192.168.241.1 --- 0x11
Internet 地址 物理地址 类型
224.0.0.22 01-00-5e-00-00-16 静态
226.174.214.27 01-00-5e-2e-d6-1b 静态
237.128.203.115 01-00-5e-00-cb-73 静态
239.255.255.250 01-00-5e-7f-ff-fa 静态
#arp解析出来的VIP的MAC地址为Director的MAC地址
#测试一下Director到RS1和RS2的连接
[root@mail ~]# curl http://192.168.0.109
RS1.lotus.com
[root@mail ~]# curl http://192.168.0.110
RS2.lotus.com
#配置Director的ipvsadm规则
[root@mail ~]# ipvsadm -C
[root@mail ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
[root@mail ~]# ipvsadm -A -t 192.168.0.100:80 -s wlc
[root@mail ~]# ipvsadm -a -t 192.168.0.100:80 -r 192.168.0.109:80 -g -w 2
[root@mail ~]# ipvsadm -a -t 192.168.0.100:80 -r 192.168.0.110:80 -g -w 1
[root@mail ~]# 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.0.100:80 wlc
-> 192.168.0.109:80 Route 2 0 0
-> 192.168.0.110:80 Route 1 0 0
以上是关于Linux学习-集群的主要内容,如果未能解决你的问题,请参考以下文章
零基础学习云计算及大数据DBA集群架构师Linux Bash Shell编程及系统自动化2015年1月13日周三