简体   繁体   English

为什么我无法使用Apache Spark与Hive Metastore连接?

[英]Why I am not able to connect with the hive metastore using apache spark?

I am trying to connect with the apache hive using apache spark with the help of a java program. 我试图在Java程序的帮助下使用apache spark与apache配置单元连接。 Here is the program: 这是程序:

import org.apache.spark.sql.SparkSession;

public class queryhive {

    public static void main(String[] args)
{
    String warehouseLocation = "spark-warehouse";

    SparkSession spark = SparkSession
            .builder()
            .appName("Java Spark Hive Example")
            .master("local[*]")
            .config("spark.sql.warehouse.dir", warehouseLocation)
            .enableHiveSupport()
            .getOrCreate();
try
{
      spark.sql("select count(*) from heath1").show();
}
catch (Exception AnalysisException)
{
    System.out.print("\nTable is not found\n");
}
}
}

I have added to the maven pom.xml: the address of hdfs and the address of hive in the <properties> tag. 我已经在Maven pom.xml中添加了<properties>标记中的hdfs地址和hive地址。
I would like to query the hive tables using the spark. 我想使用火花查询配置单元表。 But I could not see the tables, as I am getting exception of table not found: 但是我看不到表格,因为我找不到表格的例外:

    log4j:WARN No appenders could be found for logger (org.apache.hadoop.util.Shell).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
17/02/18 11:30:56 INFO SparkContext: Running Spark version 2.1.0
17/02/18 11:30:56 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
17/02/18 11:30:56 WARN Utils: Your hostname, aims resolves to a loopback address: 127.0.1.1; using 10.0.0.3 instead (on interface wlp2s0)
17/02/18 11:30:56 WARN Utils: Set SPARK_LOCAL_IP if you need to bind to another address
17/02/18 11:30:56 INFO SecurityManager: Changing view acls to: aims
17/02/18 11:30:56 INFO SecurityManager: Changing modify acls to: aims
17/02/18 11:30:56 INFO SecurityManager: Changing view acls groups to: 
17/02/18 11:30:56 INFO SecurityManager: Changing modify acls groups to: 
17/02/18 11:30:56 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users  with view permissions: Set(aims); groups with view permissions: Set(); users  with modify permissions: Set(aims); groups with modify permissions: Set()
17/02/18 11:30:57 INFO Utils: Successfully started service 'sparkDriver' on port 32975.
17/02/18 11:30:57 INFO SparkEnv: Registering MapOutputTracker
17/02/18 11:30:57 INFO SparkEnv: Registering BlockManagerMaster
17/02/18 11:30:57 INFO BlockManagerMasterEndpoint: Using org.apache.spark.storage.DefaultTopologyMapper for getting topology information
17/02/18 11:30:57 INFO BlockManagerMasterEndpoint: BlockManagerMasterEndpoint up
17/02/18 11:30:57 INFO DiskBlockManager: Created local directory at /tmp/blockmgr-6263f04a-5c65-4dda-9e9a-faafb32a066a
17/02/18 11:30:57 INFO MemoryStore: MemoryStore started with capacity 335.4 MB
17/02/18 11:30:57 INFO SparkEnv: Registering OutputCommitCoordinator
17/02/18 11:30:58 INFO Utils: Successfully started service 'SparkUI' on port 4040.
17/02/18 11:30:58 INFO SparkUI: Bound SparkUI to 0.0.0.0, and started at http://10.0.0.3:4040
17/02/18 11:30:58 INFO Executor: Starting executor ID driver on host localhost
17/02/18 11:30:58 INFO Utils: Successfully started service 'org.apache.spark.network.netty.NettyBlockTransferService' on port 43772.
17/02/18 11:30:58 INFO NettyBlockTransferService: Server created on 10.0.0.3:43772
17/02/18 11:30:58 INFO BlockManager: Using org.apache.spark.storage.RandomBlockReplicationPolicy for block replication policy
17/02/18 11:30:58 INFO BlockManagerMaster: Registering BlockManager BlockManagerId(driver, 10.0.0.3, 43772, None)
17/02/18 11:30:58 INFO BlockManagerMasterEndpoint: Registering block manager 10.0.0.3:43772 with 335.4 MB RAM, BlockManagerId(driver, 10.0.0.3, 43772, None)
17/02/18 11:30:58 INFO BlockManagerMaster: Registered BlockManager BlockManagerId(driver, 10.0.0.3, 43772, None)
17/02/18 11:30:58 INFO BlockManager: Initialized BlockManager: BlockManagerId(driver, 10.0.0.3, 43772, None)
17/02/18 11:30:58 INFO SharedState: Warehouse path is 'hdfs://localhost:8020/user/hive/warehouse/default.db/spark-warehouse'.
17/02/18 11:30:58 INFO HiveUtils: Initializing HiveMetastoreConnection version 1.2.1 using Spark classes.
17/02/18 11:30:59 INFO HiveMetaStore: 0: Opening raw store with implemenation class:org.apache.hadoop.hive.metastore.ObjectStore
17/02/18 11:30:59 INFO ObjectStore: ObjectStore, initialize called
17/02/18 11:31:00 INFO Persistence: Property hive.metastore.integral.jdo.pushdown unknown - will be ignored
17/02/18 11:31:00 INFO Persistence: Property datanucleus.cache.level2 unknown - will be ignored
17/02/18 11:31:02 INFO ObjectStore: Setting MetaStore object pin classes with hive.metastore.cache.pinobjtypes="Table,StorageDescriptor,SerDeInfo,Partition,Database,Type,FieldSchema,Order"
17/02/18 11:31:03 INFO Datastore: The class "org.apache.hadoop.hive.metastore.model.MFieldSchema" is tagged as "embedded-only" so does not have its own datastore table.
17/02/18 11:31:03 INFO Datastore: The class "org.apache.hadoop.hive.metastore.model.MOrder" is tagged as "embedded-only" so does not have its own datastore table.
17/02/18 11:31:03 INFO Datastore: The class "org.apache.hadoop.hive.metastore.model.MFieldSchema" is tagged as "embedded-only" so does not have its own datastore table.
17/02/18 11:31:03 INFO Datastore: The class "org.apache.hadoop.hive.metastore.model.MOrder" is tagged as "embedded-only" so does not have its own datastore table.
17/02/18 11:31:03 INFO Query: Reading in results for query "org.datanucleus.store.rdbms.query.SQLQuery@0" since the connection used is closing
17/02/18 11:31:03 INFO MetaStoreDirectSql: Using direct SQL, underlying DB is DERBY
17/02/18 11:31:03 INFO ObjectStore: Initialized ObjectStore
17/02/18 11:31:05 INFO HiveMetaStore: Added admin role in metastore
17/02/18 11:31:05 INFO HiveMetaStore: Added public role in metastore
17/02/18 11:31:05 INFO HiveMetaStore: No user is added in admin role, since config is empty
17/02/18 11:31:05 INFO HiveMetaStore: 0: get_all_databases
17/02/18 11:31:05 INFO audit: ugi=aims  ip=unknown-ip-addr  cmd=get_all_databases   
17/02/18 11:31:05 INFO HiveMetaStore: 0: get_functions: db=default pat=*
17/02/18 11:31:05 INFO audit: ugi=aims  ip=unknown-ip-addr  cmd=get_functions: db=default pat=* 
17/02/18 11:31:05 INFO Datastore: The class "org.apache.hadoop.hive.metastore.model.MResourceUri" is tagged as "embedded-only" so does not have its own datastore table.
17/02/18 11:31:06 INFO SessionState: Created local directory: /tmp/cac4110a-ebb3-47a6-b21e-682a12724ba2_resources
17/02/18 11:31:06 INFO SessionState: Created HDFS directory: /tmp/hive/aims/cac4110a-ebb3-47a6-b21e-682a12724ba2
17/02/18 11:31:06 INFO SessionState: Created local directory: /tmp/aims/cac4110a-ebb3-47a6-b21e-682a12724ba2
17/02/18 11:31:06 INFO SessionState: Created HDFS directory: /tmp/hive/aims/cac4110a-ebb3-47a6-b21e-682a12724ba2/_tmp_space.db
17/02/18 11:31:06 INFO HiveClientImpl: Warehouse location for Hive client (version 1.2.1) is hdfs://localhost:8020/user/hive/warehouse/default.db/spark-warehouse
17/02/18 11:31:06 INFO HiveMetaStore: 0: get_database: default
17/02/18 11:31:06 INFO audit: ugi=aims  ip=unknown-ip-addr  cmd=get_database: default   
17/02/18 11:31:06 INFO HiveMetaStore: 0: get_database: global_temp
17/02/18 11:31:06 INFO audit: ugi=aims  ip=unknown-ip-addr  cmd=get_database: global_temp   
17/02/18 11:31:06 WARN ObjectStore: Failed to get database global_temp, returning NoSuchObjectException
17/02/18 11:31:06 INFO SparkSqlParser: Parsing command: select count(*) from health1
17/02/18 11:31:08 INFO HiveMetaStore: 0: get_table : db=default tbl=health1
17/02/18 11:31:08 INFO audit: ugi=aims  ip=unknown-ip-addr  cmd=get_table : db=default tbl=health1  
17/02/18 11:31:08 INFO HiveMetaStore: 0: get_table : db=default tbl=health1
17/02/18 11:31:08 INFO audit: ugi=aims  ip=unknown-ip-addr  cmd=get_table : db=default tbl=health1  

Table is not found
17/02/18 11:31:08 INFO SparkContext: Invoking stop() from shutdown hook
17/02/18 11:31:08 INFO SparkUI: Stopped Spark web UI at http://10.0.0.3:4040
17/02/18 11:31:08 INFO MapOutputTrackerMasterEndpoint: MapOutputTrackerMasterEndpoint stopped!
17/02/18 11:31:08 INFO MemoryStore: MemoryStore cleared
17/02/18 11:31:08 INFO BlockManager: BlockManager stopped
17/02/18 11:31:08 INFO BlockManagerMaster: BlockManagerMaster stopped
17/02/18 11:31:08 INFO OutputCommitCoordinator$OutputCommitCoordinatorEndpoint: OutputCommitCoordinator stopped!
17/02/18 11:31:08 INFO SparkContext: Successfully stopped SparkContext
17/02/18 11:31:08 INFO ShutdownHookManager: Shutdown hook called
17/02/18 11:31:08 INFO ShutdownHookManager: Deleting directory /tmp/spark-ea93f7ec-6151-43e9-b5d9-bedbba537d62

I am using Apache hive 1.2.0 and Spark 2.1.0 我正在使用Apache Hive 1.2.0和Spark 2.1.0
I believe the issue is not because of the versions.Using Eclipse Neon as IDE.Kindly, let me know why I am facing this problem and how I can resolve it. 我相信问题不在于版本,请使用Eclipse Neon作为IDE。请告诉我为什么会遇到这个问题以及如何解决这个问题。

You need to specify the schema name. 您需要指定架构名称。 Either as select * from schmaName.tableName or as shown below 从schmaName.tableName中选择*或如下所示

try
{
      spark.sql("use schemaName")         // name of the schema
      spark.sql("select count(*) from heath1").show();
}
catch (Exception AnalysisException)
{
    System.out.print("\nTable is not found\n");
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Java在Apache Spark程序中指定Hive的metastore? - How I can specify the metastore of Hive in Apache Spark program using java? Spark 2与Hive MetaStore的连接 - Spark 2 connection to Hive MetaStore 我无法通过ssh连接到mysql,也不知道为什么使用Java - I am not able to connect to mysql via ssh and I don't know why using Java 为什么我不能使用JavaMail(IMAP协议)连接到我的邮箱,并收到“没有身份验证失败”错误消息? - Why am I not able to connect to my mail box using JavaMail (IMAP protocol) and getting NO AUTHENTICATE failed error? 为什么我无法通过蓝牙 android 连接到设备? - Why am I not able to connect to device via Bluetooth android? 我正在尝试使用jconsole连接到具有身份验证的JMX,但我无法这样做。 但是我无需身份验证就可以连接它 - I am trying to connect to JMX with authentication using jconsole, but I am not able to do so. But I am able to connect it without authentication 从Spark连接到Hive,无需使用“ hive-site.xml” - Connect to Hive from Spark without using “hive-site.xml” 我正在使用 spring 启动并尝试连接 Apache Phoenix - i am using spring boot and trying to connect Apache Phoenix Apache Spark我在这里坚持什么? - Apache Spark what am I persisting here? Apache Hive:无法实例化org.apache.hadoop.hive.metastore.HiveMetaStoreClient - Apache Hive : Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM