1. 硬件环境
主机名 | IP地址 | 操作系统 |
---|---|---|
master | 172.16.34.101 | CentOS Linux release 7.3.1611 |
slave01 | 172.16.34.102 | CentOS Linux release 7.3.1611 |
slave03 | 172.16.34.103 | CentOS Linux release 7.3.1611 |
2. 软件版本
软件名称 | 版本 |
---|---|
hadoop | 2.7.7 |
hive | 1.2.2 |
spark | 2.3.4 |
zookeeper | 3.4.9 |
hbase | 1.3.6 |
jdk | 1.8+ |
注解
- Hadoop:Hadoop是由java语言编写的,在分布式服务器集群上存储海量数据并运行分布式分析应用的开源框架,其核心部件是HDFS与MapReduce。HDFS为海量的数据提供了存储,则MapReduce为海量的数据提供了计算。
- HDFS:hadoop的分布式文件系统,引入存放文件元数据信息的服务器Namenode和实际存放数据的服务器Datanode,对数据进行分布式储存和读取。可以把HDFS理解为一个分布式的,有冗余备份的,可以动态扩展的用来存储大规模数据的大硬盘。
- MapReduce:是一个计算框架,MapReduce的核心思想是把计算任务分配给集群内的服务器里执行。通过对计算任务的拆分(Map计算/Reduce计算)再根据任务调度器(JobTracker)对任务进行分布式计算。可以把MapReduce理解成为一个计算引擎,按照MapReduce的规则编写Map计算/Reduce计算的程序,可以完成计算任务。
- Hbase:是一种由java语言编写的高可靠、高性能、面向列、可伸缩的分布式存储的nosql数据库,运行于HDFS文件系统之上,可以容错地存储海量非结构化和半结构化的松散数据。
- Hive:基于hadoop的数据仓库工具,可以将结构化的数据文件(或者非结构化的数据)映射为一张数据库表,并提供简单的sql查询功能,可以将sql语句转换为MapReduce任务进行运行。其优点是学习成本低,可以通过类SQL语句快速实现简单的MapReduce统计,不必开发专门的MapReduce应用,十分适合数据仓库的统计分析。
- Spark:Spark 是使用scala实现的基于内存计算的大数据并行计算框架,可用于构建大型的、低延迟的数据分析应用程序。Spark的计算模式也属于MapReduce,但不局限于Map和Reduce操作,还提供了多种数据集操作类型,编程模型比MapReduce更灵活,Spark将计算数据、中间结果都存储在内存中,大大减少了IO开销,Spark并不能完全替代Hadoop,主要用于替代Hadoop中的MapReduce计算模型,它可以借助于hadoop yarn实现资源调度管理,借助于HDFS实现分布式存储。
3. 所有节点上关闭防火墙
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
systemctl stop firewalld
systemctl disable firewalld
4. 所有节点配置NTP时钟同步
略
5. 所有节点上添加hosts
cat >>/etc/hosts <<EOF
172.16.34.101 master
172.16.34.102 slave01
172.16.34.103 slave02
EOF
6. 所有节点上面创建hadoop用户
groupadd hadoop
useradd -m -g hadoop hadoop
# 给hadoop用户设置密码为“hadoop”
echo "hadoop" |passwd --stdin hadoop
7. 在所有节点上安装jdk
7.1 在Oracle官网下载linux64位的jdk:https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
7.2 使用root用户安装jdk
mkdir -p /usr/java
tar -zxf jdk-8u191-linux-x64.tar.gz -C /usr/java
注意:如无特殊说明,以下操作在master节点的hadoop用户下进行
8. 设置master节点到slave节点的免密登录
# 切换到hadoop用户
[root@master ~]# su - hadoop
Last login: Thu Apr 16 17:12:59 CST 2020 on pts/1
# 生成公私钥对
[hadoop@master ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/hadoop/.ssh/id_rsa):
Created directory '/home/hadoop/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/hadoop/.ssh/id_rsa.
Your public key has been saved in /home/hadoop/.ssh/id_rsa.pub.
The key fingerprint is:
2b:70:a0:b3:9a:3a:60:98:4d:a9:a1:67:a3:12:61:2e hadoop@master
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| .. |
|o.o. . |
|=Bo . . S |
|Eo=o o . |
|+=.. . . |
|+o . |
|*. |
+-----------------+
# 将公钥发送到各节点(包括master自己)
[hadoop@master ~]$ ssh-copy-id master
The authenticity of host 'master (172.16.34.101)' can't be established.
ECDSA key fingerprint is 19:d0:5f:f0:7e:bd:96:0d:3b:5c:f7:c5:3d:fb:61:d5.
Are you sure you want to continue connecting (yes/no)? yes
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be i