一、概述
Hadoop集群中,有许多服务器部署着关键实例,如NameNode、ResourceManager、Zookeeper等,这些服务的稳定运行对集群健康具有重要意义。虽然这些服务基本上都会做多实例高可用部署,但是若连接的是同个交换机,万一交换机发生故障,则集群基本处于不可用状态。因此,对关键节点需要做交换机的高可用配置,即同一个服务器连接多台交换机以提高可用性。
二、操作步骤
1.启用双网卡配置
(1)关闭NetworkManager
[root@mycentos ~]# /etc/init.d/NetworkManager status
NetworkManager (pid 1520) 正在运行...
[root@mycentos ~]# /etc/init.d/NetworkManager stop
停止 NetworkManager 守护进程: [确定]
[root@mycentos ~]# /etc/init.d/NetworkManager status
NetworkManager 已停
[root@mycentos ~]# chkconfig NetworkManager off
[root@mycentos ~]# chkconfig --list | grep NetworkManager
NetworkManager 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
1
2
3
4
5
6
7
8
9
(2)配置网卡信息
[root@mycentos ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
NM_CONTROLLED=no
USERCTL=no
IPADDR=192.168.110.130
NETMASK=255.255.255.0
GATEWAY=192.168.110.3
[root@mycentos ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
ONBOOT=yes
USERCTL=no
[root@mycentos ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
ONBOOT=yes
USERCTL=no
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(3)修改modprobe相关设定文件
[root@mycentos ~]# lsmod | grep bonding
[root@mycentos ~]# cat /etc/modprobe.d/bonding.conf
alias bond0 bonding
options bonding mode=1 miimon=200
[root@mycentos ~]# cat /etc/rc.local
#!/bin/sh
touch /var/lock/subsys/local
ifenslave bond0 eth0 eth1
1
2
3
4
5
6
7
8
(4)加载模块并重启网络
如果是远程连接,必须以下两个命令一起执行。单独执行时,执行完 modprobe bonding后连接便会端口。
[root@mycentos ~]# modprobe bonding&&service network restart
1
(5)重启网络,确认是否生效
[root@mycentos ~]# ifconfig
bond0 Link encap:Ethernet HWaddr 00:0C:29:1C:A8:0B
inet addr:192.168.110.130 Bcast:192.168.110.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe1c:a80b/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:775 errors:0 dropped:0 overruns:0 frame:0
TX packets:97 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:47633 (46.5 KiB) TX bytes:8828 (8.6 KiB)
eth0 Link encap:Ethernet HWaddr 00:0C:29:1C:A8:0B
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:31951 errors:0 dropped:0 overruns:0 frame:0
TX packets:14381 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:26089260 (24.8 MiB) TX bytes:1030962 (1006.7 KiB)
eth1 Link encap:Ethernet HWaddr 00:0C:29:1C:A8:0B
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:44062 errors:0 dropped:0 overruns:0 frame:0
TX packets:1378 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2699466 (2.5 MiB) TX bytes:218716 (213.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:64 errors:0 dropped:0 overruns:0 frame:0
TX packets:64 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4128 (4.0 KiB) TX bytes:4128 (4.0 KiB)
[root@mycentos ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
link/ether 00:0c:29:1c:a8:0b brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000
link/ether 00:0c:29:1c:a8:0b brd ff:ff:ff:ff:ff:ff
4: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether 00:0c:29:1c:a8:0b brd ff:ff:ff:ff:ff:ff
inet 192.168.110.130/24 brd 192.168.111.255 scope global bond0
inet6 fe80::20c:29ff:fe1c:a80b/64 scope link
valid_lft forever preferred_lft forever
[root@mycentos ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.110.0 0.0.0.0 255.255.255.0 U 0 0 0 bond0
169.254.0.0 0.0.0.0 255.255.0.0 U 1004 0 0 bond0
0.0.0.0 192.168.110.3 0.0.0.0 UG 0 0 0 bond0
[root@mycentos ~]# lsmod | grep bonding
bonding 131724 0
[root@mycentos ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 200
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:1c:a8:0b
Slave queue ID: 0
Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:1c:a8:15
Slave queue ID: 0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
2.停用双网卡配置
如需恢复原先的单网卡配置,步骤如下
#去掉rc.local关于bond的配置
[root@mycentos ~]# vim /etc/rc.local
#删除bond相关配置文件
[root@mycentos ~]# rm -rf /etc/modprobe.d/bonding.conf
[root@mycentos ~]# rm -rf /etc/sysconfig/network-scripts/ifcfg-bond0
# 恢复网卡原先配置
[root@mycentos ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
[root@mycentos ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1
#删除bonding模块并重启网络
[root@mycentos ~]# rmmod bonding&&service network restart
---------------------
【转载】
作者:fish的饭票
原文:https://blog.csdn.net/lxbalex/article/details/83660409
|
|