【问题标题】:hive can't create table by hiveserver2hive 无法通过 hiveserver2 创建表
【发布时间】:2017-07-18 13:42:09
【问题描述】:

我正在构建一个最简单的配置单元服务器 (v2.1.1) 并希望在其上创建一个简单的表。但是遇到错误:

FAILED: Execution Error, return code 1 from 
org.apache.hadoop.hive.ql.exec.DDLTask.
 MetaException(message:file:/user/hive/warehouse/test2 is not a directory
 or unable to create one)

我在 CLI 上的 sql 是 create table test2(id int),这很简单。 我在hivebeeline都在CLI上测试过sql,另外JDBC也有同样的错误输出。

其他:
1. show tables 工作正常。
2. /config/:
下的配置 1) hive-site.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
    <property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://192.168.1.230:3306/hive?createDatabaseIfNotExist=true</value>
        <description>JDBC connect string for a JDBC metastore</description>    
    </property>   
    <property> 
        <name>javax.jdo.option.ConnectionDriverName</name> 
        <value>com.mysql.jdbc.Driver</value> 
        <description>Driver class name for a JDBC metastore</description>     
    </property>               

    <property> 
        <name>javax.jdo.option.ConnectionUserName</name>
        <value>hive</value>
        <description>username to use against metastore database</description>
    </property>
    <property>  
        <name>javax.jdo.option.ConnectionPassword</name>
        <value>hive</value>
        <description>password to use against metastore database</description>  
    </property>

    <property>
        <name>hive.server2.enable.impersonation</name>
        <description>Enable user impersonation for HiveServer2</description>
        <value>true</value>
    </property>
</configuration>

2) hive-default.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
    <property>
        <name>javax.jdo.option.ConnectionURL</name>
        <value>jdbc:mysql://192.168.1.230:3306/hive?createDatabaseIfNotExist=true</value>
        <description>JDBC connect string for a JDBC metastore</description>    
    </property>   
    <property> 
        <name>javax.jdo.option.ConnectionDriverName</name> 
        <value>com.mysql.jdbc.Driver</value> 
        <description>Driver class name for a JDBC metastore</description>     
    </property>               

    <property> 
        <name>javax.jdo.option.ConnectionUserName</name>
        <value>hive<value>
        <description>username to use against metastore database</description>
    </property>
    <property>  
        <name>javax.jdo.option.ConnectionPassword</name>
        <value>hive</value>
        <description>password to use against metastore database</description>  
    </property>
</configuration>

3) 用于 hadoop 用户配置的 core-site.xml

<configuration>
 <property>
      <name>hadoop.proxyuser.hadoop.groups</name>
      <value>*</value>
      <description>Allow the superuser oozie to impersonate any members of the group group1 and group2</description>
 </property>

 <property>
      <name>hadoop.proxyuser.hadoop.hosts</name>
      <value>*</value>
      <description>The superuser can connect only from host1 and host2 to impersonate a user</description>
  </property>
</configuration>
  1. presto 可以通过 presto-cli 在 hive 中创建表,通过 hive.metastore.uri 连接。
  2. 我已通过其他 SO 主题建议确保 hdfs /user/hive/warehouse 目录为 chmod 755。

我挣扎了一整天。希望给点建议。谢谢

更新 创建数据库也失败:

hive> create database testdb;
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:Unable to create database path file:/user/hive/warehouse/testdb.db, failed to create database testdb)

更新
我认为这可能是 hdfs 用户的设置问题,但我不确定在哪里可以找到所有相关设置。

【问题讨论】:

  • 我的第一个猜测是权限/用户问题。如果您暂时 chmod 777 有帮助吗? (或者甚至创建所需的目录和 chmod 777 )。
  • 不适用于hadoop fs -chmod 777 /user/hive/warehouse。还是谢谢。
  • 你能创建一个数据库(还有一个表吗?)我不确定是否可以直接在仓库中创建表(通常你至少会有一个默认数据库左右)
  • @DennisJaheruddin,创建数据库失败......我记得默认数据库的表保存在仓库目录中。
  • 尝试创建一个带有文件位置的外部表到您有权访问的空间。 Hive 用户 ID 似乎无法将数据写入元存储。

标签: hadoop hive


【解决方案1】:

它正在尝试从本地获取位置。确保 hive-site.xml 具有这样的配置

<property>
<name>hive.metastore.warehouse.dir</name>
<value>hdfs://CP000187:9000/user/hive/warehouse</value>
<description>location of default database for the
warehouse</description> 
</property>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多