Hadoop3.3.0完全分布式安装
前言
此次运用的操作系统是Linux CentOS 8系统
本次安装用到的四台虚拟机如下
NameNode | Secondary NameNode | DataNode | |
---|---|---|---|
Master | Yes | ||
Slave1 | Yes | Yes | |
Slave2 | Yes | ||
Slave3 | Yes |
Linux的相关配置
1、设置ip地址
每台虚拟机 更改ip地址
vi /etc/sysconfig/network-scripts/ifcfg-eth33
BOOTPROTO要设置成static,ONBOOT要设置成yes,然后在文件末尾加上虚拟机相应的ip地址,网关,子网掩码和dns
2、关闭防火墙
每台虚拟机
#关闭防火墙
systemctl stop firewalld
#禁止开机启用防火墙
systemctl disable firewalld
每台虚拟机 关闭selinux
vi /etc/selinux/config
3、设置ip映射
每台虚拟机 设置ip映射
vi /etc/hosts
4、设置免密登录
在四台机器执行以下命令,生成公钥与私钥
ssh-keygen -t rsa
执行该命令之后,按下三个回车即可
四台机器将拷贝公钥到第一台机器
四台机器执行命令
ssh-copy-id Master
将第一台机器的公钥拷贝到其他机器上
在第一台机器上面指向以下命令
scp /root/.ssh/authorized_keys Slave1:/root/.ssh
scp /root/.ssh/authorized_keys Slave2:/root/.ssh
scp /root/.ssh/authorized_keys Slave3:/root/.ssh
安装jdk
1、下载安装包
下载地址:https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
2、解压
下载好之后上传到服务器,我这里上传到/root/java目录中,然后解压:
tar zxv -f /root/java/jdk-8u281-linux-x64.tar.gz
安装hadoop
1、下载安装包
下载地址:https://downloads.apache.org/hadoop/common/stable/hadoop-3.3.0.tar.gz
2、解压
下载好之后上传到服务器,我这里上传到/root/hadoop目录中,然后解压:
tar zxv -f /root/hadoop/hadoop-3.3.0.tar.gz
3、修改配置文件 (在Master上操作)
(注:hadoop3端口相比hadoop2已经更改,详情可见官网:https://hadoop.apache.org/docs/r3.3.0/
3.1、修改core-site.xml文件
vi /root/hadoop/etc/hadoop/core-site.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. See accompanying LICENSE file.
-->
<!-- Put site-specific property overrides in this file. -->
<configuration>
<!-- 指定集群的文件系统类型:分布式文件系统 -->
<property>