hive无法通过hiveserver2创建表

时间:2017-07-13 11:13:57

标签: hadoop hive

我构建了一个最简单的配置单元服务器(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.配置下< project-dir> /配置/:
    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可以通过hit.metastore.uri连接的presto-cli在hive中创建表。
  2. 我确保hdfs /user/hive/warehouse目录是chmod 755其他SO主题建议。
  3. 我一整天都在挣扎。希望有任何建议。感谢

    更新 创建数据库也失败了:

    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用户的设置问题,但我不知道在哪里可以找到所有相关设置。

1 个答案:

答案 0 :(得分:0)

它试图从本地获取位置。确保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>