[英]how to use pyhive in lambda function?
I've wrote a function that is using pyhive to read from Hive. Running it locally it works fine.我写了一个 function,它使用 pyhive 从 Hive 读取。在本地运行它工作正常。 However when trying to use lambda function I got the error: "Could not start SASL: b'Error in sasl_client_start (-4) SASL(-4): no mechanism available: No worthy mechs found'"
但是,当尝试使用 lambda function 时,我收到错误消息: “无法启动 SASL:b'sasl_client_start (-4) SASL(-4) 中的错误:没有可用的机制:找不到有价值的机制'”
I've tried to use the guidelines in this link: https://github.com/cloudera/impyla/issues/201我尝试使用此链接中的指南: https://github.com/cloudera/impyla/issues/201
However, I wasn't able to use latest command: yum install cyrus-sasl-lib cyrus-sasl-gssapi cyrus-sasl-md5
since the system I was using to build is ubuntu that doesn't support the yum function. Tried to install those packages (using apt-get): sasl2-bin libsasl2-2 libsasl2-dev libsasl2-modules libsasl2-modules-gssapi-mit但是,我无法使用最新的命令:
yum install cyrus-sasl-lib cyrus-sasl-gssapi cyrus-sasl-md5
因为我用来构建的系统是 ubuntu,它不支持 yum function。试图安装这些包(使用 apt-get): sasl2-bin libsasl2-2 libsasl2-dev libsasl2-modules libsasl2-modules-gssapi-mit
like described in: python cannot connect hiveserver2 But still no luck.如中所述: python 无法连接 hiveserver2但仍然没有运气。 Any ideas?
有任何想法吗?
Thanks, Nir.谢谢,尼尔。
You can follow this github issue .可以关注这个github issue 。 I am able to connect Hive server2 with LDAP authentication using the pyhive library in AWS Lambda with Python 2.7.
我能够使用 AWS Lambda 中的 pyhive 库将 Hive server2 与 LDAP 身份验证连接到 Python 2.7。 What I have done to make it work is:
我为让它发挥作用所做的是:
Run the following commands to install the required dependencies运行以下命令以安装所需的依赖项
yum upgrade yum install gcc yum install gcc-g++ sudo yum install cyrus-sasl cyrus-sasl-devel cyrus-sasl-ldap #include cyrus-sals dependency for authentication mechanism you are using to connect to hive pip install six==1.12.0
Bundle up the /usr/lib64/sasl2/
to Lambda and set os.environ['SASL_PATH'] = os.path.join(os.getcwd(), /path/to/sasl2
. Verify if .so
files are presented on os.environ['SASL_PATH']
path.将
/usr/lib64/sasl2/
捆绑到 Lambda 并设置os.environ['SASL_PATH'] = os.path.join(os.getcwd(), /path/to/sasl2
。验证.so
文件是否出现在os.environ['SASL_PATH']
路径。
My Lambda code looks like:我的 Lambda 代码如下所示:
from pyhive import hive import logging import os os.environ['SASL_PATH'] = os.path.join(os.getcwd(), 'lib/sasl2') log = logging.getLogger() log.setLevel(logging.INFO) log.info('Path: %s',os.environ['SASL_PATH']) def lambda_handler(event, context): cursor = hive.connect(host='hiveServer2Ip', port=10000, username='userName', auth='LDAP',password='password').cursor() SHOW_TABLE_QUERY = "show tables" cursor.execute(SHOW_TABLE_QUERY) tables = cursor.fetchall() log.info('tables: %s', tables) log.info('done')
I've wrote a function that is using pyhive to read from Hive.我写了一个 function 使用 pyhive 从 Hive 读取。 Running it locally it works fine.
在本地运行它工作正常。 However when trying to use lambda function I got the error: "Could not start SASL: b'Error in sasl_client_start (-4) SASL(-4): no mechanism available: No worthy mechs found'"
但是,当尝试使用 lambda function 时,我收到错误消息: “无法启动 SASL:b'sasl_client_start (-4) SASL(-4) 中的错误:没有可用的机制:没有找到有价值的机甲'”
I've tried to use the guidelines in this link: https://github.com/cloudera/impyla/issues/201我尝试使用此链接中的指南: https://github.com/cloudera/impyla/issues/201
However, I wasn't able to use latest command: yum install cyrus-sasl-lib cyrus-sasl-gssapi cyrus-sasl-md5
since the system I was using to build is ubuntu that doesn't support the yum function.但是,我无法使用最新命令:
yum install cyrus-sasl-lib cyrus-sasl-gssapi cyrus-sasl-md5
,因为我用来构建的系统是不支持 yum ZC1C425268E68385D1AB5074C17A94F14 的 ubuntu。 Tried to install those packages (using apt-get): sasl2-bin libsasl2-2 libsasl2-dev libsasl2-modules libsasl2-modules-gssapi-mit尝试安装这些软件包(使用 apt-get): sasl2-bin libsasl2-2 libsasl2-dev libsasl2-modules libsasl2-modules-gssapi-mit
like described in: python cannot connect hiveserver2 But still no luck.如中所述: python 无法连接 hiveserver2但仍然没有运气。 Any ideas?
有任何想法吗?
Thanks, Nir.谢谢,尼尔。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.