二、Ambari叢集的網路配置
阿新 • • 發佈:2018-12-12
企業級大資料平臺Ambari搭建與管理
本節中我們將介紹Ambari叢集的網路配置
其中涉及到靜態IP配置、XShell批量管理叢集
1、叢集網路配置:
主機 | Hostname | IP | 子網掩碼 | 閘道器 | DNS |
---|---|---|---|---|---|
Hadoop01 | hadoop01 | 192.168.10.101 | 255.255.255.0 | 192.168.10.1 | 192.168.10.1 |
Hadoop02 | hadoop02 | 192.168.10.102 | 255.255.255.0 | 192.168.10.1 | 192.168.10.1 |
Hadoop03 | hadoop03 | 192.168.10.103 | 255.255.255.0 | 192.168.10.1 | 192.168.10.1 |
Hadoop04 | hadoop04 | 192.168.10.104 | 255.255.255.0 | 192.168.10.1 | 192.168.10.1 |
Hadoop05 | hadoop05 | 192.168.10.105 | 255.255.255.0 | 192.168.10.1 | 192.168.10.1 |
Hadoop06 | hadoop06 | 192.168.10.106 | 255.255.255.0 | 192.168.10.1 | 192.168.10.1 |
Hadoop07 | hadoop07 | 192.168.10.107 | 255.255.255.0 | 192.168.10.1 | 192.168.10.1 |
Hadoop08 | hadoop08 | 192.168.10.108 | 255.255.255.0 | 192.168.10.1 | 192.168.10.1 |
Hadoop09 | hadoop09 | 192.168.10.109 | 255.255.255.0 | 192.168.10.1 | 192.168.10.1 |
Hadoop10 | hadoop10 | 192.168.10.110 | 255.255.255.0 | 192.168.10.1 | 192.168.10.1 |
2、靜態IP配置
在vSphere上本地登入到Hadoop01伺服器上:
配置靜態IP
[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens160
將 BOOTPROTO=dhcp 改為 BOOTPROTO=static
將 ONBOOT=no 改為 ONBOOT=yes
在末尾新增如下內容:
IPADDR=192.168.10.101
NETMASK=255.255.255.0
GATEWAY=192.168.10.1
DNS1=192.168.10.1
重啟網路服務:
[[email protected] ~]# service network restart
Restarting network (via systemctl): [ OK ]
測試與外網的連通情況:
[[email protected] ~]# ping baidu.com -c 4
PING baidu.com (123.125.115.110) 56(84) bytes of data.
64 bytes from 123.125.115.110 (123.125.115.110): icmp_seq=1 ttl=128 time=38.0 ms
64 bytes from 123.125.115.110 (123.125.115.110): icmp_seq=2 ttl=128 time=37.0 ms
64 bytes from 123.125.115.110 (123.125.115.110): icmp_seq=3 ttl=128 time=48.7 ms
64 bytes from 123.125.115.110 (123.125.115.110): icmp_seq=4 ttl=128 time=42.4 ms
--- baidu.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 37.020/41.561/48.718/4.600 ms
安裝網路工具
由於我們是Minimal安裝的,所以沒有網路工具(比如ifconfig),我們需要安裝一下網路工具。
[[email protected] ~]# yum install -y net-tools
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.22.20131004git.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================
Installing:
net-tools x86_64 2.0-0.22.20131004git.el7 base 305 k
Transaction Summary
==================================================================================================================================================================================
Install 1 Package
Total download size: 305 k
Installed size: 917 k
Downloading packages:
net-tools-2.0-0.22.20131004git.el7.x86_64.rpm | 305 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : net-tools-2.0-0.22.20131004git.el7.x86_64 1/1
Verifying : net-tools-2.0-0.22.20131004git.el7.x86_64 1/1
Installed:
net-tools.x86_64 0:2.0-0.22.20131004git.el7
Complete!
檢查一下本機的IP情況:
檢查本機IP是否與預計的一致。
[[email protected] ~]# ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.10.101 netmask 255.255.255.0 broadcast 192.168.10.255
inet6 fe80::16a9:f517:a5d9:78ac prefixlen 64 scopeid 0x20<link>
ether 00:50:56:ac:63:f4 txqueuelen 1000 (Ethernet)
RX packets 6883099 bytes 9778926079 (9.1 GiB)
RX errors 0 dropped 338 overruns 0 frame 0
TX packets 2929337 bytes 396757749 (378.3 MiB)
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 32 bytes 2592 (2.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 32 bytes 2592 (2.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
到這裡Hadoop01這臺伺服器的靜態IP就配置好了。 將其他9臺伺服器也安裝以上方法進行修改,注意對應的IP地址。
3、使用XShell批量遠端連線CentOS 7 伺服器
使用XShell批量連線到我們的伺服器上,實現簡單、方便、統一的配置後面所需要的服務。 我們連線上10臺伺服器:
我們使用“傳送鍵輸入到所有回話功能”,實現所有節點統一進行配置。
4、修改hostname
此步驟中所有操作都使用“傳送鍵輸入到所有回話功能”進行配置:
修改主機名
[[email protected] ~]# hostnamectl set-hostname hadoop01
重啟所有節點:
[[email protected] ~]# reboot
Connection closing...Socket close.
Connection closed by foreign host.
Disconnected from remote host(Hadoop01-1) at 12:38:08.
Type `help' to learn how to use Xshell prompt.
[C:\~]$
重啟後檢查所有節點的hostname:
[[email protected] ~]# hostname
hadoop01
到這裡我們所有節點的hostname都配置完成。
5、關閉防火牆和SELinux
此步驟中所有操作都使用“傳送鍵輸入到所有回話功能”進行配置:
關閉防火牆服務、禁止防火牆開機自啟:
[[email protected] ~]# systemctl stop firewalld
[[email protected] ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
關閉SELinux
vi /etc/selinux/config
SELINUX=enforcing
SELINUX=disable
[[email protected] ~]# vi /etc/selinux/config
將 SELINUX=enforcing 改為 SELINUX=disabled
6、配置hosts
配置hosts檔案:
[[email protected] ~]# vi /etc/hosts
新增如下內容:
192.168.10.101 hadoop01
192.168.10.102 hadoop02
192.168.10.103 hadoop03
192.168.10.104 hadoop04
192.168.10.105 hadoop05
192.168.10.106 hadoop06
192.168.10.107 hadoop07
192.168.10.108 hadoop08
192.168.10.109 hadoop09
192.168.10.110 hadoop10
測試節點之間的通訊:
這裡只演示一個節點,這一步要保證所有節點之間的通訊都是可以的。
[[email protected] /]$ ping hadoop02 -c 4
PING hadoop02 (192.168.10.102) 56(84) bytes of data.
64 bytes from hadoop02 (192.168.10.102): icmp_seq=1 ttl=64 time=0.433 ms
64 bytes from hadoop02 (192.168.10.102): icmp_seq=2 ttl=64 time=0.331 ms
64 bytes from hadoop02 (192.168.10.102): icmp_seq=3 ttl=64 time=0.298 ms
64 bytes from hadoop02 (192.168.10.102): icmp_seq=4 ttl=64 time=0.327 ms
--- hadoop02 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3000ms
rtt min/avg/max/mdev = 0.298/0.347/0.433/0.052 ms
到這裡,我們叢集的網路配置就完成了。