spark-sql(二)---ThriftServer模式
来源:互联网 发布:淘宝司法拍卖房产过户 编辑:程序博客网 时间:2024/06/12 18:55
ThriftServer
ThriftServer和和hiveserver2类似,提供了jdbc/odbc的接口,spark-sql以这种模式启动后可以以服务的形式提供SQL查询。
客户端可以用jdbc直接访问spark-sql,用sql进行交互。
启动
安装配置接前面链接
http://blog.csdn.net/dante_003/article/details/78652534
配置文件用的上个连接 conf/hive-site.xml
sbin/start-thriftserver.sh --master yarn \--driver-cores 2 --driver-memory 2g \--executor-cores 13 --executor-memory 16g \--num-executors 3
beeline
注意:一定要用spark文件夹中的beeline,不用使用hive文件夹中的beeline
[root@ht05 bin]# bin/beeline -u jdbc:hive2://localhost:10000Connecting to jdbc:hive2://localhost:1000017/11/28 17:43:40 INFO jdbc.Utils: Supplied authorities: localhost:1000017/11/28 17:43:40 INFO jdbc.Utils: Resolved authority: localhost:1000017/11/28 17:43:40 INFO jdbc.HiveConnection: Will try to open client transport with JDBC Uri: jdbc:hive2://localhost:10000Connected to: Spark SQL (version 2.2.0)Driver: Hive JDBC (version 1.2.1.spark2)Transaction isolation: TRANSACTION_REPEATABLE_READBeeline version 1.2.1.spark2 by Apache Hive0: jdbc:hive2://localhost:10000> show tables;+-----------+---------------+--------------+--+| database | tableName | isTemporary |+-----------+---------------+--------------+--+| default | test_orc | false || default | test_orc_t | false || default | test_phoenix | false || default | test_txt | false || default | test_txt1 | false |+-----------+---------------+--------------+--+5 rows selected (0.587 seconds)0: jdbc:hive2://localhost:10000> select count(*) from test_txt1;+--------------+--+| count(1) |+--------------+--+| 12818207296 |+--------------+--+1 row selected (262.646 seconds)
java jdbc连接
取出jdbc驱动,位置在spark/jars/hive-jdbc-1.2.1.spark2.jar
TestSparksql.java
import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;public class TestSparksql { private static String driverName="org.apache.hive.jdbc.HiveDriver"; public static void main(String[] args) throws ClassNotFoundException, SQLException { Class.forName(driverName); Connection con=DriverManager.getConnection("jdbc:hive2://192.168.2.5:10000/default", "", ""); Statement statement = con.createStatement(); String sql="select * from test_txt1 limit 10"; ResultSet executeQuery = statement.executeQuery(sql); while(executeQuery.next()){ String string = executeQuery.getString(1); System.out.println(string); } statement.close(); con.close(); }}
阅读全文
0 0
- spark-sql(二)---ThriftServer模式
- Spark thriftserver连elasticsearch
- Spark-ThriftServer源码分析
- spark基础之Spark SQL和Hive的集成以及ThriftServer配置
- 关于spark thriftserver的提问
- [spark]Spark thriftserver(HiveServer2) Custom认证
- Spark 1.6.3 thriftServer 支持 ldap 配置
- 如何在Spark平台搭建ThriftServer
- cdh上使用spark-thriftserver操作carbondata
- 编译spark:[thriftServer.sh属于测试阶段 hive-0.13.1]
- Spark实战-Spark SQL(二)
- Spark SQL 之SQLContext(二)
- spark SQL (二) 聚合
- spark-sql(一)---cli模式
- SQL反模式(二)
- Apache Spark数据分析教程(二):Spark SQL
- Apache Spark数据分析教程(二):Spark SQL
- Apache Spark数据分析教程(二):Spark SQL
- matplotlib绘图
- LINUX下常用SHELL指令
- React Navigation 入门(三)
- 使用Python读取C语言.so文件-: libmysqlclient.so.16: cannot open shared object file: No such file o
- nodejs express 路由
- spark-sql(二)---ThriftServer模式
- HDOJ1048 The Hardest Problem Ever
- 如何更新LMK Low Memory Killer的阈值
- IEEE论文检索地址和使用方法
- CSRF攻击与防御
- zabbix sender 配置方法
- Tomcat 部署项目的三种方法
- scala中运算符 :: 、:+ 、+: 、::: 、++ 的区别
- WCF、WebAPI、WCFREST、WebService之间的区别