简体   繁体   English

如何在lambda function中使用pyhive?

[英]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:我为让它发挥作用所做的是:

  1. Took one EC2 instance or launch container with AMI used in Lambda . 使用 Lambda 中使用的 AMI 获取一个 EC2 实例或启动容器。
  2. 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
  3. 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']路径。

  4. 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.

相关问题 如何在lambda function中使用动态资源URL - How to use dynamic resource URL in lambda function 如何在 Lambda Function 的 CodeCommit 存储库中使用代码? - How to use code in a CodeCommit repository for a Lambda Function? 如何为 Cloudfront 创建 HttpOrigin 以使用 Lambda function url? - How do I create a HttpOrigin for Cloudfront to use a Lambda function url? 如何将 AWS 还原作业用于触发器 Lambda function - How to use an AWS Restore job to a trigger Lambda function 如何在我的 Lambda Function 中使用带有回调返回步骤 Function 的 Heartbeat? - How do I use Heartbeat with a Callback Return Step Function in my Lambda Function? 如何在 AWS 中使用 gifsicle lambda - How to use gifsicle in AWS lambda 如何在从 lambda function 执行 jupyter notebook 时使用 Conda 内核 - How to use Conda kernels while executing jupyter notebook from lambda function 如何使用 s3 触发器为 s3 存储桶中的特定文件夹调用 lambda function - How to use a s3 trigger to invoke a lambda function for a specific folder in s3 bucket 使用上次成功执行时间在 lambda function - use last successful execution time in lambda function 如何退出 NodeJs lambda function? - How to exit a NodeJs lambda function?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM