從零搭建生產Hadoop叢集(七)——關鍵伺服器雙網絡卡配置
阿新 • • 發佈:2018-12-19
一、概述
Hadoop叢集中,有許多伺服器部署著關鍵例項,如NameNode、ResourceManager、Zookeeper等,這些服務的穩定執行對叢集健康具有重要意義。雖然這些服務基本上都會做多例項高可用部署,但是若連線的是同個交換機,萬一交換機發生故障,則叢集基本處於不可用狀態。因此,對關鍵節點需要做交換機的高可用配置,即同一個伺服器連線多臺交換機以提高可用性。
二、操作步驟
1.啟用雙網絡卡配置
(1)關閉NetworkManager
[[email protected] ~]# /etc/init.d/NetworkManager status NetworkManager (pid 1520) 正在執行... [
[email protected] ~]# /etc/init.d/NetworkManager stop 停止 NetworkManager 守護程序: [確定] [[email protected] ~]# /etc/init.d/NetworkManager status NetworkManager 已停 [[email protected] ~]# chkconfig NetworkManager off [[email protected] ~]# chkconfig --list | grep NetworkManager NetworkManager 0:關閉 1:關閉 2:關閉 3:關閉 4:關閉 5:關閉 6:關閉
(2)配置網絡卡資訊
[[email protected] ~]# 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
[[email protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
ONBOOT=yes
USERCTL=no
[ [email protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
ONBOOT=yes
USERCTL=no
(3)修改modprobe相關設定檔案
[[email protected] ~]# lsmod | grep bonding
[[email protected] ~]# cat /etc/modprobe.d/bonding.conf
alias bond0 bonding
options bonding mode=1 miimon=200
[[email protected] ~]# cat /etc/rc.local
#!/bin/sh
touch /var/lock/subsys/local
ifenslave bond0 eth0 eth1
(4)載入模組並重啟網路
如果是遠端連線,必須以下兩個命令一起執行。單獨執行時,執行完 modprobe bonding後連線便會埠。
[[email protected] ~]# modprobe bonding&&service network restart
(5)重啟網路,確認是否生效
[[email protected] ~]# 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)
[[email protected] ~]# 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
[[email protected] ~]# 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
[[email protected] ~]# lsmod | grep bonding
bonding 131724 0
[[email protected] ~]# 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
2.停用雙網絡卡配置
如需恢復原先的單網絡卡配置,步驟如下
#去掉rc.local關於bond的配置
[[email protected] ~]# vim /etc/rc.local
#刪除bond相關配置檔案
[[email protected] ~]# rm -rf /etc/modprobe.d/bonding.conf
[[email protected] ~]# rm -rf /etc/sysconfig/network-scripts/ifcfg-bond0
# 恢復網絡卡原先配置
[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1
#刪除bonding模組並重啟網路
[[email protected] ~]# rmmod bonding&&service network restart