Hive问题集

企业动态
今天讲一讲关于Hive的问题、原因以及解决方法。

 1、FAILED: Error in metadata: java.lang.RuntimeException: Unable to instantiate org

问题:

起因是我重装了mysql数据库。

安装之后 把访问权限都配置好 :

  1. GRANT ALL PRIVILEGES ON*.* TO 'hive'@'%' Identified by 'hive';  
  2. GRANT ALL PRIVILEGES ON*.* TO 'hive'@'localhost' Identified by 'hive';  
  3. GRANT ALL PRIVILEGES ON*.* TO 'hive'@'127.0.0.1' Identified by 'hive' 

本机地址: 192.168.103.43 机器名字:192-168-103-43 

  1. flush privileges

启动hive 发生下面的错误:

  1. hive> show tables;FAILED: Error in metadata: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient 
  2. FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTaskFAILED: Error in metadata: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClientFAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask  
  1. cd ${HIVE_HOME}/bin 
  2. ./hive -hiveconf hive.root.logger=DEBUG,console 
  3. hive> show tables;  

得到如下的错误信息(当然 不同的问题所产生的日志是不同的):

  1. Caused by: javax.jdo.JDOFatalDataStoreException: Access denied for user 'hive'@'192-168-103-43' (using password: YES) 
  2. NestedThrowables: 
  3. java.sql.SQLException: Access denied for user 'hive'@'192-168-103-43' (using password: YES) 
  4.     at org.datanucleus.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:298) 
  5.     at org.datanucleus.jdo.JDOPersistenceManagerFactory.freezeConfiguration(JDOPersistenceManagerFactory.java:601) 
  6.     at org.datanucleus.jdo.JDOPersistenceManagerFactory.createPersistenceManagerFactory(JDOPersistenceManagerFactory.java:286) 
  7.     at org.datanucleus.jdo.JDOPersistenceManagerFactory.getPersistenceManagerFactory(JDOPersistenceManagerFactory.java:182) 
  8.     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
  9.     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
  10.     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
  11.     at java.lang.reflect.Method.invoke(Method.java:597) 
  12.     at javax.jdo.JDOHelper$16.run(JDOHelper.java:1958) 
  13.     at java.security.AccessController.doPrivileged(Native Method) 
  14.     at javax.jdo.JDOHelper.invoke(JDOHelper.java:1953) 
  15.     at javax.jdo.JDOHelper.invokeGetPersistenceManagerFactoryOnImplementation(JDOHelper.java:1159) 
  16.     at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:803) 
  17.     at javax.jdo.JDOHelper.getPersistenceManagerFactory(JDOHelper.java:698) 
  18.     at org.apache.hadoop.hive.metastore.ObjectStore.getPMF(ObjectStore.java:262) 
  19.     at org.apache.hadoop.hive.metastore.ObjectStore.getPersistenceManager(ObjectStore.java:291) 
  20.     at org.apache.hadoop.hive.metastore.ObjectStore.initialize(ObjectStore.java:224) 
  21.     at org.apache.hadoop.hive.metastore.ObjectStore.setConf(ObjectStore.java:199) 
  22.     at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:62) 
  23.     at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:117) 
  24.     at org.apache.hadoop.hive.metastore.RetryingRawStore.<init>(RetryingRawStore.java:62) 
  25.     at org.apache.hadoop.hive.metastore.RetryingRawStore.getProxy(RetryingRawStore.java:71) 
  26.     at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.newRawStore(HiveMetaStore.java:413) 
  27.     at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.getMS(HiveMetaStore.java:401) 
  28.     at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.createDefaultDB(HiveMetaStore.java:439) 
  29.     at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.init(HiveMetaStore.java:325) 
  30.     at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.<init>(HiveMetaStore.java:285) 
  31.     at org.apache.hadoop.hive.metastore.RetryingHMSHandler.<init>(RetryingHMSHandler.java:53) 
  32.     at org.apache.hadoop.hive.metastore.RetryingHMSHandler.getProxy(RetryingHMSHandler.java:58) 
  33.     at org.apache.hadoop.hive.metastore.HiveMetaStore.newHMSHandler(HiveMetaStore.java:4102) 
  34.     at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.<init>(HiveMetaStoreClient.java:121) 
  35.     ... 28 more  

原因:

发现数据库的权限 HIVE需要的是

'hive'@'192-168-103-43' 这个IP地址

解决:

然后试着在mysql中加上权限:

  1. GRANT ALL PRIVILEGES ON*.* TO 'hive'@'192-168-103-43' Identified by 'hive';  
  2. flush privileges 

再次登录hive

  1. hive> show tables; 

OK

[[179248]]

2、Hive出现异常 FAILED: Error In Metadata: Java.Lang.RuntimeException: Unable To Instan

问题:

在公司的虚拟机上运行hive计算,因为要计算的数据量较大,频繁,导致了服务器负载过高,mysql也出现无法连接的问题,最后虚拟机出现The remote system refused the connection.重启虚拟机后,进入hive。 

  1. hive> show tables; 

出现了下面的问题:

  1. FAILED: Error in metadata: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient 
  2. FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTaskFAILED: Error in metadata: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClientFAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask 

 

原因:

用下面的命令,重新启动hive

  1. ./hive -hiveconf hive.root.logger=DEBUG,console 
  2. hive> show tables;  

能够看到更深层次的原因的是: 

  1. Caused by: java.lang.reflect.InvocationTargetException 
  2.     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
  3.     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) 
  4.     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) 
  5.     at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 
  6.     at org.apache.hadoop.hive.metastore.MetaStoreUtils.newInstance(MetaStoreUtils.java:1076) 
  7.     … 23 more 
  8. Caused by: javax.jdo.JDODataStoreException: Exception thrown obtaining schema column information from datastore 
  9. NestedThrowables: 
  10. com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table ‘hive.DELETEME1370713761025′ doesn’t exist  

根据提示的信息,登陆mysql或者mysql客户端查看hive的数据库的表信息

  1. mysql -u root -p 
  2. mysql> use hive; 
  3. mysql> show tables; 
  4. +—————————+ 
  5. | Tables_in_hive | 
  6. +—————————+ 
  7. | BUCKETING_COLS | 
  8. | CDS | 
  9. | COLUMNS_V2 | 
  10. | DATABASE_PARAMS | 
  11. | DBS | 
  12. | DELETEME1370677637267 | 
  13. | DELETEME1370712928271 | 
  14. | DELETEME1370713342355 | 
  15. | DELETEME1370713589772 | 
  16. | DELETEME1370713761025 | 
  17. | DELETEME1370713792915 | 
  18. | IDXS | 
  19. | INDEX_PARAMS | 
  20. | PARTITIONS | 
  21. | PARTITION_KEYS | 
  22. | PARTITION_KEY_VALS | 
  23. | PARTITION_PARAMS | 
  24. | PART_COL_PRIVS | 
  25. | PART_COL_STATS | 
  26. | PART_PRIVS | 
  27. | SDS | 
  28. | SD_PARAMS | 
  29. | SEQUENCE_TABLE | 
  30. | SERDES | 
  31. | SERDE_PARAMS | 
  32. | SKEWED_COL_NAMES | 
  33. | SKEWED_COL_VALUE_LOC_MAP | 
  34. | SKEWED_STRING_LIST | 
  35. | SKEWED_STRING_LIST_VALUES | 
  36. | SKEWED_VALUES | 
  37. | SORT_COLS | 
  38. | TABLE_PARAMS | 
  39. | TAB_COL_STATS | 
  40. | TBLS | 
  41. | TBL_COL_PRIVS | 
  42. | TBL_PRIVS | 
  43. +—————————+ 
  44. 36 rows in set (0.00 sec)  

能够看到“DELETEME1370713792915”这个表,问题明确了,由于计算的压力过大,服务器停止响应,mysql也停止了响应,mysql进程被异常终止,在运行中的mysql表数据异常,hive的元数据表异常。

解决问题的办法有两个:

1.直接在mysql中drop 异常提示中的table;

mysql>drop table DELETEME1370713761025;

2.保守的做法,根据DELETEME*表的结构,创建不存在的表

CREATE TABLE `DELETEME1370713792915` ( `UNUSED` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

通过实践,第一个方法就能够解决问题,如果不行可以尝试第二个方法。

3、hive错误show tables无法使用 : Unable to instantiate rg.apache.hadoop.hive.metastore.

问题:

hive异常show tables无法使用:

Unable to instantiate rg.apache.hadoop.hive.metastore.HiveMetaStoreClient

异常:

  1. hive> show tables; 
  2. FAILED: Error in metadata: java.lang.RuntimeException: Unable to instantiate rg.apache.hadoop.hive.metastore.HiveMetaStoreClient  
  3. FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask  

原因:

在其他shell 开了hive 没有关闭

解决:

使用 ps -ef | grep hive

kill -9

杀死进程

4、FAILED: Error in metadata: java.lang.RuntimeException: Unable to in(2)(08-52-23)

问题:安装配置Hive时报错:

  1. FAILED: Error in metadata: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient 
  2. FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask  

用调试模式报错如下: 

  1. [root@hadoop1 bin]# hive -hiveconf hive.root.logger=DEBUG,console 
  2. 13/10/09 16:16:27 DEBUG common.LogUtils: Using hive-site.xml found on CLASSPATH at /opt/hive-0.11.0/conf/hive-site.xml 
  3. 13/10/09 16:16:27 DEBUG conf.Configuration: java.io.IOException: config() 
  4.     at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:227) 
  5.     at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:214) 
  6.     at org.apache.hadoop.hive.conf.HiveConf.<init>(HiveConf.java:1039) 
  7.     at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:636) 
  8.     at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:614) 
  9.     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
  10.     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
  11.     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
  12.     at java.lang.reflect.Method.invoke(Method.java:597) 
  13.     at org.apache.hadoop.util.RunJar.main(RunJar.java:156) 
  14.   
  15. 13/10/09 16:16:27 DEBUG conf.Configuration: java.io.IOException: config() 
  16.     at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:227) 
  17.     at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:214) 
  18.     at org.apache.hadoop.mapred.JobConf.<init>(JobConf.java:330) 
  19.     at org.apache.hadoop.hive.conf.HiveConf.initialize(HiveConf.java:1073) 
  20.     at org.apache.hadoop.hive.conf.HiveConf.<init>(HiveConf.java:1040) 
  21.     at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:636) 
  22.     at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:614) 
  23.     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
  24.     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
  25.     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
  26.     at java.lang.reflect.Method.invoke(Method.java:597) 
  27.     at org.apache.hadoop.util.RunJar.main(RunJar.java:156) 
  28.   
  29. Logging initialized using configuration in file:/opt/hive-0.11.0/conf/hive-log4j.properties 
  30. 13/10/09 16:16:27 INFO SessionState:  
  31. Logging initialized using configuration in file:/opt/hive-0.11.0/conf/hive-log4j.properties 
  32. 13/10/09 16:16:27 DEBUG parse.VariableSubstitution: Substitution is on: hive 
  33. Hive history file=/tmp/root/hive_job_log_root_4666@hadoop1_201310091616_1069706211.txt 
  34. 13/10/09 16:16:27 INFO exec.HiveHistory: Hive history file=/tmp/root/hive_job_log_root_4666@hadoop1_201310091616_1069706211.txt 
  35. 13/10/09 16:16:27 DEBUG conf.Configuration: java.io.IOException: config() 
  36.     at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:227) 
  37.     at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:214) 
  38.     at org.apache.hadoop.security.UserGroupInformation.ensureInitialized(UserGroupInformation.java:187) 
  39.     at org.apache.hadoop.security.UserGroupInformation.isSecurityEnabled(UserGroupInformation.java:239) 
  40.     at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:438) 
  41.     at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:424) 
  42.     at org.apache.hadoop.hive.shims.HadoopShimsSecure.getUGIForConf(HadoopShimsSecure.java:491) 
  43.     at org.apache.hadoop.hive.ql.security.HadoopDefaultAuthenticator.setConf(HadoopDefaultAuthenticator.java:51) 
  44.     at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:62) 
  45.     at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:117) 
  46.     at org.apache.hadoop.hive.ql.metadata.HiveUtils.getAuthenticator(HiveUtils.java:365) 
  47.     at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:270) 
  48.     at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:670) 
  49.     at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:614) 
  50.     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
  51.     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
  52.     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
  53.     at java.lang.reflect.Method.invoke(Method.java:597) 
  54.     at org.apache.hadoop.util.RunJar.main(RunJar.java:156) 
  55.   
  56. 13/10/09 16:16:27 DEBUG security.Groups:  Creating new Groups object 
  57. 13/10/09 16:16:27 DEBUG security.Groups: Group mapping impl=org.apache.hadoop.security.ShellBasedUnixGroupsMapping; cacheTimeout=300000 
  58. 13/10/09 16:16:27 DEBUG security.UserGroupInformation: hadoop login 
  59. 13/10/09 16:16:27 DEBUG security.UserGroupInformation: hadoop login commit 
  60. 13/10/09 16:16:27 DEBUG security.UserGroupInformation: using local user:UnixPrincipal锛?root 
  61. 13/10/09 16:16:27 DEBUG security.UserGroupInformation: UGI loginUser:root 
  62. 13/10/09 16:16:27 DEBUG security.Groups: Returning fetched groups for 'root' 
  63. 13/10/09 16:16:27 DEBUG security.Groups: Returning cached groups for 'root' 
  64. 13/10/09 16:16:27 DEBUG conf.Configuration: java.io.IOException: config(config) 
  65.     at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:260) 
  66.     at org.apache.hadoop.hive.conf.HiveConf.<init>(HiveConf.java:1044) 
  67.     at org.apache.hadoop.hive.ql.security.authorization.DefaultHiveAuthorizationProvider.init(DefaultHiveAuthorizationProvider.java:30) 
  68.     at org.apache.hadoop.hive.ql.security.authorization.HiveAuthorizationProviderBase.setConf(HiveAuthorizationProviderBase.java:108) 
  69.     at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:62) 
  70.     at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:117) 
  71.     at org.apache.hadoop.hive.ql.metadata.HiveUtils.getAuthorizeProviderManager(HiveUtils.java:339) 
  72.     at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:272) 
  73.     at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:670) 
  74.     at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:614) 
  75.     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
  76.     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
  77.     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
  78.     at java.lang.reflect.Method.invoke(Method.java:597) 
  79.     at org.apache.hadoop.util.RunJar.main(RunJar.java:156) 
  80.   
  81. 13/10/09 16:16:27 DEBUG conf.Configuration: java.io.IOException: config() 
  82.     at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:227) 
  83.     at org.apache.hadoop.conf.Configuration.<init>(Configuration.java:214) 
  84.     at org.apache.hadoop.mapred.JobConf.<init>(JobConf.java:330) 
  85.     at org.apache.hadoop.hive.conf.HiveConf.initialize(HiveConf.java:1073) 
  86.     at org.apache.hadoop.hive.conf.HiveConf.<init>(HiveConf.java:1045) 
  87.     at org.apache.hadoop.hive.ql.security.authorization.DefaultHiveAuthorizationProvider.init(DefaultHiveAuthorizationProvider.java:30) 
  88.     at org.apache.hadoop.hive.ql.security.authorization.HiveAuthorizationProviderBase.setConf(HiveAuthorizationProviderBase.java:108) 
  89.     at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:62) 
  90.     at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:117) 
  91.     at org.apache.hadoop.hive.ql.metadata.HiveUtils.getAuthorizeProviderManager(HiveUtils.java:339) 
  92.     at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:272) 
  93.     at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:670) 
  94.     at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:614) 
  95.     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
  96.     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
  97.     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
  98.     at java.lang.reflect.Method.invoke(Method.java:597) 
  99.     at org.apache.hadoop.util.RunJar.main(RunJar.java:156)  

原因:

这个错误应该是你集成了mysql,从而报错

解决:

修改hive-site.xml,参照:

  1. <property>    
  2.     <name>javax.jdo.option.ConnectionURL</name>    
  3.     <value>jdbc:mysql://192.168.1.101:3306/hive?createDatabaseIfNotExist=true</value>    
  4.     <description>JDBC connect string for a JDBC metastore</description>  
  5. </property>  

5、Hive的--auxpath使用相对路径遇到的一个奇怪的异常

问题:

在使用Hive的--auxpath过程中,如果我使用的是相对路径(例如,--auxpath=abc.jar),会产生下面的一个异常: 

  1. java.lang.IllegalArgumentException: Can not create a Path from an empty string 
  2.     at org.apache.hadoop.fs.Path.checkPathArg(Path.java:91) 
  3.     at org.apache.hadoop.fs.Path.<init>(Path.java:99) 
  4.     at org.apache.hadoop.fs.Path.<init>(Path.java:58) 
  5.     at org.apache.hadoop.mapred.JobClient.copyRemoteFiles(JobClient.java:619) 
  6.     at org.apache.hadoop.mapred.JobClient.copyAndConfigureFiles(JobClient.java:724) 
  7.     at org.apache.hadoop.mapred.JobClient.copyAndConfigureFiles(JobClient.java:648)  

原因:

从异常的内容来看,是由于使用了一个空字符串来创建一个Path对象。

经过分析发现,使用"--auxpath=abc.jar"来启动Hive时,Hive会自动在abc.jar前面补上"file://"。也就是说Hive最后使用的路径是"file://abc.jar"。

当我们使用"file://abc.jar"来生成一个Path时,调用这个Path的getName将会返回""(空字符串)。而Hive在提交MapReduce的Job时,会使用getName来获取文件名,并创建一个新的Path对象。下面的示例代码演示了一下这个过程,会抛出上文提到的异常。

  1. Path path = new Path("file://abc.jar"); 
  2. System.out.println("path name:" + path.getName()); 
  3. System.out.println("authority:" + path.toUri().getAuthority()); 
  4. Path newPath = new Path(path.getName());  

上文的代码输出

path name:

authority:abc.jar

并抛出了异常"Can not create a Path from an empty string"

那么为什么"file://abc.jar"生成的Path的getName返回的是""而不是"abc.jar"呢,而且"abc.jar"却成了authority?在Path中的处理代码如下: 

  1. if (pathString.startsWith("//", start) && (pathString.length()-start > 2)) { // has authority 
  2.     int nextSlash = pathString.indexOf('/', start+2); 
  3.     int authEnd = nextSlash > 0 ? nextSlash : pathString.length(); 
  4.     authority = pathString.substring(start+2, authEnd); 
  5.     start = authEnd; 
  6. // uri path is the rest of the string -- query & fragment not supported 
  7. String path = pathString.substring(start, pathString.length());  

pathString就是传进去的"file://abc.jar",由于我们只有两个"/"因此,从第二个"/"到结尾的字符串("abc.jar")都被当成了authority,path(内部的成员)则设置成了""而getName返回的就是path,因此也就为""了。

解决:

如果使用Hive的--auxpath来设置jar,必须使用绝对路径,或者使用"file:///.abc.jar"这样的表示法。这个才是Hadoop的Path支持的方式。事实上,hadoop许多相关的Path的设置,都存在这个问题,所以在无法确定的情况下,就不要使用相对路径了。

6、启动hive hwi服务时出现 HWI WAR file not found错误

问题:

  1. hive --service hwi 
  2. [niy@niy-computer /]$ $HIVE_HOME/bin/hive --service hwi 
  3. 13/04/26 00:21:17 INFO hwi.HWIServer: HWI is starting up 
  4. 13/04/26 00:21:18 FATAL hwi.HWIServer: HWI WAR file not found at /usr/local/hive/usr/local/hive/lib/hive-hwi-0.12.0-SNAPSHOT.war  

原因:

可以看出/usr/local/hive/usr/local/hive/lib/hive-hwi-0.12.0-SNAPSHOT.war肯定不是正确路径,真正路径是/usr/local/hive/lib/hive-hwi-0.12.0-SNAPSHOT.war,断定是配置的问题

解决:将hive-default.xml中关于 hwi的设置拷贝到hive-site.xml中即可

  1. <property>   
  2.     <name>hive.hwi.war.file</name>   
  3.     <value>lib/hive-hwi-0.12.0-SNAPSHOT.war</value>   
  4.     <description>This sets the path to the HWI war file, relative to ${HIVE_HOME}. </description>   
  5. </property>   
  6. <property>   
  7.     <name>hive.hwi.listen.host</name>   
  8.     <value>0.0.0.0</value>   
  9.     <description>This is the host address the Hive Web Interface will listen on</description>   
  10. </property>     
  11. <property>   
  12.     <name>hive.hwi.listen.port</name>   
  13.     <value>9999</value>   
  14.     <description>This is the port the Hive Web Interface will listen on</description>   
  15. </property>  

7、问题:当启动Hive的时候报错: 

  1. Caused by: javax.jdo.JDOException: Couldnt obtain a new sequence (unique id) : Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENTandat least one table uses a storage engine limited to row-based logging.  
  2. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED.  
  3. NestedThrowables: java.sql.SQLException: Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT andat least one table uses a storage engine limited to row-based logging.  
  4. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED

 原因:

这个问题是由于hive的元数据存储MySQL配置不当引起的

解决办法: 

  1. mysql> setglobal binlog_format='MIXED'

8、问题:

当在Hive中创建表的时候报错:

  1. create table years (year string, eventstring) row format delimited fields terminated by'\t'; FAILED: Execution Error, return code 1from org.apache.hadoop.hive.ql.exec.DDLTask.  
  2. MetaException(message:For direct MetaStore DB connections, we don't support retries at the client level.)  

原因:

这是由于字符集的问题,需要配置MySQL的字符集:

解决办法:

  1. mysql> alter database hive character set latin1; 

9、问题:

当执行Hive客户端时候出现如下错误:

WARN conf.HiveConf: HiveConf of name hive.metastore.localdoesnot exist

原因:这是由于在0.10 0.11或者之后的HIVE版本 hive.metastore.local 属性不再使用。

解决办法:

将该参数从hive-site.xml删除即可。

10、问题:

在启动Hive报如下错误:

(Permission denied: user=anonymous, access=EXECUTE, inode="/tmp":hadoop:supergroup:drwx------

原因:这是由于Hive没有hdfs:/tmp目录的权限,

解决办法:

赋权限即可:hadoop dfs -chmod -R 777 /tmp

11、Hive查询数据库时,出现null。无数据显示。

问题如下: 

 

 

 

解决办法:

  1. LOAD DATA LOCAL INPATH '/tmp/sanple.txt' overwrite into table animal FIELDS TERMINATED BY '\t'

解释:

数据分隔符的问题,定义表的时候需要定义数据分隔符,

  1. FIELDS TERMINATED BY '\t' 

这个字段就说明了数据分隔符是tab。

具体分割符请以自己的文化中具体的情况来定。

12、ERROR beeline.ClassNameCompleter: Fail to parse the class name from the Jar file due to

在使用beeline链接Hive服务的时候,报了下面的这个错误:

  1. beeline> !connect jdbc:hive2//h2slave1:10000 
  2. scan complete in 1ms 
  3. 16/07/27 11:40:54 [main]: ERROR beeline.ClassNameCompleter: Fail to parse the class name from the Jar file due to the exception:java.io.FileNotFoundException: minlog-1.2.jar (没有那个文件或目录) 
  4. 16/07/27 11:40:54 [main]: ERROR beeline.ClassNameCompleter: Fail to parse the class name from the Jar file due to the exception:java.io.FileNotFoundException: objenesis-1.2.jar (没有那个文件或目录) 
  5. 16/07/27 11:40:54 [main]: ERROR beeline.ClassNameCompleter: Fail to parse the class name from the Jar file due to the exception:java.io.FileNotFoundException: reflectasm-1.07-shaded.jar (没有那个文件或目录) 
  6. scan complete in 596ms 
  7. No known driver to handle "jdbc:hive2//h2slave1:10000" 

 解决:

其实这个问题是由于jdbc协议地址写错造成的,在hive2之后少了个“:”

改成以下这个形式即可:

  1. beeline> !connect jdbc:hive2://h2slave1:10000 

13、Missing Hive Execution Jar: /.../hive-exec-*.jar

运行hive时显示Missing Hive Execution Jar: /usr/hive/hive-0.11.0/bin/lib/hive-exec-*.jar

运行hive时显示Missing Hive Execution Jar: /usr/hive/hive-0.11.0/bin/lib/hive-exec-*.jar

细细分析这个目录/bin/lib,在hive安装文件夹中这两个目录是并列的,而系统能够找到这样的链接,说明hive在centos系统配置文件中的路径有误,打开 /etc/profile会发现hive的配置路径为

  1. export PATH=$JAVA_HOME/bin:$PATH:/usr/hive/hive-0.11.0/bin 

明显可以看出是路径配置的问题,这样的配置系统会在hive安装文件夹中的bin目录下寻找它所需要的jar包,而bin和lib文件夹是并列的,所以我们需要在centos系统配置文件中将hive路径配置为文件夹安装路径,即

  1. export PATH=$JAVA_HOME/bin:$PATH:/usr/hive/hive-0.11.0 

注意:这种问题一般都是出在环境变量上面的配置。请认真检查etc/profile跟你hive的安装路径。

14、hive启动报错: Found class jline.Terminal, but interface was expected

错误如下: 

  1. [ERROR] Terminal initialization failed; falling back to unsupported 
  2. java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected 
  3.     at jline.TerminalFactory.create(TerminalFactory.java:101) 
  4.     at jline.TerminalFactory.get(TerminalFactory.java:158) 
  5.     at jline.console.ConsoleReader.<init>(ConsoleReader.java:229) 
  6.     at jline.console.ConsoleReader.<init>(ConsoleReader.java:221) 
  7.     at jline.console.ConsoleReader.<init>(ConsoleReader.java:209) 
  8.     at org.apache.hadoop.hive.cli.CliDriver.getConsoleReader(CliDriver.java:773) 
  9.     at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:715) 
  10.     at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:675) 
  11.     at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:615) 
  12.     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
  13.     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
  14.     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
  15.     at java.lang.reflect.Method.invoke(Method.java:606) 
  16.     at org.apache.hadoop.util.RunJar.main(RunJar.java:212)  

原因:

jline版本冲突不一致导致的,hadoop目录下存在老版本jline:

/hadoop-2.6.0/share/hadoop/yarn/lib:

jline-0.9.94.jar

解决:

把hive中的新版本jline拷贝一份到hadoop的share/hadoop/yarn/lib即可

同时要把那个老版本的给删除 

  1. cp /hive/apache-hive-1.1.0-bin/lib/jline-2.12.jar /hadoop-2.5.2/share/hadoop/yarn/lib 

15、MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes

在使用hive时,使用mysql存储元数据的时候,遇到下面的错误:

  1. com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes 
  2.     at sun.reflect.GeneratedConstructorAccessor31.newInstance(Unknown Source) 
  3.     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
  4.     at java.lang.reflect.Constructor.newInstance(Constructor.java:526) 
  5.     at com.mysql.jdbc.Util.handleNewInstance(Util.java:377) 
  6.     at com.mysql.jdbc.Util.getInstance(Util.java:360)  

解决办法:

用mysql做元数据,要修改数据字符集

  1. alter database hive character set latin1  

【本文为51CTO专栏作者“王森丰”的原创稿件,转载请注明出处】

责任编辑:庞桂玉 来源: 神算子
相关推荐

2016-12-14 15:59:31

HBase分布式数据

2016-12-14 14:47:59

Zookeeper服务器

2016-12-19 15:32:12

Linux问题集

2016-12-13 16:36:15

Hadoopwindows

2011-03-28 17:51:10

nagios

2010-03-25 16:20:44

CentOS安装

2011-02-22 14:21:49

vsftpd

2009-10-09 17:40:38

VB.Net问题集

2018-07-12 09:25:07

磁盘阵列数据恢复

2011-02-25 14:25:04

Proftpd

2011-02-22 14:40:25

vsftpd

2009-12-31 15:28:02

Silverlight

2009-07-01 00:23:40

MySQL字符集乱码

2011-05-16 13:15:55

MySQL存储字符集

2011-03-03 13:41:36

Pureftpd防火墙

2011-03-03 14:26:15

PureftpdSSHFTP

2014-03-26 11:15:26

Hive

2021-08-04 07:21:31

Hive 数据排查

2010-05-17 10:01:09

MySql字符集

2011-03-03 14:56:56

Pureftpd脚本
点赞
收藏

51CTO技术栈公众号