作者:翻版的袁城 | 来源:互联网 | 2023-09-10 17:17
企业级大数据平台Ambari搭建与管理本节中我们将介绍Ambari集群的网络配置其中涉及到静态IP配置、XShell批量管理集群1、集群网络配置:主机HostnameIP子网掩码网
企业级大数据平台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 [root@localhost ~]# 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
重启网络服务: [root@localhost ~]# service network restart Restarting network (via systemctl): [ OK ]
测试与外网的连通情况: [root@localhost ~]# 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),我们需要安装一下网络工具。
[root@localhost ~]# 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是否与预计的一致。
[root@localhost ~]# ifconfig ens160: flags=4163 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 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 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 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
此步骤中所有操作都使用“发送键输入到所有回话功能”进行配置:
修改主机名 [root@localhost ~]# hostnamectl set-hostname hadoop01
重启所有节点: [root@localhost ~]# 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: [root@hadoop01 ~]# hostname hadoop01
到这里我们所有节点的hostname都配置完成。
5、关闭防火墙和SELinux
此步骤中所有操作都使用“发送键输入到所有回话功能”进行配置:
关闭防火墙服务、禁止防火墙开机自启: [root@hadoop01 ~]# systemctl stop firewalld [root@hadoop01 ~]# 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
[root@hadoop01 ~]# vi /etc/selinux/config
将 SELINUX=enforcing 改为 SELINUX=disabled
6、配置hosts
配置hosts文件: [root@hadoop01 ~]# 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
测试节点之间的通信: 这里只演示一个节点,这一步要保证所有节点之间的通信都是可以的。
[hadoop@hadoop01 /]$ 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
到这里,我们集群的网络配置就完成了。