Support Questions
Find answers, ask questions, and share your expertise

Connection to MetaStore refused

Expert Contributor

HDP sandbox 2.6.3 on my local Windows 7 machine.

The Hive services are running fine. Using the shell or via Ambari views, I am able to create and view tables:

Hive_services_running.JPG

43814-hive-services-running.jpg

The entry in the hosts file:

127.0.0.1 localhost sandbox.hortonworks.com sandbox-hdp.hortonworks.com sandbox-hdf.hortonworks.com

I downloaded the client configs. using Ambari, now, I pass the hive-site.xml to the below code that I am trying to execute:

private static void connectHiveMetastore(String clientConfigHiveSiteAbsolutePath) throws MetaException, MalformedURLException {
        System.setProperty("hadoop.home.dir", "E:\Software\Virtualization");
        Configuration configuration = new Configuration();
        /*Start : Commented or un-commented, immaterial ...*/
        configuration.addResource(clientConfigHiveSiteAbsolutePath);
        /*End : Commented or un-commented, immaterial ...*/
        HiveConf hiveConf = new HiveConf(configuration,Configuration.class);
        /*Start : Commented or un-commented, immaterial ...*/
        URL url = new File(clientConfigHiveSiteAbsolutePath).toURI().toURL();
        HiveConf.setHiveSiteLocation(url);
        hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS,"thrift://sandbox-hdp.hortonworks.com:9083");
        /*End : Commented or un-commented, immaterial ...*/
        HiveMetaStoreClient hiveMetaStoreClient = new HiveMetaStoreClient(hiveConf);
        System.out.println("****************************Metastore client : "+hiveMetaStoreClient);
        System.out.println("****************************Is local metastore ? "+hiveMetaStoreClient.isLocalMetaStore());
        System.out.println(hiveMetaStoreClient.getAllDatabases());
        hiveMetaStoreClient.close();
    }

It's unable to connect to the Hive metastore:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/E:/Development/lib/hdp/hadoop/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/E:/Development/lib/hdp/hive2/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
2017-12-04 16:36:53,809 INFO  [main] hive.metastore (HiveMetaStoreClient.java:open(443)) - Trying to connect to metastore with URI thrift://sandbox-hdp.hortonworks.com:9083
2017-12-04 16:36:54,893 WARN  [main] hive.metastore (HiveMetaStoreClient.java:open(495)) - Failed to connect to the MetaStore Server...
2017-12-04 16:36:54,893 INFO  [main] hive.metastore (HiveMetaStoreClient.java:open(526)) - Waiting 1 seconds before next connection attempt.
2017-12-04 16:36:55,893 INFO  [main] hive.metastore (HiveMetaStoreClient.java:open(443)) - Trying to connect to metastore with URI thrift://sandbox-hdp.hortonworks.com:9083
2017-12-04 16:36:56,894 WARN  [main] hive.metastore (HiveMetaStoreClient.java:open(495)) - Failed to connect to the MetaStore Server...
2017-12-04 16:36:56,894 INFO  [main] hive.metastore (HiveMetaStoreClient.java:open(526)) - Waiting 1 seconds before next connection attempt.
2017-12-04 16:36:57,894 INFO  [main] hive.metastore (HiveMetaStoreClient.java:open(443)) - Trying to connect to metastore with URI thrift://sandbox-hdp.hortonworks.com:9083
2017-12-04 16:36:58,904 WARN  [main] hive.metastore (HiveMetaStoreClient.java:open(495)) - Failed to connect to the MetaStore Server...
2017-12-04 16:36:58,904 INFO  [main] hive.metastore (HiveMetaStoreClient.java:open(526)) - Waiting 1 seconds before next connection attempt.
Exception in thread "main" MetaException(message:Could not connect to meta store using any of the URIs provided. Most recent failure: org.apache.thrift.transport.TTransportException: java.net.ConnectException: Connection refused: connect
at org.apache.thrift.transport.TSocket.open(TSocket.java:226)
at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.open(HiveMetaStoreClient.java:487)
at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.<init>(HiveMetaStoreClient.java:282)
at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.<init>(HiveMetaStoreClient.java:188)
at com.client.MetaStoreWindowsClient.connectHiveMetastore(MetaStoreWindowsClient.java:38)
at com.client.MetaStoreWindowsClient.main(MetaStoreWindowsClient.java:18)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.thrift.transport.TSocket.open(TSocket.java:221)
... 5 more
)
at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.open(HiveMetaStoreClient.java:534)
at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.<init>(HiveMetaStoreClient.java:282)
at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.<init>(HiveMetaStoreClient.java:188)
at com.client.MetaStoreWindowsClient.connectHiveMetastore(MetaStoreWindowsClient.java:38)
at com.client.MetaStoreWindowsClient.main(MetaStoreWindowsClient.java:18)
Process finished with exit code 1

What am I missing?

0 REPLIES 0