如何在Spark平台搭建ThriftServer

来源:互联网 发布:凯里欧文数据 编辑:程序博客网 时间:2024/06/06 07:32

Thrift JDBC Server描述

Thrift JDBC Server使用的是HIVE0.12的HiveServer2实现。能够使用Spark或者hive0.12版本的beeline脚本与JDBC Server进行交互使用。Thrift JDBC Server默认监听端口是10000。

使用Thrift JDBC Server前需要注意:

1、将

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

说明: hive-site.xml配置有meta信息存储的MySQL路径

2、需要在$SPARK_HOME/conf/spark-env.sh中的SPARK_CLASSPATH添加jdbc驱动的jar包
export SPARK_CLASSPATH=$SPARK_CLASSPATH:/home/hadoop/software/mysql-connector-java-5.1.27-bin.jar


## Thrift JDBC Server/beeline启动

1. 启动Thrift JDBC Server:默认端口是10000

cd $SPARK_HOME/sbin
start-thriftserver.sh
> 如何修改Thrift JDBC Server的默认监听端口号?借助于--hiveconf
start-thriftserver.sh --hiveconf hive.server2.thrift.port=14000

Demo:

``` shell

#!/bin/bash

./sbin/start-thriftserver.sh \
--hiveconf hive.exec.mode.local.auto=true \
--hiveconf hive.auto.convert.join=true \
--hiveconf hive.mapjoin.smalltable.filesize=50000000 \
--name thriftserver \
--master yarn-client \
--driver-cores 5 \
--driver-memory 5G \
--conf spark.serializer=org.apache.spark.serializer.KryoSerializer \
--conf spark.scheduler.mode=FAIR \
--conf spark.kryoserializer.buffer.max.mb=1024 \
--conf spark.storage.memoryFraction=0.2

  1. 启动beeline
    cd $SPARK_HOME/bin
    beeline -u jdbc:hive2://hadoop000:10000

Demo:

$ ./bin/beelineBeeline version 1.2.1.spark2 by Apache Hivebeeline> !connect jdbc:hive2://localhost:10000
ref:http://slamke.github.io/2017/03/30/%E5%A6%82%E4%BD%95%E5%9C%A8Spark%E5%B9%B3%E5%8F%B0%E6%90%AD%E5%BB%BAThriftServer/
原创粉丝点击