「Spark」Spark SQL Thrift Server運行方式

Spark SQL能夠使用JDBC/ODBC或命令行接口充當分佈式查詢引擎。這種模式,用戶或者應用程序能夠直接與Spark SQL交互,以運行SQL查詢,無需編寫任何代碼。node

Spark SQL提供兩種方式來運行SQL:sql

  • 經過運行Thrift Server
  • 直接執行Spark SQL命令行

運行Thrift Server方式

一、先運行Hive metastoreapache

nohup hive --service metastore &分佈式


二、在 hdfs-site.xml 中添加如下配置oop

<property>
       <name>fs.hdfs.impl.disable.cache</name>
       <value>true</value>
</property>spa


三、啓動Thrift Server命令行

[root@node1 sbin]# pwd
/export/servers/spark-2.2.0-bin-hadoop2.6/sbinserver

[root@node1 sbin]# ./start-thriftserver.sh --master local[*]
starting org.apache.spark.sql.hive.thriftserver.HiveThriftServer2, logging to /export/servers/spark-2.2.0-bin-hadoop2.6/logs/spark-root-org.apache.spark.sql.hive.thriftserver.HiveThriftServer2-1-node1.outxml

默認的端口是:10000接口

注意:啓動 Thrift Server 的命令兼容spark-submit的全部命令


四、使用 beeline 鏈接 Thrift Server

[root@node1 bin]# ./beeline Beeline version 1.2.1.spark2 by Apache Hive beeline> !connect jdbc:hive2://node1:10000 Connecting to jdbc:hive2://node1:10000 Enter username for jdbc:hive2://node1:10000: root Enter password for jdbc:hive2://node1:10000: 20/02/01 22:26:41 INFO jdbc.Utils: Supplied authorities: node1:10000 20/02/01 22:26:41 INFO jdbc.Utils: Resolved authority: node1:10000 20/02/01 22:26:41 INFO jdbc.HiveConnection: Will try to open client transport with JDBC Uri: jdbc:hive2://node1:10000 Connected to: Spark SQL (version 2.2.0) Driver: Hive JDBC (version 1.2.1.spark2) Transaction isolation: TRANSACTION_REPEATABLE_READ 0: jdbc:hive2://node1:10000> show databases; +---------------+--+ | databaseName  | +---------------+--+ | default       | | demo          | | job_analysis  | | test          | +---------------+--+ 4 rows selected (0.629 seconds)

相關文章
相關標籤/搜索