Launch Hive-metastore and hive-server2 to connect hive with beeline error
[Email protected] hive]# beelinebeeline version 0.13.1-cdh5.3.0 by Apache hivebeeline>!connect jdbc:hive2:// 172.16.145.114:10000 Hivescan complete in 3msConnecting to jdbc:hive2://172.16.145.114:10000enter password for JDBC: hive2://172.16.145.114:10000: * * * *error:could not open connection to jdbc:hive2://172.16.145.114:10000: Java.net.ConnectException:Connection refused (state=08s01,code=0)0:jdbc:hive2://172.16.145.114:10000 (closed ) >!connect jdbc:hive2://172.16.145.114:10000 Hive
Verify that the hive user has been given permission to the current host link database:
mysql> use MySQL; Reading table information for completion of table and column namesyou can turn off this feature to get a quicker startup W Ith-adatabase changedmysql> Select Host,user from user;+-----------+------+| Host % | hive || 127.0.0.1 | root | | localhost | hive | | localhost | root | | node04 | root |+-------- ---+------+5 rows in Set (0.00 sec)
To view the Metastore log, the error message is as follows:
... MORE2016-11-14 16:10:00,881 ERROR [main]: Metastore. Metastoredirectsql (metastoredirectsql.java:<init> (135))-self-test query [select "db_id" from "DBS"] failed; Direct SQL is disabledjavax.jdo.JDODataStoreException:Error Executing SQL query "select" db_id "from" DBS "". At Org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException (nucleusjdohelper.java:451) at Org.datanucleus.api.jdo.JDOQuery.execute (jdoquery.java:230) at Org.apache.hadoop.hive.metastore.metastoredirectsql.<init> (metastoredirectsql.java:131) at Org.apache.hadoop.hive.metastore.ObjectStore.initialize (objectstore.java:253) at Org.apache.hadoop.hive.metastore.ObjectStore.setConf (objectstore.java:224) at Org.apache.hadoop.util.ReflectionUtils.setConf (reflectionutils.java:73) at Org.apache.hadoop.util.ReflectionUtils.newInstance (reflectionutils.java:133) at Org.apache.hadoop.hive.metastore.rawstoreproxy.<init> (rawstoreproxy.java:58) at Org.apache.hadoop.hive.metastore.RawStoreProxy.getProxy (rawstoreproxy.java:67) at Org.apache.hadoop.hive.metastore.hivemetastore$hmshandler.newrawstore (hivemetastore.java:506) at Org.apache.hadoop.hive.metastore.hivemetastore$hmshandler.getms (Hivemetastore.java:484) at Org.apache.hadoop.hive.metastore.hivemetastore$hmshandler.createdefaultdb (HiveMetaStore.java : 532) at Org.apache.hadoop.hive.metastore.hivemetastore$hmshandler.init (hivemetastore.java:406) at Org.apach E.hadoop.hive.metastore.hivemetastore$hmshandler.<init> (hivemetastore.java:365) at Org.apache.hadoop.hive.metastore.retryinghmshandler.<init> (retryinghmshandler.java:55) at Org.apache.hadoop.hive.metastore.RetryingHMSHandler.getProxy (retryinghmshandler.java:60) at Org.apache.hadoop.hive.metastore.HiveMetaStore.newHMSHandler (hivemetastore.java:4953) at Org.apache.hadoop.hive.metastore.HiveMetaStore.startMetaStore (hivemetastore.java:5174) at Org.apache.hadoop.hive.metastore.HiveMetaStore.main (hivemetastore.java:5093) 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:212) Nestedthrowablesstacktrace: Com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table ' Metastore. DBS ' doesn ' t exist At Sun.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method) at Sun.reflect.NativeConstructorAc Cessorimpl.newinstance (nativeconstructoraccessorimpl.java:57) at Sun.reflect.DelegatingConstructorAccessorImpl.newInstance (delegatingconstructoraccessorimpl.java:45) at Java.lang.reflect.Constructor.newInstance (constructor.java:526) at Com.mysql.jdbc.Util.handleNewInstance ( util.java:411) at Com.mysql.jdbc.Util.getInstance (util.java:386) at Com.mysql.jdbc.SQLError.createSQLExcepti On (sqlerror.java:1052) at Com.mysql.jdbc.MysqlIO.checkErrorPacket (mysqlio.java:3597) at Com.mysql.jdbc.Mysql Io.checkerrorpacket (mysqlio.java:3529) at Com.mysql.jdbc.MysqlIO.sendCommand (mysqlio.java:1990) at Com.mysql . jdbc. Mysqlio.sqlquerydirect (mysqlio.java:2151) at Com.mysql.jdbc.ConnectionImpl.execSQL (connectionimpl.java:2625) At Com.mysql.jdbc.PreparedStatement.executeInternal (preparedstatement.java:2119)At Com.mysql.jdbc.PreparedStatement.executeQuery (preparedstatement.java:2283) at Com.jolbox.bonecp.PreparedStatementHandle.executeQuery (preparedstatementhandle.java:174) at Org.datanucleus.store.rdbms.ParamLoggingPreparedStatement.executeQuery (paramloggingpreparedstatement.java:381) At Org.datanucleus.store.rdbms.SQLController.executeStatementQuery (sqlcontroller.java:504) at Org.datanucleus.store.rdbms.query.SQLQuery.performExecute (sqlquery.java:280) at Org.datanucleus.store.query.Query.executeQuery (query.java:1786) at Org.datanucleus.store.query.AbstractSQLQuery.executeWithArray (abstractsqlquery.java:339) at Org.datanucleus.store.query.Query.execute (query.java:1654) at Org.datanucleus.api.jdo.JDOQuery.execute ( jdoquery.java:221) at org.apache.hadoop.hive.metastore.metastoredirectsql.<init> (MetaStoreDirectSql.java : 131) at Org.apache.hadoop.hive.metastore.ObjectStore.initialize (objectstore.java:253) at org. apache.hadoop.hive.metastore.ObjectStore.setConf (objectstore.java:224) at Org.apache.hadoop.util.ReflectionUtils.setConf (reflectionutils.java:73) at Org.apache.hadoop.util.ReflectionUtils.newInstance (reflectionutils.java:133) at Org.apache.hadoop.hive.metastore.rawstoreproxy.<init> (rawstoreproxy.java:58) at Org.apache.hadoop.hive.metastore.RawStoreProxy.getProxy (rawstoreproxy.java:67) at Org.apache.hadoop.hive.metastore.hivemetastore$hmshandler.newrawstore (hivemetastore.java:506) at Org.apache.hadoop.hive.metastore.hivemetastore$hmshandler.getms (hivemetastore.java:484) at Org.apache.hadoop.hive.metastore.hivemetastore$hmshandler.createdefaultdb (hivemetastore.java:532) at Org.apache.hadoop.hive.metastore.hivemetastore$hmshandler.init (hivemetastore.java:406) at Org.apache.hadoop.hive.metastore.hivemetastore$hmshandler.<init> (hivemetastore.java:365) at Org.apache.hadoop.hive.metastore.retryinghmshandler.<init> (retryinghmshandler.java:55) at Org.apache.hadoop.hive.metastore.RetryingHMSHandler.getProxy ( RETRYINGHMSHANDLER.JAVA:60) at Org.apache.hadoop.hive.metastore.HiveMetaStore.newHMSHandler (Hivemetastore.java : 4953) at Org.apache.hadoop.hive.metastore.HiveMetaStore.startMetaStore (hivemetastore.java:5174) at Org.apac He.hadoop.hive.metastore.HiveMetaStore.main (hivemetastore.java:5093) 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.hado Op.util.RunJar.main (runjar.java:212) 2016-11-14 16:10:01,019 WARN [main]: Metastore. ObjectStore (ObjectStore.java:checkSchema (6304))-Version information not found in Metastore. Hive.metastore.schema.verification is isn't enabled so recording the Schema version 0.13.0 2016-11-14 16:10:01,063 ERROR [main]: Metastore. Hivemetastore (HiveMetaStore.java:startMetaStore (5215))-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" At Org.datanucleus.api.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException (nucleusjdohelper.java:461) A T 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:6398) at Org.apache.hadoop.hive.metastore.ObjectStore.checkSchema (objectstore.java:6308) at Org.apache.hadoop.hive.metastore.ObjectStore.verifySchema (objectstore.java:6286) 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.hado Op.hive.metastore.RawStoreProxy.invoke (RAWSTOREPROXY.Java:108) at Com.sun.proxy. $Proxy 0.verifySchema (Unknown Source) at Org.apache.hadoop.hive.metastore.HiveMetaS Tore$hmshandler.getms (hivemetastore.java:485) at org.apache.hadoop.hive.metastore.hivemetastore$ Hmshandler.createdefaultdb (hivemetastore.java:532) at org.apache.hadoop.hive.metastore.hivemetastore$ Hmshandler.init (hivemetastore.java:406) at Org.apache.hadoop.hive.metastore.hivemetastore$hmshandler.<init > (hivemetastore.java:365) at org.apache.hadoop.hive.metastore.retryinghmshandler.<init> ( retryinghmshandler.java:55) at Org.apache.hadoop.hive.metastore.RetryingHMSHandler.getProxy ( RETRYINGHMSHANDLER.JAVA:60) at Org.apache.hadoop.hive.metastore.HiveMetaStore.newHMSHandler (Hivemetastore.java : 4953) at Org.apache.hadoop.hive.metastore.HiveMetaStore.startMetaStore (hivemetastore.java:5174) at Org.apac He.hadoop.hive.metastore.HiveMetaStore.main (hivemetastore.java:5093) 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.Me Thod.invoke (method.java:606) at Org.apache.hadoop.util.RunJar.main (runjar.java:212) nestedthrowablesstacktrace:|
Guess the Hive metadata table creation failed by the error message, by looking at the metabase of Hive in MySQL, there is not a single table.
Theinitial judgment may be because this property is not set by "Either your MetaData is incorrect, or you need to enable" datanucleus.autocreatetables ". after a meal Baidu, see a post http://blog.csdn.net/eason_oracle/article/details/52273954, said is modified Hive-site.xml:
Restart Hive-metastore and Hiveserver2 after the changes have been made, or the metadata table has not been generated.
Tangled up for a long time, determined that the hive metabase is not initialized is the culprit, and finally learned that hive can initialize the metabase by command
The first time you need to execute the initialization command:
schematool -dbType mysql -initSchema
查看那初始化后的信息 schematool -dbType mysql -info
Execute the Schematool script into the bin directory of hive:./schematool-dbtype Mysql-initschema
[Email protected] bin]#./schematool -dbtype mysql-initschemametastore connection URL: jdbc:mysql://node04 : 3306/metastore?createdatabaseifnotexist=true&characterencoding=utf-8metastore Connection Driver: Com.mysql.jdbc.DriverMetastore connection User: hivestarting metastore schema initialization to 0.13.0Initialization Script Hive-schema-0.13.0.mysql.sqlinitialization Script Completedschematool completed
To view initialization information:
[Email protected] bin]#./schematool-dbtype mysql-infometastore Connection URL: jdbc:mysql://node04:3306/ Metastore?createdatabaseifnotexist=true&characterencoding=utf-8metastore Connection Driver: Com.mysql.jdbc.DriverMetastore connection User: hivehive distribution version: 0.13.0Metastore schema Version: 0.13.0schemaTool completed
View Hive's metabase and discover that the table has been generated
Mysql> Show tables;+---------------------------+| Tables_in_metastore |+---------------------------+| Bucketing_cols | | CDS | | COLUMNS_V2 | | Compaction_queue | | completed_txn_components | | Database_params | | DBS | | Db_privs | | Delegation_tokens | | Funcs | | Func_ru | | Global_privs | | Hive_locks | | Idxs | | Index_params | | Master_keys | | next_compaction_queue_id | | next_lock_id | | next_txn_id | | Nucleus_tables | | partitions | | partition_events | | Partition_keys | | Partition_key_vals | | Partition_params | | Part_col_privs | | Part_col_stats | | Part_privs | | ROLES | | Role_map | | Sds || Sd_params | | sequence_table | | SERDES | | Serde_params | | Skewed_col_names | | Skewed_col_value_loc_map | | Skewed_string_list | | Skewed_string_list_values | | Skewed_values | | Sort_cols
Restarting Metastore and Hiveserver2
Beeline Connection Hiveserve2 Successful
[Email protected] ~]# beelinebeeline version 0.13.1-cdh5.3.0 by Apache hivebeeline>!connect jdbc:hive2://node04 : 10000 Hivescan complete in 4msConnecting to jdbc:hive2://node04:10000enter password for jdbc:hive2://node04:10000: * * * Connected to:apache Hive (version 0.13.1-cdh5.3.0) driver:hive JDBC (version 0.13.1-cdh5.3.0) Transaction Isolation:tran Saction_repeatable_read0:jdbc:hive2://node04:10000> Show tables;+-----------+--+| Tab_name |+-----------+--++-----------+--+no rows selected (0.261 seconds)
Reference: http://blog.csdn.net/diudiu2025/article/details/51890673
http://blog.csdn.net/eason_oracle/article/details/52273954
Hive Uninitialized metabase error