Spark Thrift Server

ThriftServer是一个JDBC/ODBC接口,用户可以通过JDBC/ODBC连接ThriftServer来访问SparkSQL的数据。ThriftServer在启动的时候,会启动了一个SparkSQL的应用程序,而通过JDBC/ODBC连接进来的客户端共同分享这个SparkSQL应用程序的资源,也就是说不同的用户之间可以共享数据;ThriftServer启动时还开启一个侦听器,等待JDBC客户端的连接和提交查询。所以,在配置ThriftServer的时候,至少要配置ThriftServer的主机名和端口,如果要使用Hive数据的话,还要提供Hive Metastore的uris。

具体配置

1、修改$SPARK_HOME/conf目录下的hive-site.xml文件,具体配置如下

<?xml version="1.0"?>
<configuration>
<!-- Hive Metastore 配置 -->
<property>
<name>hive.metastore.uris</name>
<value>thrift://m1:9083</value>
<description>Thrift URI for the remote metastore. Used by metastore client to connect to remote metastore.</description>
</property>

<property>
<name>hive.server2.thrift.min.worker.threads</name>
<value>5</value>
<description>Minimum number of Thrift worker threads</description>
</property>

<property>
<name>hive.server2.thrift.max.worker.threads</name>
<value>500</value>
<description>Maximum number of Thrift worker threads</description>
</property>

<!-- Thrift Server服务器绑定的端口 -->
<property>
<name>hive.server2.thrift.port</name>
<value>10000</value>
<description>Port number of HiveServer2 Thrift interface. Can be overridden by setting $HIVE_SERVER2_THRIFT_PORT</description>
</property>

<!-- Thrift Server服务器地址 -->
<property>
<name>hive.server2.thrift.bind.host</name>
<value>m1</value>
<description>Bind host on which to run the HiveServer2 Thrift interface.Can be overridden by setting$HIVE_SERVER2_THRIFT_BIND_HOST</description>
</property>
</configuration>

2、启动hive metastore

$nohup hive --service metastore > metastore.log 2>&1 &

  

3、启动spark

./sbin/start-all.sh

  

4、启动Thrift Server

./sbin/start-thriftserver.sh --master spark://m1:7077

  

5、客户端连接Thrift Server

启动beeline

./bin/beeline

  

连接服务

!connect jdbc:hive2://m1:10000

  

连接成功后就可以在这里使用HQL进行操作了

 

posted @ 2017-04-27 17:36  天之涯0204  阅读(2541)  评论(0编辑  收藏  举报