spark SQL Running the Thrift JDBC/ODBC server
来源:互联网 发布:九维网络登录 编辑:程序博客网 时间:2024/05/01 02:01
Running the Thrift JDBC/ODBC server
1:运行
./sbin/start-thriftserver.sh --hiveconf hive.server2.thrift.port=10000 --hiveconf hive.server2.thrift.bind.host=feng02 --master spark://feng02:7077 --driver-class-path /home/jifeng/hadoop/spark-1.2.0-bin-2.4.1/lib/mysql-connector-java-5.1.32-bin.jar --executor-memory 1g
端口:10000
服务器:feng02
spark master:spark://feng02:7077
driver-class-path:mysql驱动包(hive配置的)
[jifeng@feng02 spark-1.2.0-bin-2.4.1]$ ./sbin/start-thriftserver.sh --hiveconf hive.server2.thrift.port=10000 --hiveconf hive.server2.thrift.bind.host=feng02 --master spark://feng02:7077 --driver-class-path /home/jifeng/hadoop/spark-1.2.0-bin-2.4.1/lib/mysql-connector-java-5.1.32-bin.jarstarting org.apache.spark.sql.hive.thriftserver.HiveThriftServer2, logging to /home/jifeng/hadoop/spark-1.2.0-bin-2.4.1/sbin/../logs/spark-jifeng-org.apache.spark.sql.hive.thriftserver.HiveThriftServer2-1-feng02.out
2:运行beeline
Now you can use beeline to test the Thrift JDBC/ODBC server:
./bin/beeline
[jifeng@feng02 spark-1.2.0-bin-2.4.1]$ ./bin/beelineSpark assembly has been built with Hive, including Datanucleus jars on classpathBeeline version ??? by Apache Hive
3:连接server
参考:https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-BeelineExample
beeline> !connect jdbc:hive2://feng02:10000 jifeng jifeng org.apache.hive.jdbc.HiveDriverConnecting to jdbc:hive2://feng02:10000log4j:WARN No appenders could be found for logger (org.apache.thrift.transport.TSaslTransport).log4j:WARN Please initialize the log4j system properly.log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.Connected to: Spark SQL (version 1.2.0)Driver: null (version null)Transaction isolation: TRANSACTION_REPEATABLE_READ
4:查询
0: jdbc:hive2://feng02:10000> show tables; +----------------+| result |+----------------+| course || hbase_table_1 || pokes || student |+----------------+4 rows selected (2.723 seconds)
0: jdbc:hive2://feng02:10000> select * from student;+-----+----------+------+| id | name | age |+-----+----------+------+| 1 | nick | 24 || 2 | doping | 25 || 3 | caizhi | 26 || 4 | liaozhi | 27 || 5 | wind | 30 |+-----+----------+------+5 rows selected (10.554 seconds)0: jdbc:hive2://feng02:10000> select a.*,b.* from student a join course b where a.id=b.id ;+-----+----------+------+-----+-----+-----+-----+-----+| id | name | age | id | c1 | c2 | c3 | c4 |+-----+----------+------+-----+-----+-----+-----+-----+| 1 | nick | 24 | 1 | 英语 | 中文 | 法文 | 日文 || 2 | doping | 25 | 2 | 中文 | 法文 | | || 3 | caizhi | 26 | 3 | 中文 | 法文 | 日文 | || 4 | liaozhi | 27 | 4 | 中文 | 法文 | 拉丁 | || 5 | wind | 30 | 5 | 中文 | 法文 | 德文 | |+-----+----------+------+-----+-----+-----+-----+-----+5 rows selected (2.33 seconds)
4:Java JDBC连接
package demo.test;import java.sql.*;public class Pretest { public static void main( String args[] ) throws SQLException , ClassNotFoundException { String jdbcdriver="org.apache.hive.jdbc.HiveDriver"; String jdbcurl="jdbc:hive2://feng02:10000"; String username="scott"; String password="tiger"; Class.forName(jdbcdriver); Connection c = DriverManager.getConnection(jdbcurl,username,password); Statement st = c.createStatement(); print( "num should be 1 " , st.executeQuery("select * from student")); // TODO indexing } static void print( String name , ResultSet res ) throws SQLException { System.out.println( name); ResultSetMetaData meta=res.getMetaData(); //System.out.println( "\t"+res.getRow()+"条记录"); Stringstr=""; for(int i=1;i<=meta.getColumnCount();i++){ str+=meta.getColumnName(i)+" "; //System.out.println( meta.getColumnName(i)+" "); } System.out.println("\t"+str); str=""; while ( res.next() ){ for(int i=1;i<=meta.getColumnCount();i++){ str+= res.getString(i)+" "; } System.out.println("\t"+str); str=""; } } }
上面是运行参数
结果显示:
num should be 1 id name age 1 nick 24 2 doping 25 3 caizhi 26 4 liaozhi 27 5 wind 30
0 0
- spark SQL Running the Thrift JDBC/ODBC server
- spark SQL Running the Thrift JDBC/ODBC server
- Spark SQL读取Hive数据配置及使用Thrift JDBC/ODBC Server访问Spark SQL
- 通过Thrift Server使用JDBC来运行Spark SQL
- Spark SQL thrift server 部署
- spark-thrift-server 执行spark-sql 的OOM GC异常.
- Spark SQL和Spark Thrift Server安装部署
- cloudera cdh 5.11 编译 启动spark thrift server spark sql
- CDH5.3.2中配置运行Spark SQL的Thrift Server
- CDH5.5.0中配置运行Spark SQL的Thrift Server
- spark sql thrift server搭建及踩过的坑
- SQL server, get all running sessions on the SQL server
- 如何使用Spark SQL 的JDBC server
- 如何用java连接SQL server(JDBC-ODBC桥)
- [Spark]Django项目使用Spark(thrift-server)
- SQL SERVER ODBC 出错
- jsp/java代码中用jdbc驱动代替jdbc-odbc桥连接SQL Server数据库
- 大数据IMF传奇行动绝密课程第73课:Spark SQL Thrift Server实战
- oc中分类 扩展 协议的使用及区别
- 内核编译
- DrawerLayout
- UVa 331 交换的方案数 (回溯法,启发)
- C++ 多态、重载、函数隐藏
- spark SQL Running the Thrift JDBC/ODBC server
- 机器学习算法 - k-means Clustering K均值聚类
- MySQL服务无法启动(2003 - Can't connect to MySQL server on‘localhost' (10061).)
- killall
- red hat Linux操作系统下载地址
- Handler、MessageQueue 、Looper的关系
- 中兴V5s N918st专用中文TWRP2.8.5.1 recovery(电量显示正常)
- Composer PHP用来管理依赖关系的工具
- Android Studio使用小指南