使用MySQL作为Metastore安装hive-0.7.1后无法创建表

时间:2011-12-12 23:39:02

标签: mysql hadoop hive

我使用MySQL 5.5作为Metastore安装了hive-0.7.1。当我尝试创建一个简单的表时,它失败了。我得到了例外

com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`hiveone`.`tbls`, CONSTRAINT `TBLS_FK2` FOREIGN KEY (`SD_ID`) REFERENCES `SDS` (`SD_ID`))

请帮助建议我应该如何继续。

hive> CREATE TABLE pokes (foo INT, bar STRING);
FAILED: Error in metadata: javax.jdo.JDODataStoreException: Insert of object     "org.apache.hadoop.hive.metastore.model.MTable@4d092447" using statement "INSERT INTO `TBLS` (`TBL_ID`,`LAST_ACCESS_TIME`,`TBL_TYPE`,`CREATE_TIME`,`OWNER`,`SD_ID`,`RETENTION`,`VIEW_ORIGINAL_TEXT`,`TBL_NAME`,`DB_ID`,`VIEW_EXPANDED_TEXT`) VALUES (?,?,?,?,?,?,?,?,?,?,?)" failed : Cannot add or update a child row: a foreign key constraint fails (`hiveone`.`tbls`, CONSTRAINT `TBLS_FK2` FOREIGN KEY (`SD_ID`) REFERENCES `SDS` (`SD_ID`))
NestedThrowables:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`hiveone`.`tbls`, CONSTRAINT `TBLS_FK2` FOREIGN KEY (`SD_ID`) REFERENCES `SDS` (`SD_ID`))
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask

hive-site.xml设置如下:

<property>
  <name>hive.metastore.local</name>
  <value>true</value>
</property>

<property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:mysql://localhost:3306/hiveone?createDatabaseIfNotExist=true</value>
</property>

<property>
  <name>javax.jdo.option.ConnectionDriverName</name>
  <value>com.mysql.jdbc.Driver</value>
</property>

<property>
  <name>javax.jdo.option.ConnectionUserName</name>
  <value>hadoop</value>
</property>

<property>
  <name>javax.jdo.option.ConnectionPassword</name>
  <value>pwd</value>
</property>

</configuration>

MySQL中的表格如下:

SDS表格为空。

mysql> show tables;
+-------------------+
| Tables_in_hiveone |
+-------------------+
| BUCKETING_COLS |
| COLUMNS |
| DATABASE_PARAMS |
| PARTITION_KEYS |
| SDS |
| SD_PARAMS |
| SEQUENCE_TABLE |
| SERDES |
| SERDE_PARAMS |
| SORT_COLS |
| TABLE_PARAMS |
| TBLS |
| dbs |
+-------------------+
13 rows in set (0.00 sec)

问题是Hive期望的SDS数据是什么?

1 个答案:

答案 0 :(得分:1)

hive-0.7.1不支持MySQL 5.5。故事的结局。