modify
This commit is contained in:
parent
30d73a6751
commit
7a6e1de845
25
README.md
25
README.md
@ -52,9 +52,10 @@
|
||||
1. [分布式文件存储系统——HDFS](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Hadoop-HDFS.md)
|
||||
2. [分布式计算框架——MapReduce](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Hadoop-MapReduce.md)
|
||||
3. [集群资源管理器——YARN](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Hadoop-YARN.md)
|
||||
4. [Hadoop单机伪集群环境搭建](https://github.com/heibaiying/BigData-Notes/blob/master/notes/installation/hadoop单机版本环境搭建.md)
|
||||
5. [HDFS常用Shell命令](https://github.com/heibaiying/BigData-Notes/blob/master/notes/HDFS常用Shell命令.md)
|
||||
6. [HDFS Java API的使用](https://github.com/heibaiying/BigData-Notes/blob/master/notes/HDFS-Java-API.md)
|
||||
4. [Hadoop单机伪集群环境搭建](https://github.com/heibaiying/BigData-Notes/blob/master/notes/installation/Hadoop单机环境搭建.md)
|
||||
5. [Hadoop集群环境搭建](https://github.com/heibaiying/BigData-Notes/blob/master/notes/installation/Hadoop集群环境搭建.md)
|
||||
6. [HDFS常用Shell命令](https://github.com/heibaiying/BigData-Notes/blob/master/notes/HDFS常用Shell命令.md)
|
||||
7. [HDFS Java API的使用](https://github.com/heibaiying/BigData-Notes/blob/master/notes/HDFS-Java-API.md)
|
||||
|
||||
## 二、Hive
|
||||
|
||||
@ -77,6 +78,7 @@
|
||||
5. [RDD常用算子详解](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Spark_Transformation和Action算子.md)
|
||||
5. [Spark运行模式与作业提交](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Spark部署模式与作业提交.md)
|
||||
6. [Spark累加器与广播变量](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Spark累加器与广播变量.md)
|
||||
7. [基于Zookeeper搭建Spark高可用集群](https://github.com/heibaiying/BigData-Notes/blob/master/notes/installation/Spark集群环境搭建.md)
|
||||
|
||||
**Spark SQL :**
|
||||
|
||||
@ -113,14 +115,15 @@ TODO
|
||||
|
||||
1. [Hbase 简介](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Hbase简介.md)
|
||||
2. [HBase系统架构及数据结构](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Hbase系统架构及数据结构.md)
|
||||
3. [HBase基本环境搭建(Standalone /pseudo-distributed mode)](https://github.com/heibaiying/BigData-Notes/blob/master/notes/installation/Hbase基本环境搭建.md)
|
||||
4. [HBase常用Shell命令](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Hbase_Shell.md)
|
||||
5. [HBase Java API](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Hbase_Java_API.md)
|
||||
6. [Hbase 过滤器详解](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Hbase过滤器详解.md)
|
||||
7. [HBase 协处理器详解](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Hbase协处理器详解.md)
|
||||
8. [HBase 容灾与备份](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Hbase容灾与备份.md)
|
||||
9. [HBase的SQL中间层——Phoenix](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Hbase的SQL中间层_Phoenix.md)
|
||||
10. [Spring/Spring Boot 整合 Mybatis + Phoenix](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Spring+Mybtais+Phoenix整合.md)
|
||||
3. [HBase基本环境搭建(Standalone /pseudo-distributed mode)](https://github.com/heibaiying/BigData-Notes/blob/master/notes/installation/HBase基本环境搭建.md)
|
||||
4. [HBase集群环境搭建](https://github.com/heibaiying/BigData-Notes/blob/master/notes/installation/HBase集群环境搭建.md)
|
||||
5. [HBase常用Shell命令](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Hbase_Shell.md)
|
||||
6. [HBase Java API](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Hbase_Java_API.md)
|
||||
7. [Hbase 过滤器详解](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Hbase过滤器详解.md)
|
||||
8. [HBase 协处理器详解](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Hbase协处理器详解.md)
|
||||
9. [HBase 容灾与备份](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Hbase容灾与备份.md)
|
||||
10. [HBase的SQL中间层——Phoenix](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Hbase的SQL中间层_Phoenix.md)
|
||||
11. [Spring/Spring Boot 整合 Mybatis + Phoenix](https://github.com/heibaiying/BigData-Notes/blob/master/notes/Spring+Mybtais+Phoenix整合.md)
|
||||
|
||||
## 七、Kafka
|
||||
|
||||
|
183
notes/installation/HBase集群环境搭建.md
Normal file
183
notes/installation/HBase集群环境搭建.md
Normal file
@ -0,0 +1,183 @@
|
||||
# HBase集群环境配置
|
||||
|
||||
## 一、集群规划
|
||||
|
||||
这里搭建一个3节点的HBase集群,其中三台主机上均为`Regin Server`。同时为了保证高可用,除了在hadoop001上部署主`Master`服务外,还在hadoop002上署备用的`Master`服务,Master服务由Zookeeper集群进行协调管理,如果主`Master`不可用,则备用`Master`会成为新的主`Master`。
|
||||
|
||||

|
||||
|
||||
## 二、前置条件
|
||||
|
||||
HBase的运行需要依赖JDK和Hadoop,HBase 2.0+需要安装JDK 1.8+ 。同时为了保证高可用,这里我们不采用HBase内置的Zookeeper,而采用外置的Zookeeper集群。相关搭建步骤可以参阅:
|
||||
|
||||
- [Linux环境下JDK安装](https://github.com/heibaiying/BigData-Notes/blob/master/notes/installation/Linux下JDK安装.md)
|
||||
- [Zookeeper单机环境和集群环境搭建](https://github.com/heibaiying/BigData-Notes/blob/master/notes/installation/Zookeeper单机环境和集群环境搭建.md)
|
||||
- [Hadoop集群环境搭建](https://github.com/heibaiying/BigData-Notes/blob/master/notes/installation/Hadoop集群环境搭建.md)
|
||||
|
||||
|
||||
|
||||
## 三、集群搭建
|
||||
|
||||
### 3.1 下载并解压
|
||||
|
||||
下载并解压,官方下载地址:https://hbase.apache.org/downloads.html
|
||||
|
||||
```shell
|
||||
# tar -zxvf hbase-2.1.4-bin.tar.gz
|
||||
```
|
||||
|
||||
### 3.2 配置环境变量
|
||||
|
||||
```shell
|
||||
# vim /etc/profile
|
||||
```
|
||||
|
||||
添加环境变量:
|
||||
|
||||
```shell
|
||||
export HBASE_HOME=/usr/app/hbase-2.1.4
|
||||
export PATH=$HBASE_HOME/bin:$PATH
|
||||
```
|
||||
|
||||
使得配置的环境变量立即生效:
|
||||
|
||||
```shell
|
||||
# source /etc/profile
|
||||
```
|
||||
|
||||
### 3.3 集群配置
|
||||
|
||||
进入`${HBASE_HOME}/conf`目录下,修改配置:
|
||||
|
||||
#### 1. hbase-env.sh
|
||||
|
||||
```shell
|
||||
# 配置JDK安装位置
|
||||
export JAVA_HOME=/usr/java/jdk1.8.0_201
|
||||
# 不使用内置的zookeeper服务
|
||||
export HBASE_MANAGES_ZK=false
|
||||
```
|
||||
|
||||
#### 2. hbase-site.xml
|
||||
|
||||
```xml
|
||||
<configuration>
|
||||
<property>
|
||||
<!-- 指定hbase以分布式集群的方式运行 -->
|
||||
<name>hbase.cluster.distributed</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
<property>
|
||||
<!-- 指定hbase在HDFS上的存储位置 -->
|
||||
<name>hbase.rootdir</name>
|
||||
<value>hdfs://hadoop001:8020/hbase</value>
|
||||
</property>
|
||||
<property>
|
||||
<!-- 指定zookeeper的地址-->
|
||||
<name>hbase.zookeeper.quorum</name>
|
||||
<value>hadoop001:2181,hadoop002:2181,hadoop003:2181</value>
|
||||
</property>
|
||||
</configuration>
|
||||
```
|
||||
|
||||
#### 3. regionservers
|
||||
|
||||
```
|
||||
hadoop001
|
||||
hadoop002
|
||||
hadoop003
|
||||
```
|
||||
|
||||
#### 4. backup-masters
|
||||
|
||||
```
|
||||
hadoop002
|
||||
```
|
||||
|
||||
` backup-masters`这个文件是不存在的,需要新建,主要用来指明备用的master节点,可以是多个,这里我们以1个为例。
|
||||
|
||||
### 3.4 HDFS客户端配置
|
||||
|
||||
这里有一个可选的配置:如果您在Hadoop集群上进行了HDFS客户端配置的更改,比如将副本系数`dfs.replication`设置成5,则必须使用以下方法之一来使HBase知道,否则HBase将依旧使用默认的副本系数3来创建文件:
|
||||
|
||||
> 1. Add a pointer to your `HADOOP_CONF_DIR` to the `HBASE_CLASSPATH` environment variable in *hbase-env.sh*.
|
||||
> 2. Add a copy of *hdfs-site.xml* (or *hadoop-site.xml*) or, better, symlinks, under *${HBASE_HOME}/conf*, or
|
||||
> 3. if only a small set of HDFS client configurations, add them to *hbase-site.xml*.
|
||||
|
||||
以上是官方文档的说明,这里解释一下:
|
||||
|
||||
**第一种** :将Hadoop配置文件的位置信息添加到`hbase-env.sh`的`HBASE_CLASSPATH` 属性,示例如下:
|
||||
|
||||
```shell
|
||||
export HBASE_CLASSPATH=usr/app/hadoop-2.6.0-cdh5.15.2/etc/hadoop
|
||||
```
|
||||
|
||||
**第二种** :将Hadoop的` hdfs-site.xml`或`hadoop-site.xml` 拷贝到 `${HBASE_HOME}/conf `目录下,或者通过符号链接的方式。如果采用这种方式的话,建议将两者都拷贝或建立符号链接,示例如下:
|
||||
|
||||
```shell
|
||||
# 拷贝
|
||||
cp core-site.xml hdfs-site.xml /usr/app/hbase-1.2.0-cdh5.15.2/conf/
|
||||
# 使用符号链接
|
||||
ln -s /usr/app/hadoop-2.6.0-cdh5.15.2/etc/hadoop/core-site.xml
|
||||
ln -s /usr/app/hadoop-2.6.0-cdh5.15.2/etc/hadoop/hdfs-site.xml
|
||||
```
|
||||
|
||||
> 注:`hadoop-site.xml`这个配置文件现在叫做`core-site.xml`
|
||||
|
||||
**第三种** :如果你只有少量更改,那么直接配置到`hbase-site.xml`中即可。
|
||||
|
||||
|
||||
|
||||
### 3.5 安装包分发
|
||||
|
||||
将HBase的安装包分发到其他服务器,分发后建议在这两台服务器上也配置一下HBase的环境变量。
|
||||
|
||||
```shell
|
||||
scp -r /usr/app/hbase-1.2.0-cdh5.15.2/ hadoop002:usr/app/
|
||||
scp -r /usr/app/hbase-1.2.0-cdh5.15.2/ hadoop003:usr/app/
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 四、启动集群
|
||||
|
||||
### 4.1 启动ZooKeeper集群
|
||||
|
||||
分别到三台服务器上启动ZooKeeper服务:
|
||||
|
||||
```shell
|
||||
zkServer.sh start
|
||||
```
|
||||
|
||||
### 4.2 启动Hadoop集群
|
||||
|
||||
```shell
|
||||
# 启动dfs服务
|
||||
start-dfs.sh
|
||||
# 启动yarn服务
|
||||
start-yarn.sh
|
||||
```
|
||||
|
||||
### 4.3 启动HBase集群
|
||||
|
||||
进入hadoop001的`${HBASE_HOME}/bin`,使用以下命令启动HBase集群。执行此命令后,会在hadoop001上启动`Master`服务,在hadoop002上启动备用`Master`服务,在`regionservers`文件中配置的所有节点启动`region server`服务。
|
||||
|
||||
```shell
|
||||
start-hbase.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
### 4.5 查看服务
|
||||
|
||||
访问HBase的Web-UI界面,这里我安装的HBase版本为1.2,访问端口为`60010`,如果你安装的是2.0以上的版本,则访问端口号为`16010`。可以看到`Master`在hadoop001上,三个`Regin Servers`分别在hadoop001,hadoop002,和hadoop003上,并且还有一个`Backup Matser` 服务在 hadoop002上。
|
||||
|
||||

|
||||
|
||||
<br/>
|
||||
|
||||
hadoop002 上的 HBase出于备用状态:
|
||||
|
||||
<br/>
|
||||
|
||||

|
212
notes/installation/Hadoop集群环境搭建.md
Normal file
212
notes/installation/Hadoop集群环境搭建.md
Normal file
@ -0,0 +1,212 @@
|
||||
# Hadoop集群环境搭建
|
||||
|
||||
## 一、集群规划
|
||||
|
||||
这里搭建一个3节点的Hadoop集群,其中三台主机均部署`DataNode`和`NodeManager`服务,但只有hadoop001上部署`NameNode`和`ResourceManager`服务。
|
||||
|
||||

|
||||
|
||||
## 二、前置条件
|
||||
|
||||
Hadoop的运行依赖JDK,需要预先安装。其安装步骤单独整理至:
|
||||
|
||||
+ [Linux下JDK的安装](https://github.com/heibaiying/BigData-Notes/blob/master/notes/installation/JDK%E5%AE%89%E8%A3%85.md)
|
||||
|
||||
|
||||
|
||||
## 三、配置免密登录
|
||||
|
||||
### 3.1 生成密匙
|
||||
|
||||
在每台主机上使用ssh-keygen产生公钥私钥对:
|
||||
|
||||
```shell
|
||||
ssh-keygen
|
||||
```
|
||||
|
||||
### 3.2 免密登录
|
||||
|
||||
将`hadoop001`的公钥写到本机和远程机器的` ~/ .ssh/authorized_key`文件中:
|
||||
|
||||
```shell
|
||||
ssh-copy-id -i ~/.ssh/id_rsa.pub hadoop001
|
||||
ssh-copy-id -i ~/.ssh/id_rsa.pub hadoop002
|
||||
ssh-copy-id -i ~/.ssh/id_rsa.pub hadoop003
|
||||
```
|
||||
|
||||
### 3.3 验证免密登录
|
||||
|
||||
```she
|
||||
ssh hadoop002
|
||||
ssh hadoop003
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 四、集群搭建
|
||||
|
||||
### 3.1 下载并解压
|
||||
|
||||
下载Hadoop。这里我下载的是CDH版本Hadoop,下载地址为:http://archive.cloudera.com/cdh5/cdh/5/
|
||||
|
||||
```shell
|
||||
# tar -zvxf hadoop-2.6.0-cdh5.15.2.tar.gz
|
||||
```
|
||||
|
||||
### 3.2 配置环境变量
|
||||
|
||||
编辑`profile`文件:
|
||||
|
||||
```shell
|
||||
# vim /etc/profile
|
||||
```
|
||||
|
||||
增加如下配置:
|
||||
|
||||
```
|
||||
export HADOOP_HOME=/usr/app/hadoop-2.6.0-cdh5.15.2
|
||||
export PATH=${HADOOP_HOME}/bin:$PATH
|
||||
```
|
||||
|
||||
执行`source`命令,使得配置立即生效:
|
||||
|
||||
```shell
|
||||
# source /etc/profile
|
||||
```
|
||||
|
||||
### 3.3 修改配置
|
||||
|
||||
进入`${HADOOP_HOME}/etc/hadoop`目录下,修改配置文件。各个配置文件内容如下:
|
||||
|
||||
#### 1. hadoop-env.sh
|
||||
|
||||
```shell
|
||||
# 指定JDK的安装位置
|
||||
export JAVA_HOME=/usr/java/jdk1.8.0_201/
|
||||
```
|
||||
|
||||
#### 2. core-site.xml
|
||||
|
||||
```xml
|
||||
<configuration>
|
||||
<property>
|
||||
<!--指定namenode的hdfs协议文件系统的通信地址-->
|
||||
<name>fs.defaultFS</name>
|
||||
<value>hdfs://hadoop001:8020</value>
|
||||
</property>
|
||||
<property>
|
||||
<!--指定hadoop集群存储临时文件的目录-->
|
||||
<name>hadoop.tmp.dir</name>
|
||||
<value>/home/hadoop/tmp</value>
|
||||
</property>
|
||||
</configuration>
|
||||
```
|
||||
|
||||
#### 3. hdfs-site.xml
|
||||
|
||||
```xml
|
||||
<property>
|
||||
<!--namenode节点数据(即元数据)的存放位置,可以指定多个目录实现容错,多个目录用逗号分隔-->
|
||||
<name>dfs.namenode.name.dir</name>
|
||||
<value>/home/hadoop/namenode/data</value>
|
||||
</property>
|
||||
<property>
|
||||
<!--datanode节点数据(即数据块)的存放位置-->
|
||||
<name>dfs.datanode.data.dir</name>
|
||||
<value>/home/hadoop/datanode/data</value>
|
||||
</property>
|
||||
```
|
||||
|
||||
#### 4. yarn-site.xml
|
||||
|
||||
```xml
|
||||
<property>
|
||||
<!--配置NodeManager上运行的附属服务。需要配置成mapreduce_shuffle后才可以在Yarn上运行MapReduce程序。-->
|
||||
<name>yarn.nodemanager.aux-services</name>
|
||||
<value>mapreduce_shuffle</value>
|
||||
</property>
|
||||
<property>
|
||||
<!--resourcemanager的主机名-->
|
||||
<name>yarn.resourcemanager.hostname</name>
|
||||
<value>hadoop001</value>
|
||||
</property>
|
||||
</configuration>
|
||||
|
||||
```
|
||||
|
||||
#### 5. mapred-site.xml
|
||||
|
||||
```xml
|
||||
<configuration>
|
||||
<property>
|
||||
<!--指定mapreduce作业运行在yarn上-->
|
||||
<name>mapreduce.framework.name</name>
|
||||
<value>yarn</value>
|
||||
</property>
|
||||
</configuration>
|
||||
```
|
||||
|
||||
#### 5. slaves
|
||||
|
||||
配置所有从属节点的主机名或IP地址,每行一个。
|
||||
|
||||
```properties
|
||||
hadoop001
|
||||
hadoop002
|
||||
hadoop003
|
||||
```
|
||||
|
||||
### 3.4 分发程序
|
||||
|
||||
将Hadoop安装包分发到其他两台服务器,分发后建议在这两台服务器上也配置一下Hadoop的环境变量。
|
||||
|
||||
```shell
|
||||
# 将安装包分发到hadoop002
|
||||
scp -r /usr/app/hadoop-2.6.0-cdh5.15.2/ hadoop002:/usr/app/
|
||||
# 将安装包分发到hadoop003
|
||||
scp -r /usr/app/hadoop-2.6.0-cdh5.15.2/ hadoop003:/usr/app/
|
||||
```
|
||||
|
||||
### 3.5 初始化
|
||||
|
||||
在`Hadoop001`上执行namenode初始化命令:
|
||||
|
||||
```
|
||||
hadoop namenode -format
|
||||
```
|
||||
|
||||
### 3.6 启动集群
|
||||
|
||||
进入到`Hadoop001`的`${HADOOP_HOME}/sbin`目录下,启动Hadoop。此时`hadoop002`和`hadoop003`上的相关服务也会被启动。
|
||||
|
||||
```shell
|
||||
# 启动dfs服务
|
||||
start-dfs.sh
|
||||
# 启动yarn服务
|
||||
start-yarn.sh
|
||||
```
|
||||
|
||||
### 3.7 查看集群
|
||||
|
||||
在每台服务器上使用`jps`命令查看服务进程,或直接进入Web-UI界面进行查看,端口为`50070`。可以看到此时有三个可用的`Datanode`:
|
||||
|
||||

|
||||
|
||||
点击`Live Nodes`进入,可以看到每个`DataNode`的详细情况:
|
||||
|
||||

|
||||
|
||||
接着可以查看Yarn集群的情况,端口号为`8088` :
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
## 五、提交服务到集群
|
||||
|
||||
提交作业到集群的方式和单机环境完全一致,这里以提交Hadoop内置的计算Pi的示例程序为例,在任何一个节点上执行都可以,命令如下:
|
||||
|
||||
```shell
|
||||
hadoop jar /usr/app/hadoop-2.6.0-cdh5.15.2/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.0-cdh5.15.2.jar pi 3 3
|
||||
```
|
||||
|
172
notes/installation/Spark集群环境搭建.md
Normal file
172
notes/installation/Spark集群环境搭建.md
Normal file
@ -0,0 +1,172 @@
|
||||
# 基于ZooKeeper搭建Spark高可用集群
|
||||
|
||||
## 一、集群规划
|
||||
|
||||
这里搭建一个3节点的Spark集群,其中三台主机上均部署`Worker`服务。同时为了保证高可用,除了在hadoop001上部署主`Master`服务外,还在hadoop002和hadoop003上分别部署备用的`Master`服务,Master服务由Zookeeper集群进行协调管理,如果主`Master`不可用,则备用`Master`会成为新的主`Master`。
|
||||
|
||||

|
||||
|
||||
## 二、前置条件
|
||||
|
||||
搭建Spark集群前,需要保证JDK环境、Zookeeper集群和Hadoop集群已经搭建,相关步骤可以参阅:
|
||||
|
||||
- [Linux环境下JDK安装](https://github.com/heibaiying/BigData-Notes/blob/master/notes/installation/Linux下JDK安装.md)
|
||||
- [Zookeeper单机环境和集群环境搭建](https://github.com/heibaiying/BigData-Notes/blob/master/notes/installation/Zookeeper单机环境和集群环境搭建.md)
|
||||
- [Hadoop集群环境搭建](https://github.com/heibaiying/BigData-Notes/blob/master/notes/installation/Hadoop集群环境搭建.md)
|
||||
|
||||
## 三、Spark集群搭建
|
||||
|
||||
### 3.1 下载解压
|
||||
|
||||
下载所需版本的Spark,官网下载地址:http://spark.apache.org/downloads.html
|
||||
|
||||
<div align="center"> <img width="600px" src="https://github.com/heibaiying/BigData-Notes/blob/master/pictures/spark-download.png"/> </div>
|
||||
|
||||
|
||||
|
||||
下载后进行解压:
|
||||
|
||||
```shell
|
||||
# tar -zxvf spark-2.2.3-bin-hadoop2.6.tgz
|
||||
```
|
||||
|
||||
|
||||
|
||||
### 3.2 配置环境变量
|
||||
|
||||
```shell
|
||||
# vim /etc/profile
|
||||
```
|
||||
|
||||
添加环境变量:
|
||||
|
||||
```shell
|
||||
export SPARK_HOME=/usr/app/spark-2.2.3-bin-hadoop2.6
|
||||
export PATH=${SPARK_HOME}/bin:$PATH
|
||||
```
|
||||
|
||||
使得配置的环境变量立即生效:
|
||||
|
||||
```shell
|
||||
# source /etc/profile
|
||||
```
|
||||
|
||||
### 3.3 集群配置
|
||||
|
||||
进入`${SPARK_HOME}/conf`目录,拷贝配置样本进行修改:
|
||||
|
||||
#### 1. spark-env.sh
|
||||
|
||||
```she
|
||||
cp spark-env.sh.template spark-env.sh
|
||||
```
|
||||
|
||||
```shell
|
||||
# 配置JDK安装位置
|
||||
JAVA_HOME=/usr/java/jdk1.8.0_201
|
||||
# 配置hadoop配置文件的位置
|
||||
HADOOP_CONF_DIR=/usr/app/hadoop-2.6.0-cdh5.15.2/etc/hadoop
|
||||
# 配置zookeeper地址
|
||||
SPARK_DAEMON_JAVA_OPTS="-Dspark.deploy.recoveryMode=ZOOKEEPER -Dspark.deploy.zookeeper.url=hadoop001:2181,hadoop002:2181,hadoop003:2181 -Dspark.deploy.zookeeper.dir=/spark"
|
||||
```
|
||||
|
||||
#### 2. slaves
|
||||
|
||||
```
|
||||
cp slaves.template slaves
|
||||
```
|
||||
|
||||
配置所有Woker节点的位置:
|
||||
|
||||
```properties
|
||||
hadoop001
|
||||
hadoop002
|
||||
hadoop003
|
||||
```
|
||||
|
||||
### 3.4 安装包分发
|
||||
|
||||
将Spark的安装包分发到其他服务器,分发后建议在这两台服务器上也配置一下Spark的环境变量。
|
||||
|
||||
```shell
|
||||
scp -r /usr/app/spark-2.4.0-bin-hadoop2.6/ hadoop002:usr/app/
|
||||
scp -r /usr/app/spark-2.4.0-bin-hadoop2.6/ hadoop003:usr/app/
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 四、启动集群
|
||||
|
||||
### 4.1 启动ZooKeeper集群
|
||||
|
||||
分别到三台服务器上启动ZooKeeper服务:
|
||||
|
||||
```shell
|
||||
zkServer.sh start
|
||||
```
|
||||
|
||||
### 4.2 启动Hadoop集群
|
||||
|
||||
```shell
|
||||
# 启动dfs服务
|
||||
start-dfs.sh
|
||||
# 启动yarn服务
|
||||
start-yarn.sh
|
||||
```
|
||||
|
||||
### 4.3 启动Spark集群
|
||||
|
||||
进入hadoop001的` ${SPARK_HOME}/sbin`目录下,执行下面命令启动集群。执行命令后,会在hadoop001上启动`Maser`服务,会在`slaves`配置文件中配置的所有节点上启动`Worker`服务。
|
||||
|
||||
```shell
|
||||
start-all.sh
|
||||
```
|
||||
|
||||
分别在hadoop002和hadoop003上执行下面的命令,启动备用的`Master`服务:
|
||||
|
||||
```shell
|
||||
# ${SPARK_HOME}/sbin 下执行
|
||||
start-master.sh
|
||||
```
|
||||
|
||||
### 4.4 查看服务
|
||||
|
||||
查看Spark的Web-UI页面,端口为`8080`。此时可以看到hadoop001上的Master节点处于`ALIVE`状态,并有3个可用的`Worker`节点。
|
||||
|
||||

|
||||
|
||||
而hadoop002和hadoop003上的Master节点均处于`STANDBY`状态,没有可用的`Worker`节点。
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
## 五、验证集群高可用
|
||||
|
||||
此时可以使用`kill`命令杀死hadoop001上的`Master`进程,此时`备用Master`会中会有一个再次成为`主Master`,我这里是hadoop002,可以看到hadoop2上的`Master`经过`RECOVERING`后成为了新的`主Master`,并且获得了全部可以用的`Workers`。
|
||||
|
||||
此时如果你再在hadoop001上使用`start-master.sh`启动Master,那么其会作为`备用Master`存在。
|
||||
|
||||

|
||||
|
||||
Hadoop002上的`Master`成为`主Master`,并获得了全部可以用的`Workers`。
|
||||
|
||||

|
||||
|
||||
## 六、提交作业
|
||||
|
||||
和单机环境下的提交到Yarn上的命令完全一致,这里以Spark内置的计算Pi的样例程序为例,提交命令如下:
|
||||
|
||||
```shell
|
||||
spark-submit \
|
||||
--class org.apache.spark.examples.SparkPi \
|
||||
--master yarn \
|
||||
--deploy-mode client \
|
||||
--executor-memory 1G \
|
||||
--num-executors 10 \
|
||||
/usr/app/spark-2.4.0-bin-hadoop2.6/examples/jars/spark-examples_2.11-2.4.0.jar \
|
||||
100
|
||||
```
|
||||
|
BIN
pictures/hadoop集群规划.png
Normal file
BIN
pictures/hadoop集群规划.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
BIN
pictures/hbase集群规划.png
Normal file
BIN
pictures/hbase集群规划.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
BIN
pictures/spark集群规划.png
Normal file
BIN
pictures/spark集群规划.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
Loading…
x
Reference in New Issue
Block a user