我爱编程

2.环境搭建

2018-03-06  本文已影响0人  PigPIgAutumn

目录
1.系统架构
2.环境搭建
2.1本地环境下kafka批量导入数据
2.2 kafka-manager的安装与配置
3.1 Spark Streaming 性能调优(一): 解决并行度
3.2 Spark Streaming 性能调优(二): 解决task倾斜

这个项目需要安装:

1.Cassandra 2.2.8

Apache Cassandra是一个高度可扩展的高性能分布式数据库,用于处理大量商用服务器上的大量数据,提供高可用性,无单点故障。这是一种NoSQL类型的数据库。以下是cassandra的特性:

2.Kairosdb 1.1.3

KairosDB是一个快速可靠的分布式时间序列数据库,主要用Cassandra来做底层存储,也可以使用HBase。KairosDB是在OpenTSDB基础上重写的。其主要功能如下:

3.Kafka 0.8.2

Kafka其实说白了就是一个分布式的消息队列,底层依赖于Zookeeper.kafka 是一个中间件,是一个服务。任何机器都可以向它生产数据和消费数据。

4.Zookeeper 3.4.5

Kafka的核心,负责保存Kafka的topic信息和其他配置信息,也是一个中间件

5.spark 2.3.0

Apache Spark 是专为大规模数据处理而设计的快速通用的计算引擎,其启用了内存分布数据集,除了能够提供交互式查询外,它还可以优化迭代工作负载。要运行spark还需要在机器上配置scala

6.jdk 1.8

1.安装Cassandra:

①.下载:
官网上只有最新版的下载,但是官方提供了所有旧版release的仓库,点击这里就可以找到自己要下载的版本了.
②.配置Cassandra:
1.首先在你喜欢的地方,新建以下三个文件夹:

mkdir /var/lib/cassandra/data
mkdir /var/lib/cassandra/commitlog
mkdir /var/lib/cassandra/saved_caches

2.解压刚刚下载好的压缩包,之后进入/cassandra/conf目录,打开cassandra.yaml文件,将配置文件中的三个地方改成刚刚新建的那三个文件夹

data_file_directories:
- /var/lib/cassandra/data // 注意,这里-前面不能有空格!!!
commitlog_directory: /var/lib/cassandra/commitlog
saved_caches_directory: /var/lib/cassandra/saved_caches
# 开启rpc服务,如果不开启的话,Kairosdb将无法调用cassandra的api
start_rpc: true

③.运行:
进入/cassandra/bin目录,运行脚本:

./cassandra

如果没报错的话就表示cassandra正常启动了,使用:

./nodetool status

也可以查看当前数据库所有节点的状态

2.安装Kairosdb

①.下载:
kairosdb是开源的,在github上可以直接下载:https://github.com/kairosdb/kairosdb/releases
直接下载需要的版本即可
②.配置:
解压刚刚下载的压缩包,进入/conf目录,打开Kairosdb.properties文件,
要使用cassandra作为kairosdb的存储服务,就必须如下配置:

#kairosdb.service.datastore=org.kairosdb.datastore.h2.H2Module // 默认使用h2作为存储服务,所以要注释这行  
kairosdb.service.datastore=org.kairosdb.datastore.cassandra.CassandraModule  

其他配置默认即可
③.运行:
运行Kairosdb前需要先启动cassandra,启动cassandra后,进入Kairosdb/bin目录,运行命令:

./kairosdb.sh run

即可启动Kairosdb

3.安装Kafka:

①.下载:
Kafka直接去官方下就可以,官网挺好看的,一下子就找到了要安装的版本了,这里附一下连接吧
http://kafka.apache.org/downloads
②.配置:
解压刚刚下载的压缩包,先进入/conf目录,编辑zookeeper.properties文件:
配置可以跟下面安装Zookeeper的配置文件一样:

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/opt/zookeeper-datas
# the port at which the clients will connect
clientPort=2181
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

至于server.properties也是需要修改的,这个就先留到后面我摸索好所有组件如何用再回来完善吧...
③.运行:
进入/bin目录,输入以下命令:

kafka-server-start.sh config/server.properties & 

即可指定配置文件,并开启kafka后台进程

Kafka-Manager

日常开发中总是敲命令行来管理kafka还是有点不方便,所以这里我用了kafka-manager来管理kafka.
这里附上我安装kafka-mananger的过程: kafka-manager的安装与配置

4.安装Zookeeper:

kafka下载好后其实自带了zookeeper, 详情可以去这篇补充文章里面看2.1 本地环境下kafka批量导入数据

①.下载:
同样地,zookeeper官网只有最新版的,要想下载以前的版本,只能通过官网提供的旧版仓库:
https://archive.apache.org/dist/zookeeper/
这样就可以找到自己想要的版本了
②.配置:
1.新建文件夹:

mkdir /opt/zookeeper-datas

解压刚刚下载好的压缩包,进行/conf目录,新建zoo.cfg文件,并输入以下内容:

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/opt/zookeeper-datas
# the port at which the clients will connect
clientPort=2181
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

新建好配置文件后,进行/bin目录,运行命令:

./zkServer.sh start

即可开启zookeeper服务

5.安装spark:

spark就没有啥比较好的安装方法了,下载scala,配置jdk,再下载spark的程序压缩包(spark的压缩包可能需要科学上网才能正常下载)就行,开包即用

6.安装jdk:

这么简单的我就不写了,网上一搜一大堆

上一篇 下一篇

猜你喜欢

热点阅读