error无法使用pyhive连接到配置单元数据库

qhhrdooz  于 2021-06-26  发布在  Hive
关注(0)|答案(0)|浏览(419)

这是用于连接我们的配置单元数据库的代码,一周前运行良好,但现在似乎连打开会话和获取游标来执行查询都失败了。当我显式添加cursor.close()方法时,这个问题暂时得到了解决,但现在又回来了。我无法使用python访问配置单元数据库
我尝试过使用pyhs2和pyhive这两个库都无法连接到hive数据库。到目前为止,集群没有任何变化。为什么会这样?
我知道hive不是关系数据库,所以游标的概念没有意义,但是hive数据库有没有办法记住使用pyhive库创建的游标??如果是这样,我如何删除当前未使用的光标??
下面是它在执行时引发的代码和异常

from pyhive import hive
import contextlib

class Hive():
    def __init__(self,host="[hostnamehere]",db="default",port="10000",auth="KERBEROS",kerberos_service_name="hive"):
        self.host = host
        self.db = db
        self.port = port
        self.auth = auth
        self.kerberos_service_name = kerberos_service_name

    def connect(self):
        return(hive.connect(host=self.host, port=self.port, database=self.db, auth=self.auth, kerberos_service_name=self.kerberos_service_name))

    def query_one(self,sql):
        with contextlib.closing(self.connect()) as connection:
            with contextlib.closing(connection.cursor()) as cursor:
                cursor.execute(sql)
                result = cursor.fetch_one()
                cursor.close()
        return(result)

if __name__ == "__main__":
    connector = Hive()
    print("running query")
    print(connector.query_one("SELECT * FROM [tablenamehere]"))

raise operationalerror(response)pyhive.exc.operationalerror:topensessionresp(状态=tstatus(状态码=3,信息消息=['*org.apache.hive.service.cli.hivesqlexception:failed to 打开新会话:java.lang.runtimeexception:java.lang.runtimeexception:无法示例化org.apache.hadoop.hive.ql.metadata.sessionhivemetastoreclient:13:12','org.apache.hive.service.cli.session.sessionmanager:opensession:会话管理器。java:289','org.apache.hive.service.cli.cliservice:opensession:cliservice。java:199','org.apache.hive.service.cli.thrift.thriftcliservice:getsessionhandle:节俭服务。java:427','org.apache.hive.service.cli.thrift.thriftcliservice:opensession:节俭服务。java:319','org.apache.hive.service.cli.thrift.tcliservice$processor$opensession:getresult:t仪器。java:1257','org.apache.hive.service.cli.thrift.tcliservice$processor$opensession:getresult:t仪器。java:1242','org.apache.thrift.proces.'sfunction:process:processfunction。java:39','org.apache.thrift.tbaseprocessor:process:t基础处理器。java:39','org.apache.hadoop.hive.thrift.hadoopthriftauthbridge$server$tugiasumingprocessor:process:hadoopthriftauthbridge。java:562','org.apache.thrift.server.tthreadpoolserver$工作erprocess:run:t线程池服务器。java:286','java.util.concurrent.threadpoolexecutor:runworker:threadpoolexecutor。java:1149','java.util.concurrent.threadpoolexecutor$worker:run:threadpoolexecutor。java:624','java.lang。thread:run:线程。java:748','*java.lang.runtimeexception:java.lang.runtimeexception:无法示例化org.apache.hadoop.hive.ql.metadata.sessionhivemetastoreclient:15:2',org.apache.hadoop.hive.ql.session.sessionstate:start:会话状态。java:547','org.apache.hive.service.cli.session.hivesessionimpl:open:hivesessionimpl。java:144','org.apache.hive.service.cli.session.sessionmanager:opensession:会话管理器。java:281','*java.lang.runtimeexception:unable to 示例化org.apache.hadoop.hive.ql.metadata.sessionhivemetastoreclient:21:6','org.apache.hadoop.hive.metastore.metastoreutils:newinstance:metastoreutils。java:1566','org.apache.hadoop.hive.metastore.retryingmetastoreclient::retryingmetastoreclient。java:92','org.apache.hadoop.hive.metastore.retryingmetastoreclient:getproxy:正在重试MetaStoreClient。java:138','org.apache.hadoop.hive.metastore.retryingmetastoreclient:getproxy:正在重试MetaStoreClient。java:110','org.apache.hadoop.hive.ql.metadata。hive:createmetastoreclient:Hive。java:3510','org.apache.hadoop.hive.ql.metadata。hive:getmsc:Hive。java:3542','org.apache.hadoop.hive.ql.session.sessionstate:start:会话状态。java:528','*java.lang.reflect.invocationtargetexception:null:25:4','sun.reflect.nativeconstructoracc'essorimpl:newinstance0:NativeConstructor附件模板。java:-2','sun.reflect.nativeconstructoraccessorimpl:newinstance:NativeConstructor附件模板。java:62','sun.reflect.delegatingconstructoraccessorimpl:newinstance:delegatingconstructoraccessorimpl。java:45','java.lang.reflect.constructor:newinstance:构造函数。java:423','org.apache.hadoop.hive.metastore.metastoreutils:newinstance:metastoreutils。java:1564','*org.apache.hadoop.hive.metastore.api.metaexception:gc overhead 限制exceeded:30:4',org.apache.hadoop.hive.metastore.retryinghmshandler::retryinghmshandler。java:82','org.apache.hadoop.hive.metastore.retryingh'mshandler:getproxy:重试hmshandler。java:91','org.apache.hadoop.hive.metastore.hivemetastore:newretryinghmshandler:hivemetastore。java:6463','org.apache.hadoop.hive.metastore.hivemetastoreclient::hivemetastoreclient。java:206','org.apache.hadoop.hive.ql.metadata.sessionhivemetastoreclient::sessionhivemetastoreclient。java:76','*java.lang.outofmemoryerror:gc overhead 限制exceeded:0:-1'],sqlstate=none,errorcode=0,errormessage='failed to open new session:java.lang.runtimeexception:java.lang.runtimeexception:unable to instantiate org.apache.hadoop.hive.ql.metadata.sessionhivemetastoreclient'),serverprotocolversion=7,sessionhandle=none,configuration=none)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题