Hiveの――起動問題と解決策


転載は出典を明記してください。http://blog.csdn.net/l1028386804/article/details/51566262
問題1:
Caused by: javax.jdo.JDODataStoreException: Required table missing : "`VERSION`" in Catalog "" Schema "". DataNucleus requires this table to perform its persistence operations. Either your MetaData is incorrect, or you need to enable "datanucleus.autoCreateTables"
NestedThrowables:
org.datanucleus.store.rdbms.exceptions.MissingTableException: Required table missing : "`VERSION`" in Catalog "" Schema "". DataNucleus requires this table to perform its persistence operations. Either your MetaData is incorrect, or you need to enable "datanucleus.autoCreateTables"
        at org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:461)
        at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:732)
        at org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:752)
        at org.apache.hadoop.hive.metastore.ObjectStore.setMetaStoreSchemaVersion(ObjectStore.java:6664)
解決方法:
hiveのソースコードを調べて追跡します。
 if ((this.readOnlyDatastore) || (this.fixedDatastore))  
 {  
   this.autoCreateTables = false;  
   this.autoCreateColumns = false;  
   this.autoCreateConstraints = false;  
 }  
 else  
 {  
   boolean autoCreateSchema = conf.getBooleanProperty("datanucleus.autoCreateSchema");  
   if (autoCreateSchema)  
   {  
     this.autoCreateTables = true;  
     this.autoCreateColumns = true;  
     this.autoCreateConstraints = true;  
   }  
   else
   {  
     this.autoCreateColumns = conf.getBooleanProperty("datanucleus.autoCreateColumns");  
     this.autoCreateTables = conf.getBooleanProperty("datanucleus.autoCreateTables");  
     this.autoCreateConstraints = conf.getBooleanProperty("datanucleus.autoCreateConstraints");  
   }
 }
では、キーポイントはthis.readOnlyDatastoreとthis.fixedDatastoreの2つのフィールドであり、aut CreateSchemaという設定はtrueであれば他の設定が決定されますので、他の設定はここで無効になります。引き続き追跡org.datanucles.store.AbstractStore Managerがこの2つのフィールドの設定コードを発見しました。
  this.readOnlyDatastore = conf.getBooleanProperty("datanucleus.readOnlyDatastore");
  this.fixedDatastore = conf.getBooleanProperty("datanucleus.fixedDatastore");  
で修正された構成の内容は以下の通りです。

    datanucleus.readOnlyDatastore
    false

 
    datanucleus.fixedDatastore
    false 

 
    datanucleus.autoCreateSchema 
    true 


    datanucleus.autoCreateTables
    true


    datanucleus.autoCreateColumns
    true
または将:

    datanucleus.schema.autoCreateAll
    false
    creates necessary schema on a startup if one doesn't exist. set this to false, after creating it once
 
を変更しました

    datanucleus.schema.autoCreateAll
    true
    creates necessary schema on a startup if one doesn't exist. set this to false, after creating it once
 
問題2:
16/06/02 10:49:52 WARN conf.HiveConf: DEPRECATED: Configuration property hive.metastore.local no longer has any effect. Make sure to provide a valid value for hive.metastore.uris if you are connecting to a remote metastore.
16/06/02 10:49:52 WARN conf.HiveConf: HiveConf of name hive.metastore.local does not exist

Logging initialized using configuration in jar:file:/usr/local/hive/lib/hive-common-0.14.0.jar!/hive-log4j.properties
Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: The root scratch dir: /tmp/hive on HDFS should be writable. Current permissions are: rwx--x--x
        at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:444)
        at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:672)
        at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:616)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:160)
Caused by: java.lang.RuntimeException: The root scratch dir: /tmp/hive on HDFS should be writable. Current permissions are: rwx--x--x
        at org.apache.hadoop.hive.ql.session.SessionState.createRootHDFSDir(SessionState.java:529)
        at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:478)
        at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:430)
        ... 7 more
解決方法:
[root@hadoop ~]# hadoop fs -chmod -R 777 /tmp/hive
[root@hadoop ~]# hadoop fs -ls /tmp
Found 1 items
drwxrwxrwx   - root supergroup          0 2016-06-02 08:48 /tmp/hive
問題3:
16/06/02 09:33:13 WARN conf.HiveConf: DEPRECATED: Configuration property hive.metastore.local no longer has any effect. Make sure to provide a valid value for hive.metastore.uris if you are connecting to a remote metastore.
16/06/02 09:33:13 WARN conf.HiveConf: HiveConf of name hive.metastore.local does not exist

Logging initialized using configuration in jar:file:/usr/local/hive/lib/hive-common-0.14.0.jar!/hive-log4j.properties
Exception in thread "main" java.lang.RuntimeException: java.net.ConnectException: Call to hadoop/192.168.52.139:9000 failed on connection exception: java.net.ConnectException: Connection refused
        at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:444)
        at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:672)
        at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:616)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:160)
Caused by: java.net.ConnectException: Call to hadoop/192.168.52.139:9000 failed on connection exception: java.net.ConnectException: Connection refused
解決方法:
この問題はhadoopが起動されていないため、hadoopを起動した後に問題が解決されます。
問題4:
[root@hadoop ~]# hive
16/06/02 09:38:06 WARN conf.HiveConf: DEPRECATED: Configuration property hive.metastore.local no longer has any effect. Make sure to provide a valid value for hive.metastore.uris if you are connecting to a remote metastore.
16/06/02 09:38:06 WARN conf.HiveConf: HiveConf of name hive.metastore.local does not exist
Logging initialized using configuration in jar:file:/usr/local/hive/lib/hive-common-0.14.0.jar!/hive-log4j.properties
hive>
解決方法:
0.10で  0.11以降のHIVEバージョンhive.metastore.local属性は使用されません。
設定ファイルで:
 
 	hive.metastore.local
  	false
  	controls whether to connect to remove metastore server or open a new metastore server in Hive Client JVM
は削除して、再度ログインすると警告が消えます。
問題5:
Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D
        at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:444)
        at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:672)
        at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:616)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:160)
Caused by: java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D
        at org.apache.hadoop.fs.Path.initialize(Path.java:148)
        at org.apache.hadoop.fs.Path.(Path.java:126)
        at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:487)
        at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:430)
        ... 7 more
Caused by: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D
        at java.net.URI.checkPath(URI.java:1804)
        at java.net.URI.(URI.java:752)
        at org.apache.hadoop.fs.Path.initialize(Path.java:145)
        ... 10 more
解決方法:
設定ファイルのhive-site.xmlで「system:java.io.tmpdir」を探して彼らを絶対パスに変えました。
hive-site.xmlの完全な内容は以下の通りです。





     
        javax.jdo.option.ConnectionURL 
        jdbc:mysql://192.168.52.139:3306/hive?createDatabaseIfNotExsit=true;characterEncoding=UTF-8 
     
     
        javax.jdo.option.ConnectionDriverName 
        com.mysql.jdbc.Driver
    
    
        javax.jdo.option.ConnectionUserName
        hive
    
     
        javax.jdo.option.ConnectionPassword 
        hive 
     

    
        datanucleus.readOnlyDatastore
        false
    
     
        datanucleus.fixedDatastore
        false 
    

     
        datanucleus.autoCreateSchema 
        true 
    
    
    
        datanucleus.autoCreateTables
        true
    

    
        datanucleus.autoCreateColumns
        true
    


問題6:
hive> show tables;
FAILED: Error in metadata: MetaException(message:Got exception: javax.jdo.JDODataStoreException An exception was thrown while adding/validating class(es) : Specified key was too long; max key length is 767 bytes
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes
解析:
mysqlの最大インデックス長により、MySQLのvarrharキーは768バイトまたは768/2=384バイトまたは768/3=256バイトのフィールドだけをサポートし、GBKは2バイト、UTF-8は3バイトです。
ソリューション:
データベースの文字セットは、systemがutf 8である以外に、他のものはlatin 1が一番いいです。そうでないと、上記のような異常が発生し、mysqlマシンで実行されるかもしれません。
mysql> show variables like '%char%';
mysql>alter database    character set latin1;
mysql>flush privileges;