如何从 spark thrift 服务器使用 hadoop?

How to use hadoop from spark thrift server?

请考虑以下设置。

hadoop 版本 2.6.4

spark 版本 2.1.0

OS CentOS Linux 发布 7.2.1511(核心)

所有软件作为单节点集群安装在单机上,spark以单机模式安装。 我正在尝试使用 Spark Thrift 服务器。 要启动 spark thrift 服务器,我 运行 shell 脚本 start-thriftserver.sh

运行连接 thrift 服务器后,我可以 运行 直线命令行工具并发出以下命令: 命令 运行 成功:

!connect jdbc:hive2://localhost:10000 user_name '' org.apache.hive.jdbc.HiveDriver
create database testdb;
use testdb;
create table names_tab(a int, name string) row format delimited fields terminated by ' ';

我的第一个问题是在 haddop 上的什么地方创建了这个 table/database 的底层 file/folder? 问题是即使使用 stop-all.sh 停止 hadoop,创建 table/database 命令仍然成功, 这让我觉得 table 根本不是在 hadoop 上创建的。

我的第二个问题是如何告诉 spark hadoop 安装在世界的哪个地方? 并要求 spark 使用 hadoop 作为来自 beeline.

的所有查询 运行 的基础数据存储

我应该以其他模式安装 spark 吗?

提前致谢。

我的 objective 是通过 Spark Thrift Server 使用 hadoop 作为基础 data-store 让直线命令行实用程序工作,我让它工作了。我的设置是这样的:

Hadoop  <-->  Spark  <-->  SparkThriftServer  <--> beeline

我想以这样的方式配置 spark,使其在直线命令行实用程序中对所有查询使用 hadoop 运行。 诀窍是在 spark-defaults.xml.

中指定以下 属性
spark.sql.warehouse.dir hdfs://localhost:9000/user/hive/warehouse

默认情况下,spark 对元数据和数据本身使用 derby(在 spark 中称为仓库) 为了让 spark 使用 hadoop 作为仓库,我必须添加这个 属性.

这是一个示例输出

./beeline
Beeline version 1.0.1 by Apache Hive
beeline> !connect jdbc:hive2://localhost:10000 abbasbutt '' org.apache.hive.jdbc.HiveDriver
Connecting to jdbc:hive2://localhost:10000
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/abbasbutt/Projects/hadoop_fdw/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/abbasbutt/Projects/hadoop_fdw/apache-hive-1.0.1-bin/lib/hive-jdbc-1.0.1-standalone.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
Connected to: Spark SQL (version 2.1.0)
Driver: Hive JDBC (version 1.0.1)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://localhost:10000>
0: jdbc:hive2://localhost:10000>
0: jdbc:hive2://localhost:10000>
0: jdbc:hive2://localhost:10000> create database my_test_db;
+---------+--+
| Result  |
+---------+--+
+---------+--+
No rows selected (0.379 seconds)
0: jdbc:hive2://localhost:10000> use my_test_db;
+---------+--+
| Result  |
+---------+--+
+---------+--+
No rows selected (0.03 seconds)
0: jdbc:hive2://localhost:10000> create table my_names_tab(a int, b string) row format delimited fields terminated by ' ';
+---------+--+
| Result  |
+---------+--+
+---------+--+
No rows selected (0.11 seconds)
0: jdbc:hive2://localhost:10000>

这里是hadoop中对应的文件

[abbasbutt@localhost test]$ hadoop fs -ls /user/hive/warehouse/
17/01/19 10:48:04 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Found 4 items
drwxrwxr-x   - abbasbutt supergroup          0 2017-01-18 23:45 /user/hive/warehouse/fdw_db.db
drwxrwxr-x   - abbasbutt supergroup          0 2017-01-18 23:23 /user/hive/warehouse/my_spark_db.db
drwxrwxr-x   - abbasbutt supergroup          0 2017-01-19 10:47 /user/hive/warehouse/my_test_db.db
drwxrwxr-x   - abbasbutt supergroup          0 2017-01-18 23:45 /user/hive/warehouse/testdb.db

[abbasbutt@localhost test]$ hadoop fs -ls /user/hive/warehouse/my_test_db.db/
17/01/19 10:50:52 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Found 1 items
drwxrwxr-x   - abbasbutt supergroup          0 2017-01-19 10:50 /user/hive/warehouse/my_test_db.db/my_names_tab
[abbasbutt@localhost test]$